Im having bit of problem. Im using OgreNewt for Newton 1.53. And Ogre 1.6. And i dont have time to change to newton 2.0.
When im testing my game i get random Assert AABB errors from Ogre. After few hours of investigation i foundout that the pyhisic engine in this case newton 1.53 passes this 1.#QNAN, 1.#IND, 1.#INF three "errors" to OgreNewt. What things could couse this things to happen i dont know, becouse my application was working fine before.
Here is my error info about object, before ogre graphic refresh. It happends at random positions. It happends to vehicles and other stuff too.
Moment of inertia is calculated with NewtonConvexCollisionCalculateInertialMatrix and its multiplied by mass of objects.
This missle initial velocity is 600m/s i tried to change to other velocites or mass but no luck.
- Code: Select all
....
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
Vector3(-1127.88, 356.634, -842.74)
...other objects
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
Vector3(-1129.37, 356.969, -843.85)
...Other objects
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
Vector3(-1.#IND, -1.#IND, -1.#IND)
....Other objects
!NO MISSLE_TM0xe02a7a8:21239_FIREPORT_0
Quaternion(0.311732, 0.132465, 0.939864, 0.0439494)
Vector3(1.#QNAN, 1.#QNAN, 1.#QNAN)
Here is code for building physic object.
- Code: Select all
PhysicObject::PhysicObject( OgreNewt::World* w,
std::string meshid,
bool overrideCOF,
Ogre::Vector3 offsetCenterOfMass,
Ogre::Real mass,
bool isNullCollison){
mWorld = w;
SceneNodeClass* snc = SceneNodeManager::getSingletonPtr()->GetMesh(meshid);
Ogre::SceneNode* osn = snc->getSceneNode();
std::vector<OgreNewt::Collision*> colarry;
//build sub node collisions
int c = osn->numChildren();
while(c){
Ogre::SceneNode* object = (Ogre::SceneNode*)osn->getChild(--c);
//set setscale
Ogre::Vector3 gs = object->getScale();object->setScale(osn->getScale());
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::ConvexHull(mWorld, object, Ogre::Quaternion::IDENTITY, object->getPosition()*osn->getScale());
object->setScale(gs);
colarry.push_back(col);
}
//build compound collison...
OgreNewt::Collision* cmp = new OgreNewt::CollisionPrimitives::CompoundCollision(mWorld,colarry);
//Destroy collisons
while(!colarry.empty()){
delete colarry.back();
colarry.pop_back();
}
//cast collison for inertia and center of mass calculation...
OgreNewt::ConvexCollision* cccol = (OgreNewt::ConvexCollision*)cmp;
//calculate inertia and center of mass
Ogre::Vector3 inertia; Ogre::Vector3 offsetCOF;
cccol->calculateInertialMatrix(inertia,offsetCOF);
//Create Body
bdy = new OgreNewt::Body(mWorld, cmp);
//Delete collison
delete cmp;
bdy->setMassMatrix(mass,mass * inertia);
//Set center of mass
Ogre::Vector3 off = (!overrideCOF)? offsetCOF : offsetCenterOfMass;
bdy->setCenterOfMass(off);
bdy->setPositionOrientation(osn->getPosition(), osn->getOrientation());
//Attach body to scenenode
bdy->attachToNode(osn);
//reset vars
mTorque = Ogre::Vector3::ZERO; //reset torque
mForce = Ogre::Vector3::ZERO;mTouchpoint = Ogre::Vector3::ZERO; //reset local force
mGlbForce = Ogre::Vector3::ZERO;mGlbTouchpoint = Ogre::Vector3::ZERO; //reset global force
mImpulse = Ogre::Vector3::ZERO;mImpulsePos = Ogre::Vector3::ZERO; //reset impulse
//setCustomForceAndTorqueCallback
bdy->setCustomForceAndTorqueCallback<PhysicObject>(&PhysicObject::forceCallBack, this);
}
void PhysicObject::forceCallBack(OgreNewt::Body* m_pBody){
m_pBody->addTorque(mTorque);
m_pBody->addLocalForce(mForce,mTouchpoint);
m_pBody->addGlobalForce(mGlbForce,mGlbTouchpoint);
m_pBody->addImpulse(mImpulse,mImpulsePos);
//reset vars
mTorque = Ogre::Vector3::ZERO; //reset torque
mForce = Ogre::Vector3::ZERO;mTouchpoint = Ogre::Vector3::ZERO; //reset local force
mGlbForce = Ogre::Vector3::ZERO;mGlbTouchpoint = Ogre::Vector3::ZERO; //reset global force
mImpulse = Ogre::Vector3::ZERO;mImpulsePos = Ogre::Vector3::ZERO; //reset impulse
//!GRAVITY
//!///////////////////////////////////////////////
//!Fg = m * g
Ogre::Real mass;Ogre::Vector3 inertia;
m_pBody->getMassMatrix(mass,inertia);
m_pBody->addForce(Ogre::Vector3(0,(mass*-9.803),0));
}
PhysicObject::~PhysicObject(){
delete bdy;
}
OgreNewt::Body* PhysicObject::getOgreNewtBody(){
return bdy;
}
I just dont get it...please help...im in hurry...thanyou for your help in advance.