From: Bruno Sanches <bcsanches@gm...>  20080207 12:07:45
Attachments:
Message as HTML

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 
From: Oscar Forth <oscar@tr...>  20080207 12:13:40
Attachments:
Message as HTML

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 To: Game Development Algorithms 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/  _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 
From: Bruno Sanches <bcsanches@gm...>  20080207 12:28:46
Attachments:
Message as HTML

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@...> 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 <bcsanches@...> > *To:* Game Development Algorithms<gdalgorithmslist@...> > *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/ > >  > > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > 
From: Oscar Forth <oscar@tr...>  20080207 12:32:41
Attachments:
Message as HTML

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 To: Game Development Algorithms 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@...> 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 To: Game Development Algorithms 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/  _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist  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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist   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/  _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 
From: Bruno Sanches <bcsanches@gm...>  20080207 13:42:42
Attachments:
Message as HTML

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@...> 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 <bcsanches@...> > *To:* Game Development Algorithms<gdalgorithmslist@...> > *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@...> 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 <bcsanches@...> > > *To:* Game Development Algorithms<gdalgorithmslist@...> > > *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/ > > > >  > > > > _______________________________________________ > > GDAlgorithmslist mailing list > > GDAlgorithmslist@... > > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > Archives: > > > > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > > > > > >  > > 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/ > > _______________________________________________ > > GDAlgorithmslist mailing list > > GDAlgorithmslist@... > > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > Archives: > > > > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > >  > >  > 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/ > >  > > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > 
From: Richard Fabian <raspo1@gm...>  20080207 13:56:35
Attachments:
Message as HTML

you can think of a view matrix as just being a model matrix of your camera, and the reason you use the inverse of it is that you're trying to transform the scene by the camera's model matrix, but the camera is the other way up/down the scene graph. consider this: "object" is a child of "transform", is a child of "scene root", "camera" is a child of "scene root" to render "object", you need to get each vertex of "object", multiply each of them by the transforms "down" the chain . First by "object"'s model matrix, then down to "transform", then you reach the scene root (which you might have as a transform, but not normally as you'll see in a moment), but to get to the camera you have to go "up" (using the inverse matrix instead) of "camera" so you apply the inverse camera after you've built your "world" representation using the idea that a inverse multiply is a divide, you can figure it through like this V * object * transform * root / root / camera as you can see, the root scene transform is unimportant because it cancels immediately, leaving you with: V * object * transform / camera and this is why you need to use the inverse camera local matrix to build your renderer camera transform. On Feb 7, 2008 1:42 PM, Bruno Sanches <bcsanches@...> wrote: > 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@...> 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 <bcsanches@...> > > *To:* Game Development Algorithms<gdalgorithmslist@...> > > *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@...> 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 <bcsanches@...> > > > *To:* Game Development Algorithms<gdalgorithmslist@...> > > > *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/ > > > > > >  > > > > > > _______________________________________________ > > > GDAlgorithmslist mailing list > > > GDAlgorithmslist@... > > > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > > Archives: > > > > > > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > > > > > > > > > >  > > > 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/ > > > _______________________________________________ > > > GDAlgorithmslist mailing list > > > GDAlgorithmslist@... > > > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > > Archives: > > > > > > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > > > > >  > > > > > >  > > 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/ > > > >  > > > > _______________________________________________ > > GDAlgorithmslist mailing list > > GDAlgorithmslist@... > > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > Archives: > > > > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > > > > > >  > > 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/ > > _______________________________________________ > > GDAlgorithmslist mailing list > > GDAlgorithmslist@... > > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > > Archives: > > > > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist >  fabs(); Just because the world is full of people that think just like you, doesn't mean the other ones can't be right. 
From: Sam Martin <sam.martin@ge...>  20080207 13:57:49
Attachments:
Message as HTML

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: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Bruno Sanches Sent: 07 February 2008 13:43 To: Game Development Algorithms Subject: 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@...> 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 <mailto:bcsanches@...> To: Game Development Algorithms <mailto:gdalgorithmslist@...> 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@...> 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 <mailto:bcsanches@...> To: Game Development Algorithms <mailto:gdalgorithmslist@...> 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/ ________________________________ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslis t   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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslis t ________________________________   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/ ________________________________ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslis t   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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslis t 
From: Bruno Sanches <bcsanches@gm...>  20080207 14:37:39
Attachments:
Message as HTML

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@...> 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:* gdalgorithmslistbounces@... [mailto: > gdalgorithmslistbounces@...] *On Behalf Of *Bruno > Sanches > *Sent:* 07 February 2008 13:43 > *To:* Game Development Algorithms > *Subject:* 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@...> 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 <bcsanches@...> > > *To:* Game Development Algorithms<gdalgorithmslist@...> > > *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@...> 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 <bcsanches@...> > > *To:* Game Development Algorithms<gdalgorithmslist@...> > > *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/ >  > > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > >  > >  > 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/ >  > > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > 
From: Will Vale <will@se...>  20080207 21:02:00

