I have a .dll converted by the SC3converter. I can open the Goose.cpp and Goose.h files in the compiler. I can make sense of a some things, but others seem very strange. How would I make it so, when I press the retro thust keypad "-", it activates the reverse thruster animation, and closes it when released ?
I would rather link this to another key (toggle thruster reversers) and then implement the action like that:
First of all, you implement the keyhandler in clbkConsumeBufferedKey. My personal preference is to only analyse what Orbiter tells you there and then implement the actual action for that key in a new function ("void toggleReserveThrust()"). This way you can find the right place in your source code much faster in Visual Studio.
For handling the animation, I would use the AnimState class that Orbiter already provides. So, you need to add an attribute to your vessel like
Code:
AnimState thrustReserver;
Like every attribute, you should initialize it in the constructor of the vessel. The constructor is a function with the same name as the vessel class name and has the special duty to help creating your vessel. This initialization is a simple statement in the constructor body:
Code:
thrustReverser.Set(AnimState::CLOSED, 0.0);
Now, if you want to toggle the animation in your action function (toggleThrustReverser), you need to toggle the action state of this thrustReverser attribute:
Code:
if (thrustReverser.Closed() || thrustReverser.Closing())
thrustReverser.action = AnimState::OPENING;
else
thrustReverser.action = AnimState::CLOSING;
Now, it would be fun if this would be all about it, right? Still, there is one task needed: Giving the animation time to move and moving the animation visibly. This is done either in clbkPreStep and clbkPostStep. I personally prefer clbkPostStep for the animations, but that is just for keeping clbkPreStep smaller. There, you have to add a line to give the animation some time:
Code:
if (thrustReverser.Moving()) {
thrustReverser.Move(0.1 * fDeltaT);
SetAnimation(animThrustReverser, thrustReverser.pos);
}
animThrustReverser is the animation handle of the thrust reverser Animation. I am not knowing how the SC3 converter defines it.
Now you have the animation in your spacecraft starting with the keypress... now the hard work: How to implement a thrust reverser in Orbiter?
In deep dark theory, a thrust reverser like that splits the exhaust stream and directs some or all of it forward. The thrust of the thrust reverser depends on the thrust level of the thruster that powers it. So, you define one new thruster for each reverse of the engine, but give it zero thrust, and connect it to the same propellant resource as the main engines, even add it to the same thruster group (main) as the main engine (so a throttle controller has proper effect on it).
Lets say, you want to blend the thrust from full forward to full reverse. Then you have a function:
effectiveMaximumThrustMain = (1-thrustReverser.pos) * MaximumThrustMain
effectiveMaximumThrustReverse = thrustReverser.pos * MaximumThrustReverse
That is something you can also tell Orbiter via "SetThrusterMax0()". And you can still implement something like a airbreathing engine simulation in front of it, calculating what maximumThrustMain, etc actually is. But thats something much more advanced than that.