• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

_walrus

Conversion between left and right handed coordinate systems

6 posts in this topic

Hi, I''m trying to convert my file format (kept in a left handed coordinate system) to render in opengl''s right handed coordiante system, where left hand Coordinate system defined as x, y, z where they point right, up and into the screen and right handed coordinate system defined as x,y, z where they point right, up and away from the screen respectively. Now technically could i multipy all z values by -1 and rotate by the negative amount? Suppose i have some transformations in my file and i want to convert this transformation from left hand to right hand. I dont think scaling it by [1 1 -1] and negating the z translation component works. does anybody know how to convert this properly. I think i''ve seen it on the forums before but the search isn''t working. Thanks for any help.
0

Share this post


Link to post
Share on other sites
Does this make any sence:

Let P be a point.
Let W be a transformation in left handed coordnate system.
Let S be a transformation that converts Point P from left to right coordinate systems.

Thus S = | 1 0 0 0 |
| 0 1 0 0 |
| 0 0 -1 0 |
| 0 0 0 1 |

So (P*W) *S = transformed point in right handed coordinate system.

since mutliplicative associativity holds between nxm matricies:

(P*W)*S = P (W*S)

So The product of W and S is W with the thrid column negated. Thus to transform from a transformation from left to right handed coordinate systems we can just negate it''s thrid column.

Is this correct?




0

Share this post


Link to post
Share on other sites
Does this make any sence:

Let P be a point.
Let W be a transformation in left handed coordnate system.
Let S be a transformation that converts Point P from left to right coordinate systems.

Thus S =
| 1 0 0 0 |
| 0 1 0 0 |
| 0 0 -1 0 |
| 0 0 0 1 |

So (P*W) *S = transformed point in right handed coordinate system.

since mutliplicative associativity holds between nxm matricies:

(P*W)*S = P (W*S)

So The product of W and S is W with the thrid column negated. Thus to transform from a transformation from left to right handed coordinate systems we can just negate it's thrid column.

Is this correct?



[edited by - _walrus on October 31, 2002 4:34:32 PM]

[edited by - _walrus on October 31, 2002 4:35:19 PM]

[edited by - _walrus on October 31, 2002 4:35:44 PM]
0

Share this post


Link to post
Share on other sites
Yep, that's correct. Just flip the sign of the third column (for column-major matrices; the third row for row-major matrices) and don't forget to change the winding of your triangles to counter-clockwise (or simply flip the culling mode).

[edited by - Asgard on November 1, 2002 10:43:35 AM]
0

Share this post


Link to post
Share on other sites
Great thanks Asgard,

The above method (scaling the thrid column) works on translations, but what about rotation components of the transformation? Rotating about the Z axis is the same for both coordinate system, but the rotations about the y and x axis are negated in the two systems. Will scaling the thrid column address this?
0

Share this post


Link to post
Share on other sites
I'm not sure if I understand your question correctly. Basically negating the third column negates the z coordinate of every vector you multiply with the matrix, which is exactly what is needed to convert a vector from left-handed to right-handed coordinates. It doesn't have anything to do with what kind of matrix that is.
Note that, if you have multiple matrices in your file format that might get concatenated somewhere (like a hierarchy with each node having its own matrix), then negating the third column in each of those matrices will not give the desired result (at least, if the number of concatenated matrices is even).
So in general, it's probably best to simply convert all the vertices in your file to right-handed coordinates by setting z' = -z for each vertex and not change any of your matrices. Another option would be to leave the vertices as they are and simply set a left-handed projection matrix when rendering with OpenGL.

[edited by - Asgard on November 1, 2002 4:22:09 PM]
0

Share this post


Link to post
Share on other sites
Hey, i guess what i mean can be best illustrated in an example:

suppose i have the following in my file (left handed system):



PUSH
TRANSFORMATION W
| -1 0 0 0 |
| 0 1 0 0 |
| 0 0 -1 0 |
| 0 0 0 1 | //where this row holds the translation components
POINTS [ vertex data for some points ]
POP




All points specified in between PUSH and POP will be affected by the TRANSFORMATION. We see that this transformation W will rotate the points 180 degrees about the y-axis.

Now we apply S to W to tranform to right handed coordinate system where S is

| 1 0 0 0 |
| 0 1 0 0 |
| 0 0 -1 0 |
| 0 0 0 1 |


This product yeilds a tranformation in right handed coordinate system:

| -1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| 0 0 0 1 | //where this row holds the translation


But is this correct? Since in the left handed system we are rotating points about the y-axis 180 degrees? This matrix does not rotate about y-axis 180 degrees.

Intuatively shouldn't we be rotating points about the y-axis at -180 degrees in the right handed system as follows:

in left handed system:

| cos(180) 0 0 0 |
| 0 0 0 0 |
| 0 0 cos(180) 0 |
| 0 0 0 0 |

so the equivalent transform in right handed system would be :
| cos(-180) 0 0 0 |
| 0 0 0 0 |
| 0 0 cos(-180) 0 |
| 0 0 0 0 |


Since cos(-180) = cos(180) we have the same matrix. Therefore using S to convert from one coordinate system to the other when rotation are involved is not adiquate.



I suppose i could tranform all points to get to them to world cooridinates and then apply S to each point, but I would really like to preseve the notaion of localized spaces in my system by transforming local points to right hand system by multipling by S and by converting Transformation by ???(by some process or by multiplying by some Transformation R). Any ideas or comments would be very helpful. Or does anyone know of documentation or books that illustrate how to do this? And thanks Asgard for your help so far.

[edited by - _walrus on November 2, 2002 1:48:06 PM]

[edited by - _walrus on November 2, 2002 1:50:23 PM]

[edited by - _walrus on November 2, 2002 1:55:44 PM]
0

Share this post


Link to post
Share on other sites