Hi, 

Hello

>huiliang yang wrote:
> I have a question about computeLocalToWorldMatrix in camera class.
> First, since the openscenegraph use row matrix instead column matrix 
>like opengl, I thought the default matrix multiply should be post 
> multiply so that :
>       V' = M*V  (opengl premultiply) chanage to
>      V' = VT*MT   ( osg post multiply)
Ok
> but looks like the camera still use pre_multiply as default, but the 
> _viewmatrix define in camera class is apparently  is  a  row matrix  MT.
How do you get to this statement, which section of the code do you refer to?

no any specific code for above statement. but I do trace the code and find 
_viewmatrix in camera class 
is a row matrix, which means the translation (x, y, z) is at last row. So, if 
the matrix is a row matrix, only way for multiply is 
by  matrix = matrix*_viewmatrix. or matrix.postmultiply(_viewmatrix). is that 
correct?
That is why I say why the default multiply in camera class is premultiply, in 
computeLocalToWorldMatrix, 
it  use matrix = _viewmatrix*matrix or matrix.premultiply(_viewmatrix), if 
_viewmatrix is a row matrix, it looks weird. 


It also depends on your definition of 'pre-multiply'. If you say VT*MT 
is "post multiply" (as you do above), then this implies that you 
actually mean "MT post-multiplies VT". This is turn also means that "VT 
pre-multiplies MT". So it depends from which operand you look at it how 
you describe the operation.
>
> Second, even as the default pre_multiply, then let's say:
>      V' = M*V  if (_transformOrder==PRE_MULTIPLY)
> then its inverse should be
>      V = M-1* V' ,
> why in function computeWorldToLocalMatrix
Which class? You say "V", which implies a vector usually, but, for 
example, Camera::computeWorldToLocalMatrix works on a matrix as input. 
If you indeed refer to Camera::computeWorldToLocalMatrix() then I would 
say that that method does the inverse operation of 
computeLocalToWorldMatrix(). Assuming _referenceFrame==RELATIVE_RF and 
_transformOrder==PRE_MULTIPLY then the method computeLocalToWorldMatrix 
pre-multiplies its argument "matrix" with "_viewMatrix". I.e.

  matrix.preMult(_viewMatrix);

actually does

  matrix = _viewMatrix * matrix;

Method computeWorldToLocalMatrix() does the inverse of this operation, 
so instead of pre-multiplying with _viewMatrix it post-multiplies with 
the inverse of _viewMatrix (the comments also say this).

That is I don't understand, if matrix' = _viewMatrix*matrix, then the inverse 
operation is 
matrix = _viewMatrix-1*matrix', right?
why here it change the order of multiply? 


Regards,
Paul


      
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to