Game Development Community

dev|Pro Game Development Curriculum

3rd person camera implemenation borks animation playback

by Ben Mathis · 07/25/2007 (7:17 am) · 7 comments

Tried to create an external 3rd person sideways camera. Had lots of problems with using the camera object (as well as the AdvancedCamera resource, it does not work) as it seems that the camera object is only used when it is set as the control object (useful??). As a solution to that I tried to change the getRenderEyeTransform function that is used to render the scene by creating another function called getRenderCameraTransform and use that one instead of getRenderEyeTransform in ShapeBase::getCameraTransform and modify the rotation and location of the render caption. Setting the character up as the control object seems to mess up the animation sequence of our character. When the Camera is set as a control object instead of the character, our character's animation runs correctly, when our character (with the changed render function) is the control object, the animation gets scewed. Here's what I did in getRenderCameraTransform (red text is code I changed):

void Player::getRenderCameraTransform( MatrixF* mat )
{
   MatrixF pmat,xmat,zmat;
   xmat.set(EulerF(mHead.x, 0.0f, 0.0f));
   zmat.set(EulerF(0.0f, 0.0f, mHead.z-1.5));
   pmat.mul(zmat,xmat);

   F32 *dp = pmat;
   F32* sp;
   if( mDataBlock->cameraNode != -1 )
   {
      sp = mShapeInstance->mNodeTransforms[mDataBlock->cameraNode];
   }
   else
   {
      Point3F center;
      mObjBox.getCenter(&center);
      MatrixF eyeMat(true);
      eyeMat.setPosition(center);

      sp = eyeMat;
   }

   const Point3F& scale = getScale();
   dp[3] = sp[3] * scale.x+7;
   dp[7] = sp[7] * scale.y+1;
   dp[11] = sp[11] * scale.z;
   mat->mul(getRenderTransform(), pmat);
}
Even only changing the y offset (to see the character from behind) shows that the animation is crooked, but only when the character is the control object.

Here is an image of the problem. See how the feet seem to detach? In Showtools, this place perfectly (ankles stay connected and she seems to just be breathing heavily)

www.poopinmymouth.com/net/escapade/bug_01.gif

#1
07/25/2007 (8:45 am)
Ben,

1. Not a plan (blog). OK, pseudo. You are telling us what your working on, but this is really a request for help. We see a lot of requests for help disguised as blogs and folks are kinda getting tired of it since it pushes real blogs off the top 10 (new blogs) list.

2. You shouldn't post source code in the public areas, including plans.

A better spot for this, and likely to get more help is:

http://www.garagegames.com/mg/forums/result.area.php?qa=10

-Ed

PS - When you repost, you might show the original code followed by the new code. Highlighting in a code block doesn't seem to work.

PPS - Nice site BTW http://www.poopinmymouth.com

PPS - Anyone thinking about this problem, it looks like the code Ben started from is present in 1_52. Ben, can you confirm that for us? It probably won't make much of a difference, but it is nice to look at the same code base.

-EFM
#2
07/25/2007 (9:06 am)
Hey Ben, nice seeing you around here, I'm a big fan of your work!

Ed Maurina is correct though, many in the community simply won't help someone who hasn't gone through "the proper channels", namely the forums. Asking for help in blog posts on the front page is seen as getting on a pedastal screaming "HEEELP MEEEE" and many simply ignore it... even if you are the mighty Ben Mathis!
#3
07/25/2007 (9:11 am)
Actually I was told by a more experienced forum member that the blog posts were what actually got people to post. I tried with several problems posting in the "proper channel" and received little or no response, so I figured I'd try here. If it's not kosher, I'll refrain, my apologies.

It is indeed 1.52 code.

Thanks Ed/Ed for the compliments about my site.
#4
07/25/2007 (9:12 am)
Looks like I should read more carefully. Ben already tried AdvancedCamera. I'm leaving my post here intact and will move over to the private forum to help

Ben,

Yeah, enough with the post scripts....

It occured to me that you might benefit from trying out this resource: Advanced Camera.

It is a smokin' resource which works well in 1_52. In fact, after adding the files in the zip file, you're pretty much done (except for script changes). All of the other code 'fixes' have been incorporated in 1_52.

If you need a side view use the: setTrackMode(). You can then adjust the camera position with: setCameraPosition() and the camera will nicely track your player, while itself remaining stationary.

Alternatively, if you need the camera to track the player from the side and to follow the player use:
setThirdPersonMode(), but don't attach the yaw, pitch, zoom scripts. Instead, adjust them using: setThirdPersonOffset().


-Ed M
#5
07/25/2007 (9:15 am)
Here's a link to Ben's new thread in the private forums . . .

www.garagegames.com/mg/forums/result.thread.php?qt=65188
#6
07/25/2007 (10:48 am)
Ben Mathis,

I posted a message on the new thread about this.

Anton Bursch
#7
07/25/2007 (1:01 pm)
Anton,

Your post on the other thread just disappeared? Did you delete it?

-Ed