kain
18-12-2007 21:10:02
Hello,
my goals were to put a spaceship into ogre, move it and detect collision with another spaceship. Well it's almost working but i have a problem with using ogreNewt force on the ship, i cannot have a smooth render:
If i put to much force on the ship, the ship is blinking, and too slow is ... well too slow
So i figure maybe i must do something wrong, here is my ship :
Here is my callback function for the ship :
Framelistener for the ship and the move methods :
Dont know why, but with this system i tried to change the way i call the force method or change the spd but it don't change the fact that my ship is not flying with a smooth render.
Regards,
Jr
my goals were to put a spaceship into ogre, move it and detect collision with another spaceship. Well it's almost working but i have a problem with using ogreNewt force on the ship, i cannot have a smooth render:
If i put to much force on the ship, the ship is blinking, and too slow is ... well too slow
So i figure maybe i must do something wrong, here is my ship :
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Box( mWorld, scale );
mNewtShip = new OgreNewt::Body( mWorld, col );
mNewtMatID = new OgreNewt::MaterialID( mWorld );
mNewtShip->setMaterialGroupID( mNewtMatID );
mNewtShip->attachToNode(mNode);
mNewtShip->setPositionOrientation( startPosition, orientation );
Ogre::Real mass = 0.01;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( mass, scale );
mNewtShip->setMassMatrix( mass, inertia);
mNewtShip->setCustomForceAndTorqueCallback( boost::bind( &Object3d::forceBodyCallback, this, _1 ) );
mNewtShip->setAutoFreeze(0);
Here is my callback function for the ship :
void Object3d::forceBodyCallback (OgreNewt::Body* me)
{
me->addForce(spd);
};
Framelistener for the ship and the move methods :
Framelistener:
if( mKeyboard->isKeyDown( KC_E ) )
{
mGameManager->mMainShip->move_f();
KeyDwn=1;
}
method:
void Object3d::move_f()
{
if (mNewtShip->getVelocity().y < 0)
spd=Vector3(0,acceleration,0)+ (-mNewtShip->getVelocity());
else
spd=Vector3(0,acceleration,0);
}
void Object3d::move_l()
{
if (mNewtShip->getVelocity().x > 0)
spd=Vector3(-acceleration,0,0)+ (-mNewtShip->getVelocity());
else
spd=Vector3(-acceleration,0,0);
}
Dont know why, but with this system i tried to change the way i call the force method or change the spd but it don't change the fact that my ship is not flying with a smooth render.
Regards,
Jr