Mononofu
23-05-2009 14:36:52
So I'm trying to create a little applicatin with OgreNewt, at first only doing normal collision checking.
I'm creating my dynamic objects like this:
Then I also create terrain from a .mesh:
Now my objects are moving as they should (falling done from gravitation) but when they hit my terrain, they just fall through it. Have I missed anything? Am I using the wrong approach?
The code for terrain loading comes from here: viewtopic.php?f=4&t=8171&p=57150
Edit: If you wonder why I pass a MeshPtr to TreeCollison(): I'm running the different parts of my engine in different threads, and since OgreNewt only uses the mesh, I pass it only the mesh to save overhead. I just overloaded the default constructor.
Edit2: Updated the overloaded constructor so it accounts for different scales. Still does not work
I'm creating my dynamic objects like this:
OgreNewt::ConvexCollisionPtr col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Cylinder(m_World, 2.5, 5));
// now we make a new rigid body based on this collision shape.
OgreNewt::Body* body = new OgreNewt::Body( m_World, col );
Ogre::Vector3 inertia, offset, dir;
col->calculateInertialMatrix(inertia, offset);
body->setMassMatrix( 10.0, 10.0*inertia );
// this is a standard callback that simply adds a gravitational force (-9.8*mass) to the body.
body->setStandardForceCallback();
body->setLinearDamping(0);
body->attachNode( node );
body->setPositionOrientation( pos, orient );
body->setContinuousCollisionMode(1);Then I also create terrain from a .mesh:
DataContainer data = ResourceManager::Instance().loadResource(specification);
OgreNewt::CollisionPtr col = boost::shared_ptr<OgreNewt::Collision>(new OgreNewt::CollisionPrimitives::TreeCollision(m_World, boost::any_cast<Ogre::MeshPtr>(data.data), true, OgreNewt::CollisionPrimitives::FW_DEFAULT, scale));
OgreNewt::Body* body = new OgreNewt::Body(m_World, col);
body->attachNode( node );
body->setPositionOrientation( pos, orient );Now my objects are moving as they should (falling done from gravitation) but when they hit my terrain, they just fall through it. Have I missed anything? Am I using the wrong approach?
The code for terrain loading comes from here: viewtopic.php?f=4&t=8171&p=57150
Edit: If you wonder why I pass a MeshPtr to TreeCollison(): I'm running the different parts of my engine in different threads, and since OgreNewt only uses the mesh, I pass it only the mesh to save overhead. I just overloaded the default constructor.
Edit2: Updated the overloaded constructor so it accounts for different scales. Still does not work