> 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. Amen to that  it makes the concatenations much more straightforward to errorcheck. Will 
From: Richard Fabian <raspo1@gm...>  20080208 09:44:09
Attachments:
Message as HTML

whereas I'm not so sure about thinking of it like this. I prefer to understand what the options are. Saying that the matrix is "model2world" to me means it's a transform, but I don't really think of matrices as being transforms. They are, but its a side effect. For me, i visualize a matrix as being the three vectors of XYZ modulation plus the 3D offset (the W=1 modulation). It certainly helps me come up with more novel solutions to problems when i think of it in this way. Its like sometimes its important to remember that a vector with a W of 1 is a position and one with a W of 0 is a vector. Don't dumb it down. You lose out in the long run. On Feb 7, 2008 9:01 PM, Will Vale <will@...> wrote: > > > 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. > > Amen to that  it makes the concatenations much more straightforward to > errorcheck. > > Will > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist >  fabs(); Just because the world is full of people that think just like you, doesn't mean the other ones can't be right. 
From: Johnson, Matt <Matt.J<ohnson@am...>  20080207 14:46:01
Attachments:
Message as HTML

http://www.toymaker.info/Games/html/camera.html 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? 
From: Jon Watte <hplus@mi...>  20080207 18:38:55

Direct3D uses row vectors on left. Thus, the "X" basis vector lives in the first row, not first column. For more information, see http://www.mindcontrol.org/~hplus/graphics/matrixlayout.html Cheers, / h+ Bruno Sanches wrote: > > 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/ >  > > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist   Go is to Western chess what philosophy is to double entry accounting. 
From: Sam Martin <sam.martin@ge...>  20080208 10:25:37
Attachments:
Message as HTML

One of the things I love about maths is that there are often equivalent ways of expressing things. Each interpretation is valuable and their equivalency can offer new insights. I certainly wouldn't want to forget what each of the basis vectors are, or the properties certain vectors can have. Depending on what you are accomplishing one interpretation might be more valuable than another, so there should be room for all  no suggestion of dumbing down. Incidentally, I think my graph comparison is kind of under represented in standard graphics text. Cheers, Sam ________________________________ From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Richard Fabian Sent: 08 February 2008 09:44 To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions whereas I'm not so sure about thinking of it like this. I prefer to understand what the options are. Saying that the matrix is "model2world" to me means it's a transform, but I don't really think of matrices as being transforms. They are, but its a side effect. For me, i visualize a matrix as being the three vectors of XYZ modulation plus the 3D offset (the W=1 modulation). It certainly helps me come up with more novel solutions to problems when i think of it in this way. Its like sometimes its important to remember that a vector with a W of 1 is a position and one with a W of 0 is a vector. Don't dumb it down. You lose out in the long run. On Feb 7, 2008 9:01 PM, Will Vale <will@...> wrote: > 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. Amen to that  it makes the concatenations much more straightforward to errorcheck. Will   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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslis t  fabs(); Just because the world is full of people that think just like you, doesn't mean the other ones can't be right. 
From: Will Vale <will@se...>  20080208 11:58:26

