Sam, Richard and Oscar,

thank you for your help!!

Now the things are clear to me, I was confused by the view matrix stuff from d3d, I came from opengl, and there I used to change the MODEL_VIEW matrix with the camera invert matrix (exactly as you described) and goes pushing the object2world matrix on stack (transforming against the invert view matrix).

But when I arrived on d3d, I through that the view matrix will invert my camera matrix and do the work, add to this the bug on my GetAxis function (that Oscar spotted), everything worked until I started moving the objects around.

But based on your comments, it appears that the View matrix is just a helper function, so I don't need to transform all my objects by the invert camera matrix before rendering (like I did on opengl), I just need to set the view matrix to the **invert matrix** of the camera and the world by the objects matrix.

Nice, now everything makes sense!!

Sorry for the API specific comments / questions.

Thanks again!

Bruno Sanches

On 2/7/08, **Sam Martin** <sam.martin@geomerics.com> wrote:

There's a simple way of thinking about these matrices that might help you.

All of these matrices are transformations that take you from one space to another. If each space is a vertex in a graph, then the matrices are the directed edges linking the vertices. You can actually sit down a draw a graph of how your geometry transitions between these spaces.

Your 'standard object matrix' is an object_space -> world_space transformation. And a 'camera view matrix' is a world_space -> view_space transformation. Inverting these matrices reverses the direction of the transformation.

If your view_space is the same as your object_space for the camera – which is up to you to define but is perfectly reasonable – then the inverse of your camera 'view matrix' is actually the camera's 'standard object matrix'. Draw the graph if you are confused. This might explain to you why one works with an inverse and the other doesn't.

Because of this I find it more helpful to think of my matrices as object2world, world2view, view2proj rather than just 'world', 'view' or 'proj' as the link between the two is relevant.

Hope that helps,

Sam

From:gdalgorithms-list-bounces@lists.sourceforge.net [mailto:gdalgorithms-list-bounces@lists.sourceforge.net]On Behalf OfBruno Sanches

Sent:07 February 2008 13:43To:Game Development AlgorithmsSubject:Re: [Algorithms] Dummie Matrix math questions

I will verify that when I arrive at home, because thinking again, I belive my code at home is wrong, because now it makes sense why using the inverse matrix its works :). Two days investigating this and havent figured out this!

So, it appears that for the view, I will need to use the invert matrix after fixing the code, thats weird to me, does anyone knows a tutorial / doc that explain the math behind view matrix?

Thank you!

Bruno Sanches

On 2/7/08,

Oscar Forth<oscar@trueharmoniccolours.co.uk> wrote:Well either you wrote it twice wrong in your original mail ... or you wrote it correctly both times.

Anyway, I still think its because GL and DX matrices are transposes of each other ... an invert of a simple rotation matrix is the transpose of that matrix.

View matrices are odd beasts ... they are not constructed like a standard object matrix. They aren't interchangeable ...

Hope thats some help.

----- Original Message -----

From:Bruno Sanches

Sent:Thursday, February 07, 2008 12:28 PM

Subject:Re: [Algorithms] Dummie Matrix math questions

Sorry Oscar, I typed it wrong when writing the email, the object code uses the same code from camera to extract the axis.

I am not sure if something with my math is wrong. The most strange for me is that for the camera, when I get the fwd vector and use it to move the camera, everything goes fine, but for objects, I need to get the fwd vector from the inverse matrix.

I am not understanding why I need to do that, because I was expecting the camera to behave like any other object.

Thank you

Bruno Sanches

On 2/7/08,

Oscar Forth<oscar@trueharmoniccolours.co.uk> wrote:Sounds like the difference between GL and DX row/column ordering.

Under DX it should be

fwd.x = objectMatrix._11;

fwd.y = objectMatrix._12;

fwd.z = objectMatrix._13;

Don't get confused by the two ...

Sorry if thats a bit of a platform specific answer admins!

----- Original Message -----

From:Bruno Sanches

Sent:Thursday, February 07, 2008 12:07 PM

Subject:[Algorithms] Dummie Matrix math questions

Hello Folks,

I am reading this list emails (and learning a lot) from some time and I would like to ask some help with basic 3d transformations that is giving a lot of headaches for me on last days (and nights)...

On the framework that I am working (d3d9) I have a basic scene graph system, each node has a transformation matrix.

On rendering, I have a code (pseudo code) like this:

Vec3 fwd;

fwd.x = cameraMatrix._11;

fwd.y = cameraMatrix._21;

fwd.z = cameraMatrix._31;//My coordinate system, x is forward, y is right, Z is up (right hand with Z pointing up)

Vec3 origin = cameraOrigin;

Vec3 at = origin + fwd;Vec3 up;

up.x = cameraMatrix._13;

up.x = cameraMatrix._23;

up.x = cameraMatrix._33;D3DXMATRIX viewMat;

D3DXMatrixLookAtRH(&viewMat, cameraOrigin, &at, &up);screen->SetViewTransform(viewMat);

After setting up the camera transformation like above, I go rendering my objects:

for each object

{

D3DXMATRIX mat = object.matrix;

screen->SetWorldTransform(mat);

DrawObject();

}And everything works fine.

But, now I am trying to move a object forward, and this is where my problems start, for moving my objects, I do:

void moveObject(float dist)

{

Vec3 fwd;

fwd.x = objectMatrix._11;

fwd.y = objectMatrix._21;

fwd.z = objectMatrix._31;

fwd *= dist;

objectOrigin += fwd;

}This appears to work, but I found out that the objects matrix appears to be inverted, they will move on very strange directions, if on the above function I use a invert matrix, everything works fine! I don't know what I am missing here, because I was expecting the above function to work without using the inverse matrix.

I have similar code on opengl few years ago and it worked. Does anyone has any clue what is going on? Or at least, is this expected? :)

Please note for all math, I am using d3dx math functions.

Thank you for your help!

Regards

Bruno Sanches

-------------------------------------------------------------------------

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________

GDAlgorithms-list mailing list

GDAlgorithms-list@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list

Archives:

http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list

-------------------------------------------------------------------------

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________

GDAlgorithms-list mailing list

GDAlgorithms-list@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list

Archives:

http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list

-------------------------------------------------------------------------

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________

GDAlgorithms-list mailing list

GDAlgorithms-list@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list

Archives:

http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list

-------------------------------------------------------------------------

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________

GDAlgorithms-list mailing list

GDAlgorithms-list@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list

Archives:

http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list

-------------------------------------------------------------------------

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________

GDAlgorithms-list mailing list

GDAlgorithms-list@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list

Archives:

http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list