Hi,

I don't know if you already found the solution to your problem, but this is how 
you can calculate the camera position in worldspace:


Code:

vec4 cameraPos_wordspace = osg_ViewMatrixInverse * vec4(0.0, 0.0, 0.0, 1.0);




The rotation and scale factors can be found in the first three rows and columns 
of a matrix, so if you only want to compute a rotation and scale it is 
sufficient to use a 3x3 matrix.
But to mathematically compute a translation of a vector you need to use a 4x4 
matrix. The vector needs to be expanded to the 4th dimension, as-well to make 
it compatible with the matrix for multiplication.

Here is how it works:


Code:

M * v = v'
<==>
1 0 0 tx * x = 1*x + 0*y + 0*z + tx * 1
0 1 0 ty * y = 0*x + 1*y + 0*z + ty * 1
0 0 1 tz * z = 0*x + 0*y + 1*z + tz * 1
0 0 0 1 * 1 = 0*x + 0*y + 0*z + 1*1



(These are the rows of a matrix not individual equations, I wasn't able to 
format it in a good way, sorry)

no if we simplify this we get:

Code:

  x+tx
= y+ty
  z+tz
  1




As we can see it all boils down to adding an offset the the original vector. 
For the rest of your computations you can just ignore the w component of the 
vector.
I hope I was able to shed some light on the dark ;)
Thank you!

Cheers,
Marcel

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56677#56677





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to