shanefarris
10-03-2011 20:47:29
I am updating to 1.6 and replacing the way we created shapes with the new shape description method. I can't use critter because I need to have control of the meshes being loaded so with 1.5 I created my own body type class and was able to get cubes, and spheres working fine with paged terrain, but now I am having problems with the spheres.
The sphere that I have when I run the simulation will have the shape along with the mesh go directly to the physics plane that I am using to test on, while the cubes will fall like expected. I don't think the sphere even falls, because in one frame it is already touching the plane even though it starts at the same height as the cubes.
Here is what I am doing to create the sphere:
Here is the constructor of the "Body" class:
Here is my update method: (it iterates through the list and calls "advance")
Any idea what I am missing here?
Thanks.
Edit:
I have both density and mass, I know stupid, but just making a note just in case someone ran into the same problem as me.
The sphere that I have when I run the simulation will have the shape along with the mesh go directly to the physics plane that I am using to test on, while the cubes will fall like expected. I don't think the sphere even falls, because in one frame it is already touching the plane even though it starts at the same height as the cubes.
Here is what I am doing to create the sphere:
reVector3Df pos = GameObject->Node->getPosition();
f32 radius = GetBoundingRadius(GameObject->Entity);
NxOgre::RigidBodyDescription desc;
desc.mMass = bodyMass;
desc.mDensity = 1.0f;
NxOgre::SphereDescription sd;
// Create the body using again the NxOgre_New macro. Passing on the prototype we just created and a copy
// of the scene pointer. we are using.
CPhysicsStrategy_PhysX::Body* body = new CPhysicsStrategy_PhysX::Body(sd, NxOgre::Matrix44::IDENTITY, desc, m_Scene, GameObject->Node);
m_Bodies.push_back(body);
return m_Bodies.size() - 1;
Here is the constructor of the "Body" class:
CPhysicsStrategy_PhysX::Body::Body(const NxOgre::ShapeDescription& shape,
const NxOgre::Matrix44& orien,
const NxOgre::RigidBodyDescription& desc,
NxOgre::Scene* Scene, SceneNode* Node)
: Actor(Scene),
m_Node(Node)
{
// Create a dynamic RigidBody with the pose, description and shape.
// We can pass on the BodyDescription as a RigidBodyDescription because it inherits from it,
createDynamic(orien, desc, shape);
// And let the time controller, that this is a timelistener that needs to be listened.
Scene->addRenderListener(this, NxOgre::Enums::Priority_Medium);
}
Here is my update method: (it iterates through the list and calls "advance")
bool CPhysicsStrategy_PhysX::Body::advance(f32 deltaTime, const NxOgre::Enums::Priority& Priority, const NxOgre::Enums::SceneFunction& Functions)
{
m_Node->setPosition(NxOgre::Vec3(getGlobalPose()).as<Vector3>());
m_Node->setOrientation(NxOgre::Quat(getGlobalPose()).as<Quaternion>());
return true;
}
Any idea what I am missing here?
Thanks.
Edit:
I have both density and mass, I know stupid, but just making a note just in case someone ran into the same problem as me.