View matrix/ World matrix problem

View matrix/ World matrix problem

Post by Nadav Rubinstei » Sun, 18 Aug 2002 02:08:52



I am writing an engine, using this engine I load a scene
made of several objects, camera ( view matrix ) and
animation, I am trying to 'place' an object that will
represent the camera ( e.g. use the cameras view matrix
as the objects world matrix ) I expected the object to be
drawn at the location of the camera, surprisingly it was
drawn at a location 'Inverse' to the location of the
camera, when I used the Inverse matrix of the view matrix
as the objects world matrix all worked fine, the object
was drawn where expected.
Should things work this way or am I missing something???
How can I avoid inversing the view matrix???
When dealing with motion the inverse of the matrix should
be calculated each frame ( worst case ) which is
computational expensive.

How can one cause an object to be drawn at the 'position'
of the view matrix without inversing the view matrix??????

Thanks in advance,
   Nadav Rubinstein.

 
 
 

View matrix/ World matrix problem

Post by Cronus3 » Sun, 18 Aug 2002 02:31:20


Quote:> I am writing an engine, using this engine I load a scene
> made of several objects, camera ( view matrix ) and
> animation, I am trying to 'place' an object that will
> represent the camera ( e.g. use the cameras view matrix
> as the objects world matrix )

The view matrix is not the matrix that describes the position and
orientation of the camera in the world.  However, the view matrix is the
inverse of a matrix that does position and orientate the camera in the
world.

I expected the object to be

Quote:> drawn at the location of the camera, surprisingly it was
> drawn at a location 'Inverse' to the location of the
> camera, when I used the Inverse matrix of the view matrix
> as the objects world matrix all worked fine, the object
> was drawn where expected.

And that is the correct behavior.

Quote:> Should things work this way or am I missing something???
> How can I avoid inversing the view matrix???
> When dealing with motion the inverse of the matrix should
> be calculated each frame ( worst case ) which is
> computational expensive.

Why not just store the cameras world position and orientation directly ??
In actuality, computing the inverse of a view matrix isn't very
computationally expensive.

Quote:> How can one cause an object to be drawn at the 'position'
> of the view matrix without inversing the view matrix??????

The view matrix doesn't have a position.  It describes the transformation
from world space to view space.
Quote:> Thanks in advance,
>    Nadav Rubinstein.


 
 
 

View matrix/ World matrix problem

Post by Nadav Rubinstei » Sun, 18 Aug 2002 04:20:27


Thanks

Quote:>-----Original Message-----

>> I am writing an engine, using this engine I load a
scene
>> made of several objects, camera ( view matrix ) and
>> animation, I am trying to 'place' an object that will
>> represent the camera ( e.g. use the cameras view matrix
>> as the objects world matrix )

>The view matrix is not the matrix that describes the
position and
>orientation of the camera in the world.  However, the
view matrix is the
>inverse of a matrix that does position and orientate the
camera in the
>world.

>I expected the object to be
>> drawn at the location of the camera, surprisingly it
was
>> drawn at a location 'Inverse' to the location of the
>> camera, when I used the Inverse matrix of the view
matrix
>> as the objects world matrix all worked fine, the object
>> was drawn where expected.

>And that is the correct behavior.

>> Should things work this way or am I missing
something???
>> How can I avoid inversing the view matrix???
>> When dealing with motion the inverse of the matrix
should
>> be calculated each frame ( worst case ) which is
>> computational expensive.

>Why not just store the cameras world position and

orientation directly ??

- Show quoted text -

Quote:>In actuality, computing the inverse of a view matrix
isn't very
>computationally expensive.

>> How can one cause an object to be drawn at
the 'position'
>> of the view matrix without inversing the view
matrix??????

>The view matrix doesn't have a position.  It describes
the transformation
>from world space to view space.

>> Thanks in advance,
>>    Nadav Rubinstein.

>.

 
 
 

1. Seperate World/View matrix

Hi there,

I`m coming to opengl from directx and I have a quick question about
the way I am trying to render a scene using seperate view and model
matrices a`la directx. Here is how I`m trying to do it in opengl:

For each frame...

    // load the view matrix as follows:
    glLoadMatrixf((float*)pCam->GetLocalMatrix());

    For each model in scene...
        // load the model`s local to world transform as follows...
        glPushMatrix();
            glMultMatrixf(pMesh->GetLocalMatrix());
        glPopMatrix;
        // Render mesh geometry using glDrawElements...
    Next model

Next frame

So you can see I`m setting the view matrix only once per frame but
applying a local to world matrix for each mesh.

According to the little red book glPushMatrix() creates a new matrix
on the stack that is a copy of the current matrix that`s on the top of
the stack and that glMultMatrixf() multiplies the passed matrix (my
local to world mesh matrix) with the one on the top of the stack (my
view matrix).

However I can only see the first mesh.

I`m pretty happy that my 2nd meshes vertices (expressed relative to
the mesh`s local matrix axis) are correct and that the 2nd mesh`s
local matrix is also correct.

I`d appreciate any ideas and/or comments on the way I`m setting up the
matrices.

Many thanks in advance,
Ben.

2. Color gradient...

3. Direct3D9: (INFO) :Cannot invert world-view matrix, assuming identity

4. One to the other?

5. World and View Matrix Question

6. ANN: BSP Solid Modeling

7. World/View Matrix - Cameras

8. World/view matrix

9. MATRIX MATRIX MATRIX

10. clipping matrix = projection matrix X modelview matrix ?

11. Clipping matrix = projection matrix X modelview matrix ?

12. View matrix problem