C++Game DevelopmentLearn C++

Learn to Develop a Perseverance Mars Simulation 3D in C++ Builder

Do you want to develop your own Mars Simulation with the latest Mars Perseverance Rover 3D Model or Mars Ingenuity Helicopter 3D Model? C++ Builder is very easy to develop this kind of simple simulations. You just need a 3D object model and some colors, lights, a camera, maybe some textures. This same method and results can be obtained in Delphi too. Let’s see how it is easy to do a simulation.

  1. Create a new C++ Builder Multi-Device FMX Project, Save all Unit and Project files to a folder (i.e. PerseveranceSim)
  2. We will use Viewport3D to display our 3D environment (scene). Drag a TViewport3D onto your Form. Set UseDesign Camera property to false, because we will use our camera to view objects in this scene.
  3. Add TCamera from the 3D Scene group in Tools Palette, Set its Position->Z to -10
  4. We will use Model3D to display our 3D object. Drag TModel3D
  5. We need some lights, Drag TLight from the Tools Palette to the ViewPort3D. Set its LightType to Point and its Position->Y to -10 in the Object Inspector window.
  6. and we need MaterialSource to display it in colors, Add a LightMatrialSource from the Tools Palette
  7. Now let’s download Mars Perseverance Rover, 3D Model in *.GLB format from Official Nasa’s Perseverance Rover Lands on Mars Web Page. Here you can download both Mars Perseverance Rover and Mars Ingenuity Helicopter, 3D models.
  8. We can only load *.DAE, *.ASE or *.OBJ based 3D object format into our Model3D. So, we should convert this GLB to DAE. Go to free online GLB 3D object file format to DAE 3D object file format converter web page here. Drag the GLB model here to convert DAE. Submit and wait to be converted. This may take few minutes, then save it to your project folder.
  9. Now back to RADS, designer. Select Model3D1 and double click to its MeshCollection to load our 3D Model Object. 
  10. Press the Load.. button to Load our converted Rover object in *.DAE format. This may take few minutes, wait till you see 3D Rover in Mesh Collection Editor.
  11. Press the OK button to apply this to our Model3D1. This may take few minutes, wait till you see a 3D rover in your Viewport.
  12. Set Depth, Height, Width of the Model3D to 5, so you can see better. You can set its Position and RotationAngles too. 

10. Now we have Scene and 3D object. This 3D object has many parts and each part may have different Materials with Colors and Textures. Let’s simply set all parts Materials to same our Material. We can get number of parts of this Model as below,

We can set MaterialSource of i’th MeshCollection as below,

So, to set all parts of materials in to the same material we can modify our codes as below.

11. Finally we can test our application in the Camera View with our Material Colors. Just Pres F9 or Run button.

From this point, you can add a ground surface with a Mars texture and, change color of Viewport to Dark, you can add keys to move this object. Add Ingenuity Helicopter 3D Model.

You can find number of parts by increasing part number and changing its material in every button click as below,

Using this method, we found that Part 27, 28 and 29 are parts of wheels, unfortunately in this model 6 wheels built as a one object, so you can not rotate each wheels. You should delete wheels of these model and you should add your wheels if you want to rotate each of them when moving. You can move these 3d objects by changing their Position and RotationAngle in X Y Z directions. For these please read more about 3D Objects in C++ Builder;

https://learncplusplus.org/learn-about-working-with-3d-in-modern-windows-c-development/

https://learncplusplus.org/learn-about-working-with-3d-windows-components-in-c-development/

https://learncplusplus.org/learn-to-quickly-create-specific-3d-objects-in-modern-c-applications-for-windows/

You can read GLB glTF formats and create you specific 3d, please check for this https://peted.azurewebsites.net/glb-reading-and-writing/

We hope you enjoy this simple example.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20

What Is The Stack (std::stack) In Modern C++?

C++C++11C++14C++17C++20Learn C++

What Is The Queue (std::queue) In Modern C++?

C++C++11C++14C++17Learn C++SyntaxTemplates

What Are The Logical Operation Metafunctions In Modern C++?

C++C++14C++17C++20Learn C++

What Are The Deprecated C++14 Features In C++17?