On Fri, 08 Feb 2008 23:25:30 +1300, Sam Martin <sam.martin@...> wrote: > One of the things I love about maths is that there are often equivalent > ways of expressing things. I was going to reply at more length but you've said it much more eloquently than I would have :) I must admit I generally try and think in terms of the highestlevel (most dumb?) representation available to the problem at hand  so when moving points between spaces, matrices are opaque mappings. When constructing these mappings, it helps me to see them as bases instead. etc. etc. Heh  even talking about matrices like they're always 4x3 or 4x4 (as we're likely all guilty of doing from time to time) is rather a narrow view of the concept... W 
From: Richard Fabian <raspo1@gm...>  20080208 12:06:41
Attachments:
Message as HTML

> > Heh  even talking about matrices like they're always 4x3 or 4x4 (as we're > likely all guilty of doing from time to time) is rather a narrow view of > the concept... > > W > > I would "like" to see hardware take a blind leap of faith and provide us with a wider than four simd instruction set, but its not going to happen, so we all end up thinking in 4x4 usually. Its not narrow, just pertinent.  fabs(); Just because the world is full of people that think just like you, doesn't mean the other ones can't be right. 
From: Jon Watte <hplus@mi...>  20080208 17:42:44

Richard Fabian wrote: > I would "like" to see hardware take a blind leap of faith and provide > us with a wider than four simd instruction set, but its not going to > happen, so we all end up thinking in 4x4 usually. Its not narrow, just > pertinent. I'm told that the implementation of modern 4way SIMD on graphics cards is now done as serial instructions, so there's little benefit to be had compared to just coding it out. The reason for this was stated that real shaders actually had a "real operands per SIMD instruction" count of about 2, and falling over time as shaders got more complex. The good news part of this is that you can easily just code up as wide a dot product as you want, and expect performance to fall off gracefully with length. Cheers, / h+   Go is to Western chess what philosophy is to double entry accounting. 
From: Marco Salvi <marcotti@gm...>  20080208 18:34:00
Attachments:
Message as HTML

On Feb 8, 2008 9:42 AM, Jon Watte <hplus@...> wrote: > > I'm told that the implementation of modern 4way SIMD on graphics cards > is now done as serial instructions, so there's little benefit to be had > compared to just coding it out. This is true for NVIDIA (G8x architecture) and latest Intel GPUs, not for AMD/ATI GPUs. But yes..I guess everyone will sooner or later move to the same model. Marco 
From: Jesús de Santos García <jesus.santos@gm...>  20080212 13:46:27
Attachments:
Message as HTML

The same is true for ATI too as described in the ATI HD2000 Programming Guide. Nonvectorized code is optimized and it is recommended for cases where vectorial instructions are not needed. http://ati.amd.com/developer/SDK/AMD_SDK_Samples_May2007/Documentations/ATI_Radeon_HD_2000_programming_guide.pdf Good to know that nvidia and intel are using the same architecture. On Feb 8, 2008 7:34 PM, Marco Salvi <marcotti@...> wrote: > > > On Feb 8, 2008 9:42 AM, Jon Watte <hplus@...> wrote: > > > > > I'm told that the implementation of modern 4way SIMD on graphics cards > > is now done as serial instructions, so there's little benefit to be had > > compared to just coding it out. > > > This is true for NVIDIA (G8x architecture) and latest Intel GPUs, not for > AMD/ATI GPUs. > But yes..I guess everyone will sooner or later move to the same model. > > Marco > > >  > 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/ > _______________________________________________ > GDAlgorithmslist mailing list > GDAlgorithmslist@... > https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist > 
From: Emil Persson <humus@co...>  20080212 21:37:13
Attachments:
Message as HTML

