Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkeyIOSOSXWindows

Alternate Reality Map 3D Demo For Delphi XE5 Firemonkey On Android And IOS

Delphi XE5 Firemonkey Alternate Reality 3D Map DemoI put together this alternate reality 3D map demo using Delphi XE5 Firemonkey and tested it on Windows and Android (though I’m sure it probably works on IOS and OSX as well).

I started out with a TForm3D (so the Firemonkey 3D form) and added a TPlane to it. The plane has it’s RotationAngle.X set to 315 (which is -45 degrees) to get the tilt. I added a TTextureMaterialSource component and linked it to the TPlane before assigning a default image to it. I also added a TFloatAnimation to the TPlane, set it to change PropertyName RotationAngle.Z, Duration 10, StartFromCurrent, and StopValue 359. The FloatAnimation causes the plane object to rotate.

Next I added a TCone in the center of the screen, tilted it -45 degrees to match the TPlane, gave it a LightMaterialSource, and placed a TLight above the cone to give it some shading. I then added a TLayer3D into the scene and set it’s Projection to pjScreen and set it’s Align property to alContents. I placed a TLabel inside of the TLayer3D and set it’s Align to alMostBottom. you can use the TLayer3D to add whatever other interface controls you want on to this project.

I have also added a TIdHTTP component and linked in a TIdCompressionIntercept, TIdCompressorZLib, TIdCookieManager, and TIdSSLIOHandlerSocketOpenSSL (none of these besides TIdHTTP are necessary). I setup a function called LoadMapImage() which uses TIdHTTP in an anonymous thread to download a map from Google Maps static image service. You should get a Google Maps static API key to use the static service more than a few times.

Next up I added a TLocationSensor and a couple timers. Your GPS needs to be enabled on your mobile device for the location sensor to work. The first timer delays the start of the location sensor and the second timer only allows the location sensor to update the map every 5 seconds. At start up it loads a high zoom map of the United States as it waits for the location sensor to kick in and as a placeholder on Windows which has no location sensor. The map that gets loaded is passed through SaveBitmapWithEffect function which applies a TInvertEffect to the bitmap before assigning it to the TPlane texture.

That is pretty much all there is to it. It needs polish and you can continue to enhance it and use it for your own purposes.

Download the full project with source code for Delphi XE5 Firemonkey Alternate Reality Map 3D.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
AndroidC++BuilderCode SnippetDelphiDemoFiremonkeyIOSOSXShowcaseWindows

Powerful Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

Significant Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

C++BuilderDelphiIDEWindows

Professional SVG Icon Image List For Delphi 10.4 FireMonkey On Windows

AndroidC++BuilderDelphiFiremonkeyIOSLiveBindingsOSXWindows

Top Tips And Tricks To Speed Up Development With Delphi 10.4 FireMonkey On Android and IOS

Sign up for our Newsletter and
stay informed

2 Comments

Leave a Reply