ageny6 122 Report post Posted November 4, 2002 I wasn''t sure where to post this message (in Math or Graphics Programming), so I''ll try here! Okay, heres the deal! Using a point array, transforming and displaying the data perspectively is a joke (at least now it is...for me). but there is a problem, and my joke falls flat! Let''s say for example that I have a nice 20 point grid projected perspectively. Great! Now, I can translate the grid it using X,Y 2D coordinates, but this produces a unrealitic movement (almost like we are moving a picture), and the perspective effect is lost in the process I have seen many 3D programs (such as Inventor, or Mechanical Desktop, or TrueSpace, etc...) that transform the point array as your translate the "grid" (the grid being the example above). That is, when you translate, hidden faces start to appear and others hide. It''s kinda like looking at your CPU screen. When you look at the left of it, you don''t see the right side, and vice versa. But when I translate using the 2D X,Y, this effect is not generated. The problem with this is obvious, the games that I make look REALLY bad! So, mathematically, how do you generate a transformation matrix to take into account the effect described above. Thanks Jonathan 0 Share this post Link to post Share on other sites

Yann L 1802 Report post Posted November 4, 2002 If you want perspective taken into account while moving around, you''ll have to translate the 3D data before it is projected. Moving it around after projection is as if you were moving a 2D sprite around: perspective information is lost.3D translation is easy: just add/substract the amount of translation from your original (x,y,z) data, and project then. Either do that by hand, or create a transformation matrix. The later approach is used by all major 3D APIs, and is the recommended way. A single matrix represents scaling, translation and rotation in any combination. After transforming your points (multiplying them with the matrix) you project them, resulting in the correct 3D effect./ Yann 0 Share this post Link to post Share on other sites

ageny6 122 Report post Posted November 5, 2002 That''s interresting,You see, that was my first instinct, but when I did so the results did not work. I am wondering if the order at which I multiply my matrices together is affecting the results. Does order matter?If you want a example of my matrix multiplication, here is what I did:-Calculate the projector_angle matrix (using eye location, focus point etc...)-scale the matrix-translate the matrix by Xmove, Ymove, Zmove -multiply the scale and the translate matrix together, resulting in matrix ST (for scale_translate)-multiply the projector_angle matrix and the ST matrix together, resulting in the PM matrix (for Projection_matrix)-multiply the point array to the PM matrix-draw points.Does this order work correctly?Thanks Jonathan 0 Share this post Link to post Share on other sites

Yann L 1802 Report post Posted November 5, 2002 quote:You see, that was my first instinct, but when I did so the results did not work. I am wondering if the order at which I multiply my matrices together is affecting the results. Does order matter? Absolutely. A*B will yield a different result from B*A.Your basic steps are correct: create projection, translation and scale matrix (and rotation if you want), and then multiply them all together to get your final transformation matrix (by which your points will be multiplied). But the order in which you multiply the matrices together is crucial, you might get bad surprises if you make a mistake here.quote:Does this order work correctly? It depends on what do you want to achieve. Should the scaling come before the translation, or after ? Both will work, but your translation units will vary (they will be relative to the scale in the former case, and absolute in the later one). The order in which you multiply the translation and scale matrix will make the difference.It also depends on your internal matrix representation, column-major or row-major. Changing representation (transposing your matrix) will invert the multiplication order you need.Perhaps you should take a look at a good matrix math tutorial. I think there are a few good ones here at GDNet. Let me check... Yes, here.. It is better, if you really understand the principles behind matrix math (it isn't that difficult), than having someone giving you the right order, without you understanding why. A simple little change in your code might need a new matrix ordering, and you'll be stuck again.../ Yann[edited by - Yann L on November 5, 2002 11:48:07 PM] 0 Share this post Link to post Share on other sites