[SOLVED]Problem with sphere

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:

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.

betajaen

10-03-2011 21:19:40

Quickly looking through it, you haven't set the radius of the sphere. It's 0.5m by default, I assume your sphere mesh is smaller than that?

NxOgre::SphereDescription sd;
sd.mRadius = 0.1f;

shanefarris

10-03-2011 21:41:19

Its about 6 when I set it but I took it out to see if all defaults would change anything and it didn't.

betajaen

11-03-2011 07:00:35

The rest of your code looks fine. What does it look like in the Remote or Visual Debugger?

shanefarris

11-03-2011 15:43:38

I have never been able to get to work with my code. I haven't tried 1.6 so I will try this weekend. I can tell you that the model is 500 y in the air with the rest of the models and after the first frame it is on the plane set up using physicx. It doesn't roll or bounce, it just sits there while the cube shapes fall to the ground.

betajaen

11-03-2011 15:46:32

Try just setting the mass to a positive real, and comment out the density line. I doubt it's that, but worth a try.

shanefarris

11-03-2011 16:05:15

Ok I'll mess around with the attributes some more.