Game Development Community

Player Roll (Y rotation)?

by Mike Treanor · in Technical Issues · 02/28/2008 (4:55 pm) · 1 replies

Hi,

I'm trying to allow to player to be able to 'roll' their point of view (perform a y axis rotation).

By the looks of it, the "GameConnection::getNextMove(Move &curMove)" function is reading values for roll from the globals $mvRollLeftSpeed, etc. By looking at the "Do the twist" resource (http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6713) it seems like I can ust do the following to make roll work:

In player.cc in the Player::updateMove function I add this:
F32 r = move->roll; //move->roll seems to already be set by getNextMove in GameConnection
if (r > M_PI) r -= M_2PI;
mHead.y = mClampF(mHead.y + r,-mDataBlock->maxFreelookAngle,mDataBlock->maxFreelookAngle); //arbitraily bound mHead.y by maxFreeLookAngle

Then in player.cc in the Player::getMuzzleTransform function I do this:
if (mActionAnimation.action < PlayerData::NumTableActionAnims)
{
MatrixF pmat,xmat,ymat,zmat;
xmat.set(EulerF(mHead.x, 0, 0));
ymat.set(EulerF(0,mHead.y, 0));
zmat.set(EulerF(0, 0, mHead.z));
pmat.mul(zmat,xmat); //apply the z and x rotations
pmat.mul(pmat,ymat); //apply the y rotation

mat->mul(getTransform(), pmat);

...
}

First off, is it OK that I posted this amount of source code in the public forums?

Second, and more on topic, this doesn't seem to work. If there somewhere that the mHead.y info is being clobbered or not being set/sent?

Thanks

#1
02/29/2008 (6:43 am)
Not sure why you're posting it on the public forums versus the private anyway, though...Especially since most of the public forum members won't be as associated with the source code specifics of player.cc.

I wish I could help, but I haven't tried anything even remotely similar.