batonrye
25-03-2006 23:32:02
For my current project, I'm implementing a hovercraft with OgreNewt, but I have a few questions...
I understand the physics pretty well, but as far as implementing things correctly with OgreNewt (callbacks, fastdelegate), I'm a bit lost (even after much reading and researching documentation)
Here as how I plan on setting things up (without knowing any better)
A Hovercraft class (pretty much laid out now) which contains the Newton body object for the chassis, any (purely cosmetic) detachable objects like fenders, wings, etc, all the ogre models and materials used, various performance variables (speed, hover height, turn...) and an array of 6-9 position vectors representing "jets" that provide the hover force.
There is an Init method for the craft that does some calculations and arranges the jets.
Now here is where I get fuzzy: I also have a hoverCallback method inside of the Hovercraft class (this goes though the jets, calculates rays, and gives the correct "hover" force on the body)
Now back up in the Init() function, i have it set the callback:
If the hovercraft "dies" i set the chassis to a normal gravitational force callback.
Here is the whole thing in pseudo code:
I guess that I'd just like to know if I'm on the right track, and maybe some pointers... thanks in advance for any help
I understand the physics pretty well, but as far as implementing things correctly with OgreNewt (callbacks, fastdelegate), I'm a bit lost (even after much reading and researching documentation)
Here as how I plan on setting things up (without knowing any better)
A Hovercraft class (pretty much laid out now) which contains the Newton body object for the chassis, any (purely cosmetic) detachable objects like fenders, wings, etc, all the ogre models and materials used, various performance variables (speed, hover height, turn...) and an array of 6-9 position vectors representing "jets" that provide the hover force.
There is an Init method for the craft that does some calculations and arranges the jets.
Now here is where I get fuzzy: I also have a hoverCallback method inside of the Hovercraft class (this goes though the jets, calculates rays, and gives the correct "hover" force on the body)
void Hovercraft::hoverCallback( OgreNewt::Body* chassis)
{
//calculations....
}
Now back up in the Init() function, i have it set the callback:
chassis->setCustomForceAndTorqueCallback( fastdelegate::MakeDelegate( this, &Hovercraft::hoverCallback) );
If the hovercraft "dies" i set the chassis to a normal gravitational force callback.
Here is the whole thing in pseudo code:
class Hovercraft
{
//Ogre geometry
OgreNewt::Body* chassis
Ogre::Vector3 nozzles[6];
Ogre::Real hoverHigh;
Ogre::Real maxSpeed;
// other data members
// ....
// ....
void HovercraftInit(size, mass, height, etc...)
{
//Calc jet thrust, jet locations
//Set Newton collision geom, attach Ogre scene node, etc.
chassis->setCustomForceAndTorqueCallback( fastdelegate::MakeDelegate( this, &Hovercraft::hoverCallback) );
}
void Hovercraft::hoverCallback( OgreNewt::Body* chassis)
{
// accumulate force and torque for each jet
//Apply net force and torque to the chassis
}
}
I guess that I'd just like to know if I'm on the right track, and maybe some pointers... thanks in advance for any help