Animating aircraft model

For topics related to the creation of simulation objects (SimObjects). This includes development of aircraft, ground, and maritime vehicles.
Locked
dtudin01
Posts: 48
Joined: Wed Jul 04, 2012 6:26 pm

Animating aircraft model

Post by dtudin01 »

Hi,

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!

Thanks,
david
User avatar
Mark Adams
Posts: 63
Joined: Thu Dec 18, 2014 2:12 pm

Re: Animating aircraft model

Post 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.
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Animating aircraft model

Post 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)
Ron
dtudin01
Posts: 48
Joined: Wed Jul 04, 2012 6:26 pm

Re: Animating aircraft model

Post by dtudin01 »

Mark:

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.


Ron:

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.
dtudin01
Posts: 48
Joined: Wed Jul 04, 2012 6:26 pm

Re: Animating aircraft model

Post 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!
dtudin01
Posts: 48
Joined: Wed Jul 04, 2012 6:26 pm

Re: Animating aircraft model

Post 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.

Thanks!
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: Animating aircraft model

Post 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.

Thanks,
Mike
dtudin01
Posts: 48
Joined: Wed Jul 04, 2012 6:26 pm

Re: Animating aircraft model

Post 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?

Thanks,
david
Mike Schroeter
Lockheed Martin
Posts: 341
Joined: Thu Jan 12, 2012 7:05 pm

Re: Animating aircraft model

Post 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.

Mike
Locked