Game Development Community

Dynamic Third-Person Camera (Part 1)

by Justin Mette · in Torque Game Engine · 08/28/2001 (6:12 pm) · 14 replies

One of the first features that the 21-6 Productions development team has started implementing for their first V12-based game, called Myrmidon, is a dynamic third-person camera that can be controlled at the same time as the player. This is the first tutorial in a series dealing with enhancing the existing third-person camera in the V12 Engine.

I have uploaded the tutorial to Owen Ashcroft's V12 Document Repository site. Check it out!

#1
08/28/2001 (7:19 pm)
Very nice!

I was wondering if this could be done :)
#2
08/28/2001 (7:33 pm)
Compiling...
shapeBase.cc
F:\GarageGames\v12\engine\game\shapeBase.cc(1752) : error C2018: unknown character '0xa2'
F:\GarageGames\v12\engine\game\shapeBase.cc(1752) : error C2065: 'erPos' : undeclared identifier
F:\GarageGames\v12\engine\game\shapeBase.cc(1755) : error C2018: unknown character '0xa2'
Error executing cl.exe.

Got that, following the tut, and cutting and pasting code.

The lines in question seems to be:
getRenderTransform().mulP(osp,
#3
08/28/2001 (7:42 pm)
By the way, thanks for taking the time, the tut was VERY well written :) I enjoyed reading it, could follow what you were doing and with the exception of these errors, "got" most of it :)
#4
08/28/2001 (8:51 pm)
Thank you for the feedback on the tutorial. It was harder to write than I thought and I was quite nervous about posting it.

I went to line 1752 and 1755 in ShapeBase.cc (modified version created by the tutorial) which are causing you problems. Those two lines are the same ones you mention in the first part of your message:

getRenderTransform().mulP(osp, & centerPos);

and

getRenderTransform().getColumn(3, & centerPos);

Make sure those two lines in the source look just like they are presented in the tutorial. There is definately a problem copy/pasting the "& centerPos" variable. I am going to change the variable name in the tutorial code snippet to avoid this problem in the future.

Please let me know if you continue to see any more problems. You can email me directly for faster responses at justin.mette@21-6.com.

Edit: Even these forums convert "& centerPos" (no spaces) to "
#5
08/29/2001 (7:36 am)
I was gonna ask if the spaces were intentional :)

I got it to compile without errors finally.

Between that typo, and me missing the "rebuild all step" that cleared up the problems :)
#6
08/29/2001 (10:19 am)
The only thing I would recommend is not using the getRealMillisecond function, but the dt (delta time) variable already there. By using the getRealMill function, your function will not playback correctly from a journal or demo. Nice tutorial though :)
#7
08/29/2001 (3:54 pm)
I actually started with the 'dt' parameter but quickly realized that it is always either 0.0 or 0.032. After digging around a little, the 0.032 seems to be hard-coded in game.cc at line 658 (which is the only place that getControlCameraTransform is called with a time delta):

if (connection && connection->getControlCameraTransform(0.032f, &query->cameraMatrix))

I meant to ask you guys about this, but forgot. I am glad you brought it up. I am not comfortable using the
getRealMillisecond() function because I figured the main game loop in the engine had to already be tracking this. Understanding that there are other drawbacks, I am really interested in fixing this. However, from the GameConnection class, I could see no other way of getting a real time delta between successive calls to the getControlCameraTransform() method.

Am I misunderstanding what the dt parameter is supposed to be used for? Did the timing code get removed during the process of ripping out T2 stuff?

Thanks for the help and the positive comments about the tutorial.
#8
08/29/2001 (5:01 pm)
Very Very nice... Very well written tutorial... This is definatly a nice upgrade to the engine...

Well done!
#9
08/29/2001 (6:58 pm)
The time thing get's a little complicated... in general though all the game objects run at a fixed time increment, the 0.032 ms. you mentioned, and the clients interpolate frames that fall between "ticks". The Simulation overview covers it a little.

The only interpolation done in the GameConnection is the camera first/third person zoom, which looking at that code will not be smooth. Works ok for the "zoom", but not something you want for general camera motion. The reason the camera is normally smooth is that it's position is obtained from the interpolated client object. GameConnection isn't aware of this interplation.

There is another time function you may be able to use that does play back correctly (can't remember what it's called though), or you can change the code to pass down the "real" event driven time, or you can push your calculations down into an object and have it do it's normal client side interpolation.
#10
08/29/2001 (8:10 pm)
Ah yes, my eyes are starting to focus...

Tim, this is great stuff and the new docs have really started to clear things up for me in relation to the network architecture and simulation algorithms.

You know, I started off adding the camera variables and functionality to the ShapeBase class but was having difficulty getting updates for the new variables out to the ghost objects - or something like that. Anyway, I am going to see if I can improve on my implementation now that I am armed with this updated information. Does the phrase "know enough to be dangerous" come to mind for anyone else working on this?

Tim, I am honored to be taking up your valuable time :)

Joking aside - thanks for your insight (not to mention the engine).
#11
08/29/2001 (8:31 pm)
Hell I'm just dangerous.

One of these days I'll learn C++... until then I use the "Hey that function looks almost like what I want." {snip Snip} {Paste Past}
#12
08/29/2001 (8:51 pm)
I'm just glad you guys are having fun with this. There's certainly a lot of code to go through and it's not always obvious what's going on :)
#13
08/31/2001 (3:07 pm)
Ok, where is the default, starting 3rd person camera set?

I see the "reset view" in the script, but I am guessing that it's somewhere else :(

-edit-

Never mind, I read right over it.

IMPLEMENT_CONOBJECT(GameConnection);
bool GameConnection::mFirstPerson = true;
F32 GameConnection::mCameraPitch = -0.2;
F32 GameConnection::mCameraYaw = M_PI;
F32 GameConnection::mCameraZoom = 4;


in gameconnection.cc

:)
#14
09/02/2001 (4:36 pm)
Yet another question.

Where can I set the reticle (from the weapon example) to not be visible on fistspawn?