Newbie camera problem

Hi people, I’m new here!

First, I say sorry for my bad english.

Well, I’m new with OpenglGL and I’m developing a little application as a research, using GLUT and Windows.

Going direct to the matter, I want to make a FPS (first person shooter) camera style and I’m using glulookat and biding the mouse “pointer” as the aim - I don’t know if this is the most acceptable option. But anyway, since the coordinates accepted in a Window for the pointer position (x, y) will never be lesser than 0, I can’t figure out on how I could make a 360 degrees camera style using glulookat bounded to mouse, like FPS games.

I.e., when I move the mouse near the left side of the window, the camera moves too, but as the X coordinate go tending to 0, I get to a time where I can’t continue moving the camera to the same side, because there is no more mouse move from 0 to 0.

My code is as follows:
[b]
void MouseMotion(int x,int y)
{

int w, h;

w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);

Camera_Mira_X = x - w / 2;
Camera_Mira_Y = -(y - h / 2);

//I divided by 2 because I start the camera at origin, 0,0 and this is the middle of the window size.

}[/b]

My calling to glulookat (please, ignore Camera_Pos variables)

gluLookAt(Camera_Pos_X, 0.0, Camera_Pos_Z, Camera_Mira_X, Camera_Mira_Y, -100, 0.0, 1.0, 0.0);

I thank you very much since now.

Regards,
Guilherme.

Create callback for mouse position, use difference between position and screen center. Then warp cursor in center of screen. This way you never hit the edge of screen.

Thank you unsigned void…

I was just wondering how can I warp the cursor back to the center of the screen after any movement. I was thinking about this last night, but I couldn’t realize how to do that. Anyone could please help me how to warp the cursor back to the center?

Very big thank you!

glut offers you a hardcore function glutWarpPointer to do that :slight_smile: . Take care of what you do with this function and install some keyboard shorcuts to quit your application for safety.

Ok dletozeun, thanks.

This function triggers glutPassiveMotion?

Do you know if is there any lagging after calling this function and handling the mouse motion again?

holds!

For the two questions, I don’t think so. The best way to know it is just trying.

you’re right, sorry! :smiley:

I’ll let another question about camera.

I want to press the ‘W’ key and move the camera ahead, through the point I’m aiming. This is, simply, I want to track a straight between the point the camera stands and the point the camera aims to. For sure that have to evolve some algebra calculation, but I can’t remember how to obtain the vertices between one vertice and the other, or, to be more precise, the line that links one vertice to the other.

Someone can help me how to do that?

Thank you again guys!

Use GLFW and it will be much easier. Really.

ZBuffer, please, what is that? A function? A convention?

GLFW resolves the mouse motion problem too or only the last question I did?

Thanks!

It is a cross plateform library which is better than GLUT for game-like GL applications. Easy full screen display, keyboard/mouse/joypad inputs, timers, loading textures…

Do you know how to use a search engine ?
http://search.yahoo.com/search?p=GLFW

Ok Zbuffer, I’ll look for this, primarily I’d need to use GLUT, but I’ll try to insert GLFW in the project.

Guys, I thank you so much for the help, a big thank you!

Regards,
Guilherme.

EDIT: Solved.