View Full Version : World VS Model Space....

08-02-2002, 07:05 AM
If I have a player walking through a world, and I have a bounding sphere around the player. I have a Direction vector pointing from the sphere center, out to the world, in the direction im heading. Now if I move the player 2 things happen. First the world is moved by glTranslate, and glRotate, in the negative direction for the actual, so that the view changes in the correct direction. I also rotate my Direction vector using, cos, and sin. (in the possitive direction, not the negative).

My Question is this. If i am rotating my direction vector by using Cos and Sin, what is my vectors 'space' is it in world space, or model space?? I am very new to this idea of 2 different kinds of space, and im not realy sure which is correct.???

EDIT: I am also moving my bounding sphere as I move, with a simple

BoundingSphere[x] = BoundingSphere[x] + Move*DirectionVector[x];

BoundingSphere[z] = BoundingSphere[z] + Move*DirectionVector[z];

I multiply by the direction vector, so I actualy move in the direction im facing, instead of simply up and down the x,z axises, I think this is correct. And NO y component because i dont want to move UP at all.

[This message has been edited by LostInTheWoods (edited 08-02-2002).]

08-02-2002, 10:17 PM
Originally posted by LostInTheWoods:
My Question is this. If i am rotating my direction vector by using Cos and Sin, what is my vectors 'space' is it in world space, or model space??

The vector has to be relative to some coordinate system. That coordinate system is the the "space" it is in.

That's all it means when something is in world, model, clip, view, texture, tangent, screen, etc... space.

08-03-2002, 07:50 AM
Assuming that you're seeing out of the eyes of the character:

Your "camera" is in "eye space". The "world" rotates around the character. Other "models" in the world may, in turn, be oriented relative to the world.

Thus, the hierarchy of transform, going from eye to object being rendered is:

EYE->WORLD "view"

OpenGL concatenates the two transformations needed to go from one way to antoher into the composite MODELVIEW matrix. Thus, you may wish to keep two transforms on your own, and concatenate them for OpenGL's use.

This is all extra delicious because OpenGL uses pre-apply (to make push/pop useful) so the order of commands is:

glTranslatef() to put the viewer in the right place in the world (i e put viewer center at origin)
glRotatef() to orient the world according to viewer
glTranslatef() to get objects position relative world origin
glRotatef() to correctly orient the model relative to the world

Note that if you're drawing "terrain" or "background" then the two last steps are likely to be identity. If you draw many things, and don't want to do all your own matrix math, you can PushMatrix/PopMatrix around the second two operations for each object in your world.