C++Game DevelopmentLanguage FeatureLearn C++

Let’s Fly Ingenuity Helicopter 3D Model with C++ Builder on Windows

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.

We highly recommend you to read this previous post Learn to Develop a Perseverance Mars Simulation 3D in C++ Builder

Do you want to fly  Mars Ingenuity Helicopter with Mars Physics? Let’s see how it is easy to do a simulation.

Simplified Ingenuity Fly Theory

For any helicopter, the Lift force can be written in this formula,

We don’t have too many details about the physical parameters of Ingenuity and this formula requires shape details to integrate.

We only know Ingenuity flies at 2400 rpm = 2400/60 = 40 1/s and angular velocity w=2xPIxf = 2xPIx40 . To calculate lift force in speed changes, we can use the formula above, all other parameters can be assumed as a constant K. Thus, Lift force can be simplified for this simulation as below,

And we know that Ingenuity has 1.8kg mass and gravity at Mars is 3.711 m/s2 that means Weight of Ingenuity is equal to,

Lift force should be higher than this Weight at the maximum RPM, So let’s assume Maximum Lift Force Lmax is %20 higher than this force (or you can assume 8 Nt)

Now, we can find K without knowing the geometry as below,

Now if we put this K to lift formula

We can simulate lifting up by the F net force in y+ direction as below,

We can find acceleration, velocity and Y in y direction;

Now we can use these simplified formulas to simulate Ingenuity flight

Developing 3D C++ Application

  1. Create a new C++ Builder Multi-Device FMX Project, Save all Unit and Project files to a folder (i.e. IngenuitySim)
  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 Ingenuity Helicopter 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. 
  13. Add right Panel as above with 2 Sliders and one ArcDial,
  14. Add Dummy1 object and drag Model3D and Camera into this, we will move and use Dummy1 as Ingenuity Model so both Camera and Model3D will move together.
  15. Finally we need a Label that has 800px width to give information in one line;

Let’s define constants and variables;

We can easily rotate blades (Part 26 and 27) as below with a OnTimer event;

We can also update the position of Ingenuity as below,

Let’s add our calculations into this OnTimer event,

We should initialize some parameter at the beginning. Here is the full example to fly Ingenuity in C++ Builder,

When you run you will see blades are rotating and flies when you increate it’s rpm by the vertical slider. Net force should be positive to move up and negative to move down.

Final Words,

This is a very simple example to show how to simulate a helicopter in 3D. In a more real simulation, we need to use matrix forms with rotation matrix to define effect of F force on X Y Z directions, atmospheric density can be considered here and it may vary with temperature changes, … etc . We know you can do better.


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.

Related posts
C++C++11C++14C++17Introduction to C++Learn C++

Discover Function Overloading in C++

C++Learn C++Videos

Learn C++ With Back to Basics: Move Semantics by David Olsen (CPPCon 2020) Video

C++Introduction to C++Learn C++

Learn to Use Pointers and Memory Address of a Variable in C++

C++Introduction to C++Learn C++

Discover Goto and Labels in C++