Moving eye node.
by N · in Torque Game Engine · 03/23/2008 (5:29 pm) · 6 replies
I recently implemented the Adding new positions and moves; ie swim, crouch, crawl, prone resource, but have one problem.
When you crouch or go prone, the eye positions stays normal. In 3rd person, it works great, but in 1st, the camera stays at the original place. I've tried moving the eye node in my animation, but that did nothing.
How do I transform the location of the eye in code?
I'm looking to do something like:
if( mPlayerPosition == 1 )
{
eyeLocation = 0 0 -1.5;
}
What would I use to change eye location?
Or, is there a way to make the eye location follow the eye node in the animation?
Thanks,
Niko Loeffelholz
When you crouch or go prone, the eye positions stays normal. In 3rd person, it works great, but in 1st, the camera stays at the original place. I've tried moving the eye node in my animation, but that did nothing.
How do I transform the location of the eye in code?
I'm looking to do something like:
if( mPlayerPosition == 1 )
{
eyeLocation = 0 0 -1.5;
}
What would I use to change eye location?
Or, is there a way to make the eye location follow the eye node in the animation?
Thanks,
Niko Loeffelholz
About the author
#2
I found this in player.cc
Would I modify something in here?
03/23/2008 (6:12 pm)
I just looked through the comments again, and I couldn't find any solution.I found this in player.cc
void Player::getEyeTransform(MatrixF* mat)
{
// Eye transform in world space. We only use the eye position
// from the animation and supply our own rotation.
MatrixF pmat,xmat,zmat;
xmat.set(EulerF(mHead.x, 0.0f, 0.0f));
zmat.set(EulerF(0.0f, 0.0f, mHead.z));
pmat.mul(zmat,xmat);
F32 *dp = pmat;
F32* sp;
if (mDataBlock->eyeNode != -1)
{
sp = mShapeInstance->mNodeTransforms[mDataBlock->eyeNode];
}
else
{
Point3F center;
mObjBox.getCenter(¢er);
MatrixF eyeMat(true);
eyeMat.setPosition(center);
sp = eyeMat;
}
const Point3F& scale = getScale();
dp[3] = sp[3] * scale.x;
dp[7] = sp[7] * scale.y;
dp[11] = sp[11] * scale.z;
mat->mul(getTransform(),pmat);
}Would I modify something in here?
#3
04/01/2008 (2:07 pm)
I tried doing this, but it changed nothing.const Point3F& scale = getScale();
dp[3] = sp[3] * scale.x;
if (getPlayerPosition() == 1)
{
dp[7] = sp[7] * scale.y;
}
if (getPlayerPosition() == 2)
{
dp[7] = sp[7] * scale.y - 3;
}
if (getPlayerPosition() == 3)
{
dp[7] = sp[7] * scale.y - 5;
}
dp[11] = sp[11] * scale.z;
mat->mul(getTransform(),pmat);
#4
04/01/2008 (3:54 pm)
It looks like the issue with the movement of the eye node was brought up in the comments, but no solution was posted.
#5
04/02/2008 (3:32 pm)
So, any idea on how to move the eye?
#6
04/04/2008 (12:08 pm)
I actually connected my eye node to the head itself in my models. This means the field of view moves slightly as the model breathes - which I find realistic and appealing. It also means the view bobs a bit when running which I find cool. This might not appeal to everyone - AND there might be some problems with this I've not yet experienced. But it is one option...
Torque Owner Chris Byars
Ion Productions