Need help in understanding FPS camera behaviour!

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Need help in understanding FPS camera behaviour!

Post by mmh771 »

First of all, what is the difference between get position and get absolute position?

If i have array of coordinates i want my webcam to follow, like this:

Turn Left -> 75%
Turn Right -> 30%
Turn Right -> 100%
Turn right - 60%

as 100% is either a full LEFT or full Right, in other words, a 100% Right mean to turn right 180 degree.

No the camera should turn left 75% degree of the 180, then after that it should turn right 30% of the 180 degrees, and again after the 30% rotation, it has to turn right again 100%!

How am i going to do that! any help please?
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Post by mmh771 »

And i've forgot to mention, that the camera will always be going forward.

Code: Select all

int i = 0;

while(device->run())
i++;

camera->setPosition(0, 0, i);
...
...
...
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Post by mmh771 »

Here are the following steps I've came up with so far!

Code: Select all

current = camera->getPosition();  // gets the camera's current position
camera->setRotation(0, R, 0); // sets the camera's direction along Y-Axis
camera->setPosition( current++) // Now move one step forward
As you can see, this is just a pseud code, that i can't translate into source code yet! ... any help please
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

getPosition() is the position relative to the parent, getAbsolutePosition() is realtive to coordinate origin (0,0,0)
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Post by mmh771 »

Hybrid, thanks for your answer ... and now i've just got what getAbsolutePoistion does ...

And now for my main question, which is about after setting the Camera Rotation Value around the Y-Axis, how can i know the next coordinates, to set the camera position to it.

in other words:

First we need to get the camera current position by using camera->getPosition(), which will return X Y Z values.

Now we set the Rotation Value, by using: camera->setRotation(0, R, 0)

And Finally, we need to calculate the New X Y Z coordinates so we can set the camera to the new coordinates, by using camera->setPosition(newX, newY, 1).

I wrote the One value in the last setPosition(newX, newY, 1), because i assume the camera will be always moving forward.

So does anyone know how to calculate the newX and newY coordinates?
stef_
Posts: 53
Joined: Tue Apr 18, 2006 9:39 pm
Contact:

Post by stef_ »

There are two "magical" function called "sin" and "cos"... :)

bye
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Post by mmh771 »

I've got D+ in Calculas I, and D in Calculas II !!!!

And Sin and Cos, are the very last thing i can deal with! .. would you JUST show me a simple example how can i use them to solve my probelm!

please ...
Post Reply