Zorbfish 214 Report post Posted January 22, 2004 Background: I''ve searched and tested this for awhile and haven''t gotten anywhere. I''m using indexed triangle lists and a left hand orthogonal projection, which is different from most articles I''ve read (I didn''t think it would matter though). I''m using the usual vertice setup 0 1 |------| Indice setup 0, 1, 2, 1, 2, 3 | / | | / | | / | | / | |------| 2 3 I''ve tried the the formulas provided in Focus on 2D in 3D example 7.01 and it didn''t work. The closest I''ve gotten to rotating the quad was with Eamonn Doherty''s rotation formulas. Rotations about the Z axis were correct for angles 0, 90, 180,and 270. But I''m afraid the other angles of rotation seemed to rotate the quad along the lines x = y,and x = -y. If anyone could help with the formulas (no you don''t have to give them to me, even a helpful hint in the right direction is appreciated). 0 Share this post Link to post Share on other sites

circlesoft 1178 Report post Posted January 22, 2004 When you say manual rotation, do you mean without the use of matrices? If you can use them, it would make it a lot easier 0 Share this post Link to post Share on other sites

glassJAw 128 Report post Posted January 22, 2004 <SPAN CLASS=smallfont>quote:Original post by Zorbfish Background: I've searched and tested this for awhile and haven't gotten anywhere. I'm using indexed triangle lists and a left hand orthogonal projection, which is different from most articles I've read (I didn't think it would matter though). I'm using the usual vertice setup0 1|------| Indice setup 0, 1, 2, 1, 2, 3| / || / || / || / ||------|2 3I've tried the the formulas provided in Focus on 2D in 3D example 7.01 and it didn't work.The closest I've gotten to rotating the quad was with Eamonn Doherty's rotation formulas. Rotations about the Z axis were correct for angles 0, 90, 180,and 270. But I'm afraid the other angles of rotation seemed to rotate the quad along the lines x = y,and x = -y.If anyone could help with the formulas (no you don't have to give them to me, even a helpful hint in the right direction is appreciated). </SPAN>Hmm.. in my quad rotation code, I used a different vertex setup:0 1|------| | / || / || / || / ||------|3 2 The code works well enough for me (it seems to go off by a pixel occasionally, but that's probably because of rounding errors introduced by the flooring that occurs in the float->int conversion).The basic idea behind the rotation is pretty easy. You'll probably be able to come up with a much better implementation than mine.- Translate the vertices so the origin is at the desired point of rotation relative to the vertices- Apply the following formulas to the coordinates of each vertex:x = x * cos(r) - y * sin(r)y = x * sin(r) + y * cos(r)- Translate the vertices back so the original point of rotation is restoredYou've probably found this formula already, but maybe your implementation didn't work? Make sure there is no off-by-1 error introduced early in the formula. This happened to me on my first few attempts at rotation, and it really threw the whole thing off.[Edited by - glassJAw on October 21, 2009 10:02:52 AM] 0 Share this post Link to post Share on other sites

Zorbfish 214 Report post Posted January 22, 2004 Ugh, thanks Eamonn I found the problem. I had:y = x * sin(r) - y * cos(r) 0 Share this post Link to post Share on other sites

Zorbfish 214 Report post Posted January 25, 2004 Is there anyway to correctly rotate without centering the primitives at the origin first, then translating it back? 0 Share this post Link to post Share on other sites

Supernat02 604 Report post Posted January 25, 2004 Off the top of my head, you could save one step by just centering the mesh at the origin in the vertex buffer when you create it. Then you could always just perform a rotation and then translate it...without having to put it at the origin every rotation.Good luck,Chris 0 Share this post Link to post Share on other sites

Zorbfish 214 Report post Posted January 26, 2004 But I''d like to not have to center it at the origin first :/ seems like an unecessary step if I don''t need to do it. 0 Share this post Link to post Share on other sites