PDA

View Full Version : should i convert my camera to quaternions?



enjoycrf
04-02-2011, 08:13 PM
i just have a regular camera class
and i cant seem to get any correct camera angles between the world and camera view besides the z axis which is my rotation angle from left to right

Alfonse Reinheart
04-02-2011, 08:37 PM
i just have a regular camera class

What is a "regular camera class," and how does it differ from other camera classes that we may have used that are not "regular?"

Or you could just explain how your camera class works.

enjoycrf
04-02-2011, 08:41 PM
see how this is only using a simple sin and stuff
it makes getting angles very hard
and i even read that is not reliable either


void RotateView(float speed) {


camera.view[1] = (float)(camera.pos[1] + sin(speed) * camera.vector[0] + cos(speed) * camera.vector[1]);
camera.view[0] = (float)(camera.pos[0] + cos(speed) * camera.vector[0] - sin(speed) * camera.vector[1]);

}

Alfonse Reinheart
04-02-2011, 10:11 PM
You also need to explain what it is you want the camera to actually do that you're having trouble with.

And USE PUNCTUATION! Periods, sentences, paragraphs. Maybe the reason you don't have a lot of "views" is because it's hard to read what you're writing.

enjoycrf
04-02-2011, 11:43 PM
you know that was totally a runon sentence?

but overlooking that unintentional mishap. i believe i have already expressed the issues i am having with my camera class, which are: that i am unable to easily calculate the x rotation angle which keeps flipping values, as i can the z rotation angle that doesnt;

Alfonse Reinheart
04-03-2011, 12:41 AM
that i am unable to easily calculate the x rotation angle which keeps flipping values, as i can the z rotation angle that doesnt;

What do you mean by "the x rotation angle"? What space are you trying to rotate about the X axis? And what exactly are you rotating: the camera's position, the camera's view target, or something else entirely?

How exactly are you trying to control the camera's position and orientation? That's the part I don't understand. You posted a few lines of code that compute two components of "camera.view", but you don't explain what "camera.view" is or how it gets used. Are these values passed to gluLookAt? Are they used by your own matrix generation code?

enjoycrf
04-03-2011, 04:33 PM
im trying to get the look up and down angle so i can transform models with it on the models x axis

Alfonse Reinheart
04-03-2011, 05:05 PM
im trying to get the look up and down angle so i can transform models with it on the models x axis

I still don't understand what you're doing here. I understand that you want to make the camera look up and down, but I don't see why you're wanting to rotate about the model's X axis to do this. Shouldn't that be the world's X axis if you're dealing with the camera? Is there a world space at all in your series of transforms?

Also, you didn't explain what "camera.view" is.

In any case, it seems clear that what you have is a typical "Orientations, not rotations" (http://www.arcsynthesis.org/gltut/Positioning/Tutorial%2008.html) problem. Successive transformations are applied successively. So if you have a Z rotationorientation followed by an X rotationorientation, the X orientation will be relative to the coordinate system after the Z orientation transform. That is, the X axis being oriented around is not relative to the original X axis, but relative to the X axis in the coordinate system after the Z orientation.

enjoycrf
04-03-2011, 05:47 PM
there is a camera.pos and a camera.view
those are the two coordinates that make the camera vector
and with a mouse i can rotate the camera using gllookat()
but i cant rotate a model the same way i rotate the camera
because the model only has glrotate not lookat
so thats why i need the angles

Alfonse Reinheart
04-03-2011, 05:49 PM
but i cant rotate a model the same way i rotate the camera
because the model only has glrotate not lookat
so thats why i need the angles

OK, so you're trying to rotate a model, not the camera. I linked you to a multi-page dissertation on how to orient models. Was something on that page unclear?