# how to create smooth (3D) cameras for games

2 replies to this topic

### #1Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 30 December 2011 - 01:48 AM

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

### #2SergeyK

New Member

• Members
• 2 posts

Posted 02 January 2012 - 10:08 AM

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).

### #3Xcrypt

New Member

• Members
• 144 posts
• LocationBelgium

Posted 04 January 2012 - 10:36 PM

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...same-plane-reci

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users