Physics Simulation Forum


All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sat Feb 18, 2012 1:54 am 

Joined: Sat Feb 18, 2012 1:42 am
Posts: 1
I'm trying to use the btKinematicCharacterController, I may end up implementing my own, but I'll probably look to that for some example code, though. The specific issue I'm having, though, is that the sweep test is not detecting the ground. I'm not rendering anything alongside the body, but I've got it to where it prints out the y coordinate of the ghostObject's position every tic. I intentionally put it obnoxiously high for a start point, but it ends up not detecting the ground and passing though it. I also put it a line of code in the btKinematicCharacterController to alert me whenever the sweep test detects a hit, though it never does. The ground object is a rigid body that otherwise works fine, it interacts with some weapons that I added physics to just fine. I'm using the irrlicht engine, and both the ground and the player objects are derived from the scenenode class there. My code is heavily encapsulated, but I'll try to get the function calls in order:

//this is the ground setup
 void CRealObject::setupPhysics()
    cout<<"setting up physics"<<endl;
   delete collObj;
   collObj = 0;
   matrix4 transform = getAbsoluteTransformation();
   vector3df rot = transform.getRotationDegrees();
   btVector3 trans = btVector3(getAbsolutePosition().X,getAbsolutePosition().Y,getAbsolutePosition().Z);
   btQuaternion quat = myGame->EulerXYZtoQuat(rot);
   btVector3 EulerRotation;
//this function works, i've tested it
   myGame->QuaternionToEuler(quat, EulerRotation);//mygame just contains all of my "global" attributes, including the dynamicsworld and others.
   vector3df rotation = vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2]);
   btTransform bulletTransform(quat,trans);
   // Give it a default MotionState
   btDefaultMotionState *MotionState = new btDefaultMotionState(bulletTransform);
   // Create the shape
   aabbox3df box = getMesh()->getBoundingBox();
   btVector3 HalfExtents( getScale().X*(box.MaxEdge.X - box.MinEdge.X), getScale().Y*(box.MaxEdge.Y - box.MinEdge.Y),  getScale().Z*(box.MaxEdge.Z - box.MinEdge.Z));
   btCollisionShape *Shape = new btBoxShape(HalfExtents*.5f);
   // Add mass
   btVector3 LocalInertia;
   Shape->calculateLocalInertia(mass, LocalInertia);
   collObj = new btRigidBody(mass, MotionState, Shape, LocalInertia);
   // Store a pointer to the irrlicht node so we can update it later
   collObj->setUserPointer((void *)this);
   // Add it to the world
   kinematic = false;
//this is the character controller
void CPlayerObject::setupPhysics()
    btCollisionShape* shape = new btCapsuleShape(.1f,2.f);
   body= new btPairCachingGhostObject();
   controller = new btKinematicCharacterController(body,(btConvexShape*)shape, .25f,1);
 }//end of setupPhysics

I'll post more if necessary, but I could really use some help. I'm wondering if I'm missing a function call or something.
Edit: a raytest works, why wouldn't a sweep test?
Edit 2: Ok, so all I had to do was make the ground a static object and the collision detected. It still doesn't stop falling, however. Why would this be?

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 13 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group