Here's a video of the problem: http://youtu.be/fTU5vtNneRo complete with my character model from Blender Noob to Pro, haha
Because my game will have a lot of objects, some of which will have irrlicht scene nodes and some of which won't, I've decided to make every object pretty much an interface between irrlicht and bullet. Every object that renders on screen has an irrlicht scene node and a bullet collision object. They all derive from an IActor interface, and my game class has a container of IActors. Every game loop, my game iterates through the container and calls the act() method, which sets the node to the position of the collision object. Here's the player's act method:
Code: Select all
int Player::act()
{
if(action_id !=P_SLEEP)
{
keyControl();//WASD calls btkinematiccharactercontroller::setWalkDirection
mouseControl();//rotates camera based on mouse movement
update();//repositions camera
}//if it isn't sleeping
return action_id;//part of FSM
}
Code: Select all
cd_Physics.World->stepSimulation((clock()-TimeStamp)*.001f,6);//steps the physics world
stepActors();//iterates through actors and calls act() for each one
cd_Engine.smgr->drawAll();//this is just for testing, actually using xeffects. same jitter occurs in either one
TimeStamp = clock();
cd_Physics.World->debugDrawWorld();
Code: Select all
void Player::mouseControl()
{
double sensitivity = 70;
vector3df rotation = playCamera->getRotation();
vector3df horizontal = rotation.getHorizontalAngle();
ICursorControl* cursorControl = cd_Engine.device->getCursorControl();
vector2df cursorPos = cursorControl->getRelativePosition();
rotation.X += (cursorPos.Y-.5)*sensitivity;
rotation.Y +=(cursorPos.X-.5)*sensitivity;
if(rotation.Y>360)
rotation.Y = rotation.Y-360;
if(rotation.Y<-360)
rotation.Y = rotation.Y+360;
if(rotation.X >85)
rotation.X = 85;
if(rotation.X <-85)
rotation.X = -85;
rotation.Z =0;
if(cursorPos.X!=.5 &&cursorPos.Y != .5)
printf("Camera Rotation: %f %f %f\n",rotation.X, rotation.Y, rotation.Z);
playCamera->setRotation(rotation);
cursorControl->setPosition(.5f,.5f);
}//end of mousecontrol
Code: Select all
void Player::keyControl()
{
playCamera->updateAbsolutePosition();
vector3df walkDir = playCamera->getTarget()-playCamera->getAbsolutePosition();
double rotation=0;
bool move = false;
if(cd_Engine.receiver->keyDown('W'))
{
move = true;
rotation = 0;
}
else if(cd_Engine.receiver->keyDown('S'))
{
move = true;
rotation = 180;
}
if(cd_Engine.receiver->keyDown('A'))
{
rotation = 90;
move = true;
}
else if(cd_Engine.receiver->keyDown('D'))
{
rotation = -90;
move = true;
}
walkDir.rotateXZBy(rotation);
setWalkDirection(btVector3(walkDir.X,0,walkDir.Z)*(move?1.0:0.0));
}