Ninja

10-01-2002, 11:42 AM

Hi, maybe this is an easy question, but if I have a lightposition in worldspace, how do I convert it to eyespace?

Regards, Ninja

Regards, Ninja

View Full Version : Worldspace to eyespace

Ninja

10-01-2002, 11:42 AM

Hi, maybe this is an easy question, but if I have a lightposition in worldspace, how do I convert it to eyespace?

Regards, Ninja

Regards, Ninja

jwatte

10-01-2002, 11:47 AM

Multiply it by your worldspace->eyespace transformation matrix.

Note that GL doesn't by itself have a notion of worldspace, because it bakes model-to-world and world-to-view into the composite model-to-view matrix.

Anyway, if you create your modelview by using one modelworld matrix and one worldview matrix, then just use the latter to go from world to view.

Note that GL doesn't by itself have a notion of worldspace, because it bakes model-to-world and world-to-view into the composite model-to-view matrix.

Anyway, if you create your modelview by using one modelworld matrix and one worldview matrix, then just use the latter to go from world to view.

SirKnight

10-01-2002, 04:05 PM

It goes like this:

object_space->[MODEL_MATRIX]->world_space->[VIEW_MATRIX]->eye_space->[PROJ_MATRIX]-> etc...

Do you have some kind of camera class so you can orient where the "camera" is looking and where it is located? If so, all of those translations and rotations combined in a matrix makes your view_matrix. So just take that matrix and multiply with your light and presto, eye-space light! http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

object_space->[MODEL_MATRIX]->world_space->[VIEW_MATRIX]->eye_space->[PROJ_MATRIX]-> etc...

Do you have some kind of camera class so you can orient where the "camera" is looking and where it is located? If so, all of those translations and rotations combined in a matrix makes your view_matrix. So just take that matrix and multiply with your light and presto, eye-space light! http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

solarforge

10-01-2002, 08:15 PM

Originally posted by SirKnight:

It goes like this:

object_space->[MODEL_MATRIX]->world_space->[VIEW_MATRIX]->eye_space->[PROJ_MATRIX]-> etc...

Do you have some kind of camera class so you can orient where the "camera" is looking and where it is located? If so, all of those translations and rotations combined in a matrix makes your view_matrix. So just take that matrix and multiply with your light and presto, eye-space light! :D

-SirKnight

If you talking from the point of view of OpenGL's transformation pipe, that's not quite right... As John said:

object_space->[MODEL_VIEW_MATRIX]->eye_space->[PROJ_MATRIX]-> etc...

However, for a light in worldspace, you can back transform the light to model space with a translation, set the actual location to the model's origin and then transform by the MODELVIEW matrix...

Leathal.

It goes like this:

object_space->[MODEL_MATRIX]->world_space->[VIEW_MATRIX]->eye_space->[PROJ_MATRIX]-> etc...

Do you have some kind of camera class so you can orient where the "camera" is looking and where it is located? If so, all of those translations and rotations combined in a matrix makes your view_matrix. So just take that matrix and multiply with your light and presto, eye-space light! :D

-SirKnight

If you talking from the point of view of OpenGL's transformation pipe, that's not quite right... As John said:

object_space->[MODEL_VIEW_MATRIX]->eye_space->[PROJ_MATRIX]-> etc...

However, for a light in worldspace, you can back transform the light to model space with a translation, set the actual location to the model's origin and then transform by the MODELVIEW matrix...

Leathal.

SirKnight

10-02-2002, 03:56 AM

I never said that is exactly how opengl does it. OpenGL ovbiously combines the model and view matrcies together to save an extra matrix multiply or something. But requardless of that, the same math is still taking place, the end result will still be the same. What I said applys to 3d graphics no matter what API is used. I wrote it like that to better see where world space is.

Here is a method that may help:

matrix4x4 mat = object[objIndex].InverseTransform() * light.GetTransform();

mat.Multiply( light_pos, objSpaceLight );

So what we are doing there is taking the inverse of the transformations done to your model and multiplying that with the tranformations that was applied to your light (any translations or rotations if any, otherwise that will just return an identity matrix). Then this matrix is used to take the light position and transform it to object space. That code right there is based on the code in Cass's inf shadow volume demo, incase that looks familiar to anyone. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

Here is a method that may help:

matrix4x4 mat = object[objIndex].InverseTransform() * light.GetTransform();

mat.Multiply( light_pos, objSpaceLight );

So what we are doing there is taking the inverse of the transformations done to your model and multiplying that with the tranformations that was applied to your light (any translations or rotations if any, otherwise that will just return an identity matrix). Then this matrix is used to take the light position and transform it to object space. That code right there is based on the code in Cass's inf shadow volume demo, incase that looks familiar to anyone. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.