Character controller Implemantation

supermael

04-10-2010 16:27:27

Hello ! I'm trying to implemante a Character controller, I'm not using the wrapper, I use directly PhysX. But i've some problems, my Critter::Body or NxOgre::Actor are not detected in the callback, just my scenegeometry. Then here is how I proceed :

Create a body :

NxOgre::ConvexDescription description(scaledMesh);
Critter::BodyDescription bodyDescription;
bodyDescription.mMass = mass;
bodyDescription.mGroup = GROUP_COLLIDABLE_PUSHABLE;
bodyDescription.mAngularDamping=0.5;

NxOgre::Matrix44 mat = nxTransformMatrix(pos, rot, Ogre::Vector3(1,1,1));

Critter::Body* body = mpv_PhysicMngr->getPhysicRenderSystem()->createBody(description, mat, fl + ".mesh", bodyDescription);


Create the CC :

NxCapsuleControllerDesc desc;
desc.setToDefault();
desc.skinWidth = 0.1f;
desc.radius = 1;
desc.height = 3;
mpt_OffsetY = desc.height/2 + desc.radius;
desc.upDirection = NX_Y;
desc.slopeLimit = 0.7;
desc.stepOffset = 0.5;
desc.position.y = 50;
desc.position.x = 0;
desc.position.z = 0;
desc.climbingMode = CLIMB_CONSTRAINED;
//desc.interactionFlag = NXIF_INTERACTION_USE_FILTER;
desc.callback = &mpt_Callback;

mpt_Controller = manager->createController(mpt_PhysicScene->getScene(), desc);
mpt_Controller->setCollision(true);


To move the character :

mpt_Controller->move(dir, COLLIDABLE_MASK, 0.000001, flag, 1.0);
if(flag == NXCC_COLLISION_DOWN)
mpv_Jump.stopJump();



The physic update :


mpv_PhysicWorld->advance(timeSinceLastFrame);
mpv_Manager->updateControllers();


And then, the callback :
class CCCallback : public NxUserControllerHitReport
{
virtual NxControllerAction onShapeHit(const NxControllerShapeHit& hit)
{
GameFramework::getSingletonPtr()->mp_Log->logMessage(hit.shape->getActor().getName());
return NX_ACTION_PUSH;
}
virtual NxControllerAction onControllerHit(const NxControllersHit& hit)
{
GameFramework::getSingletonPtr()->mp_Log->logMessage(hit.controller->getActor()->getName());
return NX_ACTION_PUSH;
}
};


As you see, at the moment I just want to log the name of the shape who is in the callback, and my Critter::Body or Critter::Actor never appear...

Do you have any idea to help me ?

Thank you in advance !
And sorry for my bad english...

supermael

08-10-2010 21:13:24

No idea ?