I wrote that document, and either youre reading it wrong or you misunderstood what Jon and Marco said. The HD 2000 series is a scalar architecture, hence its not necessary to vectorize code like you would on R520 or G70, however, its parallel rather than serial. The important thing is to parallelize the code so that each scalar instruction can be issued into a separate slot. Since vectorized code is by nature also parallel it will run fast, so vectorized code is not a bad thing. But unlike earlier generations parallel code thats not vectorized also runs fast since all parallel scalars can be computed in parallel. What doesnt run fast is serial scalar dependencies since these lead to poor utilization of the shader cores. In average shaders this is not so much of a problem, but you could construct pathological cases where utilization would be 1/5 of the maximum throughput. To parallelize your code its recommended that you use parentheses to break up long lines since HLSL evaluates expressions from left to right, just like C/C++. So A+B+C+D is computed as ((A+B)+C)+D, whereas (A+B)+(C+D) could run in one instruction less (assuming all are scalars). Emil _____ From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Jesús de Santos García Sent: Tuesday, February 12, 2008 2:47 PM To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions The same is true for ATI too as described in the ATI HD2000 Programming Guide. Nonvectorized code is optimized and it is recommended for cases where vectorial instructions are not needed. http://ati.amd.com/developer/SDK/AMD_SDK_Samples_May2007/Documentations/ATI_ Radeon_HD_2000_programming_guide.pdf Good to know that nvidia and intel are using the same architecture. On Feb 8, 2008 7:34 PM, Marco Salvi <marcotti@...> wrote: On Feb 8, 2008 9:42 AM, Jon Watte <hplus@...> wrote: I'm told that the implementation of modern 4way SIMD on graphics cards is now done as serial instructions, so there's little benefit to be had compared to just coding it out. This is true for NVIDIA (G8x architecture) and latest Intel GPUs, not for AMD/ATI GPUs. But yes..I guess everyone will sooner or later move to the same model. Marco  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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 
From: PeterPike Sloan <ppsloan@wi...>  20080212 23:21:48
Attachments:
Message as HTML

I wouldn't call it (recent ATI) a scalar architecture, it's more like a VLIW architecture, where you explicitly schedule the various slots. PeterPike From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Emil Persson Sent: Tuesday, February 12, 2008 1:37 PM To: 'Game Development Algorithms' Subject: Re: [Algorithms] Dummie Matrix math questions I wrote that document, and either you're reading it wrong or you misunderstood what Jon and Marco said. The HD 2000 series is a scalar architecture, hence it's not necessary to vectorize code like you would on R520 or G70, however, it's parallel rather than serial. The important thing is to parallelize the code so that each scalar instruction can be issued into a separate slot. Since vectorized code is by nature also parallel it will run fast, so vectorized code is not a bad thing. But unlike earlier generations parallel code that's not vectorized also runs fast since all parallel scalars can be computed in parallel. What doesn't run fast is serial scalar dependencies since these lead to poor utilization of the shader cores. In average shaders this is not so much of a problem, but you could construct pathological cases where utilization would be 1/5 of the maximum throughput. To parallelize your code it's recommended that you use parentheses to break up long lines since HLSL evaluates expressions from left to right, just like C/C++. So A+B+C+D is computed as ((A+B)+C)+D, whereas (A+B)+(C+D) could run in one instruction less (assuming all are scalars). Emil ________________________________ From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Jesús de Santos García Sent: Tuesday, February 12, 2008 2:47 PM To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions The same is true for ATI too as described in the ATI HD2000 Programming Guide. Nonvectorized code is optimized and it is recommended for cases where vectorial instructions are not needed. http://ati.amd.com/developer/SDK/AMD_SDK_Samples_May2007/Documentations/ATI_Radeon_HD_2000_programming_guide.pdf Good to know that nvidia and intel are using the same architecture. On Feb 8, 2008 7:34 PM, Marco Salvi <marcotti@...<mailto:marcotti@...>> wrote: On Feb 8, 2008 9:42 AM, Jon Watte <hplus@...<mailto:hplus@...>> wrote: I'm told that the implementation of modern 4way SIMD on graphics cards is now done as serial instructions, so there's little benefit to be had compared to just coding it out. This is true for NVIDIA (G8x architecture) and latest Intel GPUs, not for AMD/ATI GPUs. But yes..I guess everyone will sooner or later move to the same model. Marco  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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@...<mailto:GDAlgorithmslist@...> https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 
From: Emil Persson <humus@co...>  20080213 17:46:01
Attachments:
Message as HTML

