Page 1 of 1

Animating aircraft model

Posted: Fri Apr 01, 2016 3:09 pm
by dtudin01

I'm playing around with the SimpleAirplane ISimObject sample, and I'm curious about how the model's surfaces are being animated.

When registering properties in the SimpleAirplane class, if I use a name that's in the SimConnect variable list, which corresponds to a well known control in the aircraft model, will it animate the appropriate item accordingly?

For example, it is registering a property called PctElevator, which isn't in the Sim vars list - where or how does that get mapped into moving the elevators on the aircraft?

Some clarification would help greatly!


Re: Animating aircraft model

Posted: Sat Apr 02, 2016 10:10 am
by Mark Adams
Animations don't reference variables directly - they use a piece of code.

That way you can add things like "if variable x is set to on, respond to variable y divided by two"

The properties you see when modelling refer to these little formulas.
You can take a look at them or even write your own animations (copy the original file first!)

Look in the modelling sdk, something like environment/modelling/bin and look for modeldef.xml. Open it with any text editor.

The script is in reverse Polish notation which messes with your head until you get the hang of it.

The sdk has the details - thanks to the team for that.

Re: Animating aircraft model

Posted: Sat Apr 02, 2016 4:00 pm
by ronh991
First - do you really want to use SimObject to create your project? Have you already worked with MDLs, gauges, XML and GMAX, 3DS Max or sketchup or blender to create models?

There are basically two ways to create simulated objects for P3D.

1. use GMAX, 3DS Max etc to create your model and animate it and then export as MDL file.

2. use 1 above and then create the simulation engine (dll) to make your model move, animate etc.. With all the extra XML control files etc. The dll you create uses COM, and hence is more complicated as it has to work within the P3D process space. (ie. easily crash the system)

SimObjects like the SimpleAirplane is controlled by the SimpleAirplane dll. The inputs to the SimpleAirplane come from say joystick or cursor. These events set properties see:

Code: Select all

    pSimObjectMgr->RegisterProperty(CLSID_Airplane, "Elevator",    "percent over 100", SimpleAirplane::SetElevator, EVENTTYPE_AXIS);

Then follow the "goto definition" and see how it set the values in your Simulation object and SimObject object. I don't have this thing figured out entirely, but just know that a SimObject MDL is much more complicated than just creating an "Regular " MDL.

Also know that in order to compile and run the simpleairplane you need Professional Plus (as it uses counter measures objects)

Re: Animating aircraft model

Posted: Mon Apr 04, 2016 12:28 pm
by dtudin01

Thanks - I'll take a look at the modelling sdk & that modeldef file. I wasn't sure if those things set in the sample were part of the model used with it, or references to parts in some other way or some config file I missed.


No, I don't really want to this, lol. But I was having even less luck just using the ExternalSim api... This at least it showing some progress, although it's a tougher road. I really don't need the input from P3D, since this will all be driven externally (and basically sitting in the cockpit along for the ride), so I just need it to move and animate everything as if it were all working.

Re: Animating aircraft model

Posted: Mon Apr 04, 2016 4:08 pm
by dtudin01
Hi Mark,

I've found the modeldef.xml in the SDK/Modelling SDK/bin folder.

Unfortunately, none of the variables set in the SimpleAirplane sample seem to line up with any of the definitions found within. For example, PctElevator. I know it's working, because the sample model's elevators move. I don't see it in the modeldef.xml, though.

I tried attaching another model to the SimpleAirplane.dll I built, but nothing seems to animate. When I use the SimObject property debugger windows, I can see that my elevator values are changing when I move the joystick, but nothing on the model is moving.

Any thoughts would be greatly appreciated!

Re: Animating aircraft model

Posted: Tue Apr 05, 2016 12:54 pm
by dtudin01
Any thoughts on this?

Is using the ISimObject only recommended when creating new vehicle models? If so, do these properties I set in the code need to be named in such a way that the 3d model will animate properly?

If I want to use an existing model, how can I get the parts to animate? What should I be looking for in order to properly affect the 3d model when I want to move things like control surfaces on the 3d model?

I know this works with the sample model, but I'm just not seeing how the code and the SampleAirplane 3d model are connected, whereas any other airplane model isn't.


Re: Animating aircraft model

Posted: Tue Apr 05, 2016 10:08 pm
by Mike Schroeter
Hi David,

The ISimObject API is intended to drive the object independently from both the core Prepar3D simulation and its properties/simvars. Custom properties such as PctElevator must be compiled into the visual model .MDL. As previously mentioned, the MDL is compiled with a reference to a modeldef.xml that contains script containing the properties.

The SimpleAirplane SDK sample has its own modeldef.xml, and even contains a .bat to build the MDL sample. Look in the SimpleAirplane\Source.Art folder for the visual model source files (.x and .xanim), modeldef.xml, and build script (BuildModel.bat). The build script references the XtoMdl.exe compiler which will compile the .x and .xanim into the .MDL with the modeldef.xml scripts embedded. This is how you link your simulation properties to the animations.

Take a look and let me know if you still have questions.


Re: Animating aircraft model

Posted: Wed Apr 06, 2016 7:45 pm
by dtudin01
Hi Mike,

Ok, thank you! I did not see that modeldef file in the sampleAirplane folder. This definitely helps clarify how the sample is working.

Does this same method also apply to gauges, etc inside the cockpit?


Re: Animating aircraft model

Posted: Wed Apr 06, 2016 10:33 pm
by Mike Schroeter
The custom properties can be used just about anywhere the SDK Simvar strings can be used. So yes, they can be used in gauge files or the modeldef.xml for gauges animated in an interior MDL.