i am trying to implement character control with bullet
i use the following code to initialise the ghost object
const Vector3 &postion = _cameraNode->GetWorldPosition();
const Quaternion &rot = _cameraNode->GetWorldRotation();
startTransform.setOrigin (ToBtVector3(postion + rot * Vector3::ZERO));
startTransform.setRotation(ToBtQuaternion(rot));
physicsWorld_->GetWorld()->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
ghostObject = new btPairCachingGhostObject();
ghostObject->setWorldTransform(startTransform);
btScalar characterHeight=1;
btScalar characterWidth =0.5;
ghostShape = new btCapsuleShape(characterWidth,characterHeight);
ghostObject->setCollisionShape (ghostShape);
ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
btScalar stepHeight = btScalar(0.35);
btVector3 up(0.0,1.0,0.0);
characterController = new btKinematicCharacterController (ghostObject,ghostShape,stepHeight, up);
but then the ghost has rotation in x-axis which i can’t understand
i update the node transform like
btTransform &worldTrans = ghostObject->getWorldTransform();
Quaternion newWorldRotation = ToQuaternion(worldTrans.getRotation());
const Vector3 &rot = newWorldRotation * Vector3::ZERO;
Vector3 newWorldPosition = ToVector3(worldTrans.getOrigin()) - rot;
_cameraNode->SetWorldPosition(newWorldPosition);
_cameraNode->SetWorldRotation(newWorldRotation);
the rotatotion matrix is
w= 0.7
x= -0.7
y=0
z=0
this what without appling transformation
and this with transformation
when i dont set UP vector to (0.0,1.0,0.0) the character fall in x-axis
i will be happy if someone can guide me what i am doing wrong.