Well, the shader cores are not vectors but scalar units, so calling it a scalar architecture makes perfect sense. Although VLIW would also be a valid description of it, if you prefer that. Personally Im no big fan of the VLIW nomenclature since I suppose its rather subjective at which point an instruction word becomes very long and it says little about the flexibility of the underlying hardware. I wouldnt be surprised if the G80s instruction words are very long too. Emil _____ From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of PeterPike Sloan Sent: Wednesday, February 13, 2008 12:22 AM To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions I wouldnt call it (recent ATI) a scalar architecture, its more like a VLIW architecture, where you explicitly schedule the various slots. PeterPike From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Emil Persson Sent: Tuesday, February 12, 2008 1:37 PM To: 'Game Development Algorithms' Subject: Re: [Algorithms] Dummie Matrix math questions I wrote that document, and either youre reading it wrong or you misunderstood what Jon and Marco said. The HD 2000 series is a scalar architecture, hence its not necessary to vectorize code like you would on R520 or G70, however, its parallel rather than serial. The important thing is to parallelize the code so that each scalar instruction can be issued into a separate slot. Since vectorized code is by nature also parallel it will run fast, so vectorized code is not a bad thing. But unlike earlier generations parallel code thats not vectorized also runs fast since all parallel scalars can be computed in parallel. What doesnt run fast is serial scalar dependencies since these lead to poor utilization of the shader cores. In average shaders this is not so much of a problem, but you could construct pathological cases where utilization would be 1/5 of the maximum throughput. To parallelize your code its recommended that you use parentheses to break up long lines since HLSL evaluates expressions from left to right, just like C/C++. So A+B+C+D is computed as ((A+B)+C)+D, whereas (A+B)+(C+D) could run in one instruction less (assuming all are scalars). Emil _____ From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Jesús de Santos García Sent: Tuesday, February 12, 2008 2:47 PM To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions The same is true for ATI too as described in the ATI HD2000 Programming Guide. Nonvectorized code is optimized and it is recommended for cases where vectorial instructions are not needed. http://ati.amd.com/developer/SDK/AMD_SDK_Samples_May2007/Documentations/ATI_ Radeon_HD_2000_programming_guide.pdf Good to know that nvidia and intel are using the same architecture. On Feb 8, 2008 7:34 PM, Marco Salvi <marcotti@...> wrote: On Feb 8, 2008 9:42 AM, Jon Watte <hplus@...> wrote: I'm told that the implementation of modern 4way SIMD on graphics cards is now done as serial instructions, so there's little benefit to be had compared to just coding it out. This is true for NVIDIA (G8x architecture) and latest Intel GPUs, not for AMD/ATI GPUs. But yes..I guess everyone will sooner or later move to the same model. Marco  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/ _______________________________________________ GDAlgorithmslist mailing list GDAlgorithmslist@... https://lists.sourceforge.net/lists/listinfo/gdalgorithmslist Archives: http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithmslist 
From: Marco Salvi <marcotti@gm...>  20080214 18:39:09
Attachments:
Message as HTML

Umh..I can see your point and I can partially agree with it, but it's unlikely that G8x's instructions words are as long as R6xx. I don't see why G8x couldn't efficiently work using far less instruction bandwidth than R6xx, even taking in consideration the fact that G8x's ALUs are kind of 'double pumped'. Terminology aside, I wouldn't be surprised if next architectures from AMD will be more similar to G8x than vice versa, as it makes compilers job so much easier. Marco On Wed, Feb 13, 2008 at 9:45 AM, Emil Persson <humus@...> wrote: > Well, the shader cores are not vectors but scalar units, so calling it a > scalar architecture makes perfect sense. Although VLIW would also be a valid > description of it, if you prefer that. Personally I'm no big fan of the > "VLIW" nomenclature since I suppose it's rather subjective at which point an > instruction word becomes "very long" and it says little about the > flexibility of the underlying hardware. I wouldn't be surprised if the G80's > instruction words are "very long" too. > > > > Emil > > > 
From: PeterPike Sloan <ppsloan@wi...>  20080214 19:36:05
Attachments:
Message as HTML

