how to create smooth (3D) cameras for games

A528d11e2590c45b74a53dadde386125
0
Xcrypt 101 Dec 30, 2011 at 01:48

Does anyone know any nice articles/books/tutorials on how to create different types of cameras? (follow cameras, third person cameras, first person cameras, cinematic cameras, etc)

I’m trying to implement some third person follow camera but it looks rather jittery and crappy. Thanks :)

2 Replies

Please log in or register to post a reply.

0623b0537ebe73e6e0f95ca420fdfd9d
0
SergeyK 101 Jan 02, 2012 at 10:08

Take a look at the source of Linderdaum Engine
There is a GameCamera.h file where you will find the low-level camera implementation. In CameraPositioner.h there are some behaviors for what you are looking for (3rd person, trajectory, etc).

A528d11e2590c45b74a53dadde386125
0
Xcrypt 101 Jan 04, 2012 at 22:36

Well, I have a problem, I’d appreciate it if anyone could help. I’m not really a huge transformation guru, especially in 3D, especially when it concerns rotations.

I’ve been busy working on a 3D shooter game, and I’ve now managed to implement a decent 1st and 3rd person camera, but now the next problem: I have to update the movement of the player according to the camera…

I realised that, if I could find the ‘2D’ angle between the front/look vector of the camera,
and (0,0,1) in a default coordinate system, I could have a predefined set of direction vectors.
Then I could rotate that vector with the angle between the camera’s look vector and the front vector, to get the result directions I want. But I’m not sure how to do this entirely.

Here’s some pseudo-code, since we tend to understand that better than words anyway:

vec3 direction(0.0f,0.0f,0.0f);

if(keydown(up)) direction += (0.0f,0.0f,1.0f);
if(keydown(down)) direction += (0.0f,0.0f,-1.0f);
if(keydown(left)) direction += (-1.0f,0.0f,0.0f);
if(keydown(right)) direction += (1.0f,0.0f,0.0f);

direction.normalize(); //the predefined direction vector

vec3 lookW = camera->GetLook();
vec3 Front(0.0f,0.0f,1.0f);
vec3 Up(0.0f,1.0f,0.0f);

float angle = GetClockWiseAngleAlongAxis(/*axis*/Up, /*vec 1*/lookW, /*vec 2*/Front);

direction.rotateAlongAxis(/*axis*/Up, /*radians*/angle);

This would give me the result I want. But I’m not sure
how to code ‘GetClockWiseAngleAlongAxis’

In this case, I intend for that function to return the angle between vector lookW and vector Front, but in ‘2D’ or in other words, negating the Y component here.

When I’m writing this edit, I realise that’s actually pretty easily done by just setting the Y component to 0 lol. But still! I need to find the angle in a clockwise/anticlockwise direction: I cannot allow for it to find the ‘smallest’ angle, since then might rotate left when it’s supposed to rotate right and vice versa.

Forgive me for my bad math terminology =/

Can anyone help?

EDIT: I Found an answer to my question at : http://stackoverflow.com/questions/5188561/signed-angle-between-two-3d-vectors-with-same-origin-within-the-same-plane-reci