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 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE5 Firemonkey Alternate Reality 3D Map Demo | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSI 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

Unleashing Creativity With Song Writer AI: A Deep Dive


How To Build Stable Diffusion Text To Image Prompts


FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes


Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

Sign up for our Newsletter and
stay informed


Leave a Reply