There are other tradeoffs that you are ignoring though. For a given number of ALU's the amount of "state" (register primarily, but this would also interact with interstage buffering) is clearly going to be greater in the G8x architecture (given number of ALU's has to deal with roughly 5x the number of "threads"...) I think both architectures are interesting. PeterPike Sloan From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Marco Salvi Sent: Thursday, February 14, 2008 10:39 AM To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions Umh..I can see your point and I can partially agree with it, but it's unlikely that G8x's instructions words are as long as R6xx. I don't see why G8x couldn't efficiently work using far less instruction bandwidth than R6xx, even taking in consideration the fact that G8x's ALUs are kind of 'double pumped'. Terminology aside, I wouldn't be surprised if next architectures from AMD will be more similar to G8x than vice versa, as it makes compilers job so much easier. Marco On Wed, Feb 13, 2008 at 9:45 AM, Emil Persson <humus@...<mailto:humus@...>> wrote: Well, the shader cores are not vectors but scalar units, so calling it a scalar architecture makes perfect sense. Although VLIW would also be a valid description of it, if you prefer that. Personally I'm no big fan of the "VLIW" nomenclature since I suppose it's rather subjective at which point an instruction word becomes "very long" and it says little about the flexibility of the underlying hardware. I wouldn't be surprised if the G80's instruction words are "very long" too. Emil 
From: Emil Persson <humus@co...>  20080214 20:27:10
Attachments:
Message as HTML

> Umh..I can see your point and I can partially agree with it, but it's unlikely that G8x's instructions words are as long as R6xx. Sure. I didn't say they are. I'm just nitpicking on the meaning of VLIW. Emil _____ From: gdalgorithmslistbounces@... [mailto:gdalgorithmslistbounces@...] On Behalf Of Marco Salvi Sent: Thursday, February 14, 2008 7:39 PM To: Game Development Algorithms Subject: Re: [Algorithms] Dummie Matrix math questions Umh..I can see your point and I can partially agree with it, but it's unlikely that G8x's instructions words are as long as R6xx. I don't see why G8x couldn't efficiently work using far less instruction bandwidth than R6xx, even taking in consideration the fact that G8x's ALUs are kind of 'double pumped'. Terminology aside, I wouldn't be surprised if next architectures from AMD will be more similar to G8x than vice versa, as it makes compilers job so much easier. Marco On Wed, Feb 13, 2008 at 9:45 AM, Emil Persson <humus@...> wrote: Well, the shader cores are not vectors but scalar units, so calling it a scalar architecture makes perfect sense. Although VLIW would also be a valid description of it, if you prefer that. Personally I'm no big fan of the "VLIW" nomenclature since I suppose it's rather subjective at which point an instruction word becomes "very long" and it says little about the flexibility of the underlying hardware. I wouldn't be surprised if the G80's instruction words are "very long" too. Emil 
From: Aras Pranckevicius <aras@un...>  20080208 11:11:19

> http://www.toymaker.info/Games/html/camera.html > 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? That tutorial explains "how to get axis vectors and position from a matrix that is inverted". If you think about a camera as a regular object, then camera's matrix (cameratoworld) has a matrix just like any other object. In D3D's notation, first three rows are axes, 4th row is the position. More here: http://arasp.info/texts/matrices.html A view matrix is NOT camera's matrix; a view matrix does the opposite transform (worldtocamera). Hence it's an inverted matrix of the camera. Now, an orthonormal camera can be inverted pretty easily; the rotation part just gets transposed, and the position part is "the negative dot product of the position and each of the axis vectors" (quoting your tutorial link).  Aras Pranckevicius work: http://unity3d.com home: http://arasp.info 