bitem2k Posted July 15, 2005 Posted July 15, 2005 Hi ! Does any one know how I can make a mesh look in the direction im walking. I want it to face a given Vector. thanks ! Quote
Leaders Iceplug Posted July 15, 2005 Leaders Posted July 15, 2005 If I'm not mistaken, you have to transform the world by way of rotations and translations to move your mesh and make it face. First, you apply the rotation to make it face in a direction, and then you translate the world so that your mesh will be located in the proper location when you draw it. If you want it to a face a given vector, then you have to define where the vector comes from. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
bitem2k Posted July 16, 2005 Author Posted July 16, 2005 thanks for your reply. I have no problem with making my mesh face the direction by rotating it. I use the Matrix m31 m32 m33 values after applying the transform to retrieve the look at vector, however i dont know how to make it face just by giving a vector. if you want it to a face a given vector, then you have to define where the vector comes from. Sorry i dont know what you mean, could you elaborate on this at all? cheers Quote
Leaders Iceplug Posted July 18, 2005 Leaders Posted July 18, 2005 By "face a vector", I assume that the vector is referring to a point in space. This means you also need the location of what it will be looking at. However, if you are using the vector for a direction only, then you use the arctangent function to get the angle of this vector: ang = Math.Atan2(vec.y, vec.x) then, you apply a rotation transform to the world matrix with this angle (or its negative, depending on your needs) and then draw the mesh (assuming the mesh untransformed faces the 0° direction... if not, you may have to negate the angle and add 90° or maybe subtract...) . :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
bitem2k Posted July 19, 2005 Author Posted July 19, 2005 ang = Math.Atan2(vec.y, vec.x) then, you apply a rotation transform to the world matrix with this angle (or its negative, depending on your needs) and then draw the mesh (assuming the mesh untransformed faces the 0° direction... if not, you may have to negate the angle and add 90° or maybe subtract...) . :) Nice one! Ill give that a try. Thankyou very much for your help! Quote
Knight Chat X Posted August 5, 2005 Posted August 5, 2005 You can also simply use degree's, such as 60, 90, 180, etc.. Quote
Leaders Iceplug Posted August 12, 2005 Leaders Posted August 12, 2005 That's what the Math.Atan2 function is supposed to do... return the angle that straight head is at. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.