Camera Mode: Follow/Target
by Wombah · in Torque Game Engine · 06/09/2004 (1:57 am) · 9 replies
I was looking at the advancedCamera resource found here:
Advanced Camera
Great resource from the looks of it. But now the but...
I want a camera mode more suitable for a racing game, that keeps the camera on a set distance from the vehicle always looking straight at the vehicle. The camera should start out straight behind, and each update move the camera moves straight towards the vehicle's current position.
As is, I have this (semi-)working by changing the code in getCameraTransform in game/vehicle.cc, but now I'm wondering if this could/should be done in/with this resource instead, and how that would be done. Any thoughts on this?
I'm confused by the word camera being used seemingly everywhere, meaning slightly different things. What's the difference between the client's camera (the one that actually renders your view (or?) and the object's (vehicle's) camera, e g?
Advanced Camera
Great resource from the looks of it. But now the but...
I want a camera mode more suitable for a racing game, that keeps the camera on a set distance from the vehicle always looking straight at the vehicle. The camera should start out straight behind, and each update move the camera moves straight towards the vehicle's current position.
As is, I have this (semi-)working by changing the code in getCameraTransform in game/vehicle.cc, but now I'm wondering if this could/should be done in/with this resource instead, and how that would be done. Any thoughts on this?
I'm confused by the word camera being used seemingly everywhere, meaning slightly different things. What's the difference between the client's camera (the one that actually renders your view (or?) and the object's (vehicle's) camera, e g?
About the author
#2
The 3rd person camera in the starter.racing demo is uncontrollable, and is always looking at some point a bit in front of the buggy, and it doesn't keep the buggy centered on screen. I want a camera that updates itself in something like the following fasihon:
---
1. Rotate so that you are looking straight at the car, but stay in current position.
2a. If distance to car is greater than 'maxDist' allowed, move towards the car along 'viewVector', until camera is closer to car than maxDist.
2b. If distance to car is less than 'minDist' allowed, move from the car along 'viewVector', until camera is further from car than minDist.
---
This gives unsmooth motion, but that can be fixed later.
I already have a camera that works like that, but its done with uglycode(tm), and possibly in the 'wrong' place.
If this is how 3rd person view works with AdvancedCamera already, I'll just shut up and patch it in already. :)
06/09/2004 (6:17 am)
It might be that your resource fixes the 3rd person camera for me already (I have only read it, but not actually tested it), but this is what I mean:The 3rd person camera in the starter.racing demo is uncontrollable, and is always looking at some point a bit in front of the buggy, and it doesn't keep the buggy centered on screen. I want a camera that updates itself in something like the following fasihon:
---
1. Rotate so that you are looking straight at the car, but stay in current position.
2a. If distance to car is greater than 'maxDist' allowed, move towards the car along 'viewVector', until camera is closer to car than maxDist.
2b. If distance to car is less than 'minDist' allowed, move from the car along 'viewVector', until camera is further from car than minDist.
---
This gives unsmooth motion, but that can be fixed later.
I already have a camera that works like that, but its done with uglycode(tm), and possibly in the 'wrong' place.
If this is how 3rd person view works with AdvancedCamera already, I'll just shut up and patch it in already. :)
#3
The current 3rd person view does what the usual 3rd cam does too. Looks at a point (defined in the datablock) offset from the object, and rotates and moves with the object.
There is though also a 3rd person track cam, that with slight modifications would do what you seek. Add a min/max distance variable, and move camera position when desired.
If you take a peek at the code, then you see its extremely easy to add another camera mode. The code in itself is not beautiful or effecient, but it has something like
if (currentMode = 3rdPersonMode) {
do this or that
} else if (currentMode = newFantasticRacingMode) {
do this instead
}
Meaning a lot of redundant code, but very very easy to add a new mode by cut'n'pasting existing modes and modifying them.
06/09/2004 (6:35 am)
RightThe current 3rd person view does what the usual 3rd cam does too. Looks at a point (defined in the datablock) offset from the object, and rotates and moves with the object.
There is though also a 3rd person track cam, that with slight modifications would do what you seek. Add a min/max distance variable, and move camera position when desired.
If you take a peek at the code, then you see its extremely easy to add another camera mode. The code in itself is not beautiful or effecient, but it has something like
if (currentMode = 3rdPersonMode) {
do this or that
} else if (currentMode = newFantasticRacingMode) {
do this instead
}
Meaning a lot of redundant code, but very very easy to add a new mode by cut'n'pasting existing modes and modifying them.
#4
Ok, I'm rambling. Thanks for the input. I'll take a closer look on your camera resource. Feels like that will do the trick for me. Actual understanding will have to come second :)
06/09/2004 (1:57 pm)
I'll look into that. It seemed like that would be the way to go, but I get all confused by different cameras, as I said. There is a camera for each and every controllable object? But they are totally separate from the camera that torque actually renders to a viewport? If so, what do you use the camera, camera node and eye node in e.g. a vehicle for? Is there some fundamental difference between first/third person I don't see? With an advanced camera class, with the modes you want, couldn't you do all camera-related things you want?Ok, I'm rambling. Thanks for the input. I'll take a closer look on your camera resource. Feels like that will do the trick for me. Actual understanding will have to come second :)
#5
I've tried to come up with some simplified explanation for how the different camera's work in conjunction with each other so that I can wrap my already stretched brain aroud it, and I'd really like to get this confirmed or corrected.
Here goes.
Every client has a camera in their gameconnection-object. This camera handles handles all situations where the client views things without being 'physically' connected to any in-game-object such as orbitmode, mainly through the memberfunctions processTick() and getCameraTransform(). The rendering to screen asks the camera where it is, and thus what to render by calling getCameraTransform(), and the camera updates its position with each call to processTick().
As soon as the client gets a control object, wich in turn can have a control object, and so forth in a chain, you instead ask the last control object for the cameras position (again by calling getCameraTransform() not on the camera, but on the control object), and the control object handles the position of 'it's' (more or less) virtual camera in processTick(). The client's private camera in the game connection still exists, but when there are controlobjects defined, you ask them for camera poosition instead.
That's my best shot so far, and if it seems a bit confused, it probably is. Any help to get this straightened out would be appreciated.
06/10/2004 (3:16 am)
Ok, I can't let this go just yet... :/I've tried to come up with some simplified explanation for how the different camera's work in conjunction with each other so that I can wrap my already stretched brain aroud it, and I'd really like to get this confirmed or corrected.
Here goes.
Every client has a camera in their gameconnection-object. This camera handles handles all situations where the client views things without being 'physically' connected to any in-game-object such as orbitmode, mainly through the memberfunctions processTick() and getCameraTransform(). The rendering to screen asks the camera where it is, and thus what to render by calling getCameraTransform(), and the camera updates its position with each call to processTick().
As soon as the client gets a control object, wich in turn can have a control object, and so forth in a chain, you instead ask the last control object for the cameras position (again by calling getCameraTransform() not on the camera, but on the control object), and the control object handles the position of 'it's' (more or less) virtual camera in processTick(). The client's private camera in the game connection still exists, but when there are controlobjects defined, you ask them for camera poosition instead.
That's my best shot so far, and if it seems a bit confused, it probably is. Any help to get this straightened out would be appreciated.
#6
06/10/2004 (8:14 am)
That's about right. No major holes, though I'm sure after you've messed with the system a bit you'll get a more refined view of it.
#7
06/15/2004 (3:47 pm)
Can you have several eyenodes in a model, and cycle through them in script somehow? I'm looking for the standard racing game first person camera effect, where the camera can be mounted either on the hood of the car, the roof of the car or in the car.
#8
If you got the sources you can naturally extend that to whatever you need.
06/15/2004 (11:33 pm)
You can (AFAIK) only have the 2 specified in plain vanilla TGE. Eye and cam. If you got the sources you can naturally extend that to whatever you need.
#9
The camera direction seem to be parallel with the terrain.
I want it a little bit look down to the terrain to increase speed visual effect.
I know that I have to adjust the pitch angle of the camera.
But after messing it, I still dont sure where the code is.
I think there are too much thing that was hard coded in C++ code.
So it's a real difficulty to modify any little thing.
Please give me some guide!!!
Thanks
10/27/2005 (2:55 am)
So in the 3rd persion mode in racing demo, The camera direction seem to be parallel with the terrain.
I want it a little bit look down to the terrain to increase speed visual effect.
I know that I have to adjust the pitch angle of the camera.
But after messing it, I still dont sure where the code is.
I think there are too much thing that was hard coded in C++ code.
So it's a real difficulty to modify any little thing.
Please give me some guide!!!
Thanks
Torque Owner Thomas \"Man of Ice\" Lund
Please try to explain to me in more details what you would like your camera mode to do, and I might be able to help you (I wrote that resource).
First off from your explaination I cant see the difference between what you describe and the existing 3rd person mode.