Page 1 of 1

Need help in understanding FPS camera behaviour!

Posted: Fri May 26, 2006 9:29 am
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?

Posted: Fri May 26, 2006 10:17 am
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);
...
...
...

Posted: Fri May 26, 2006 10:28 am
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

Posted: Fri May 26, 2006 11:56 am
by hybrid
getPosition() is the position relative to the parent, getAbsolutePosition() is realtive to coordinate origin (0,0,0)

Posted: Fri May 26, 2006 12:33 pm
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?

Posted: Fri May 26, 2006 1:32 pm
by stef_
There are two "magical" function called "sin" and "cos"... :)

bye

Posted: Fri May 26, 2006 10:12 pm
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 ...