first person mesh placment

Started by
3 comments, last by ET3D 17 years, 11 months ago
im creating a 3D first person networked game, my problem is how do I get the meshes to face the same direction as the camera, as in if im in the game and there is another player in and there moving forward how do I make sure that the mesh that represents them is facing the right direction. im using C# and directX 9 april update...
Advertisement
Smacker,

You can store the angle about the vertical axis which they are facing. That is, if I'm using a left-handed coordinate system and my character is facing down the world Z axis (90deg about Y) and I rotate to my left, I'm now facing, lets say, 45 degrees left of the z-axis(135deg about Y).

You can build a rotation matrix from the Euler angle. You can then use this rotation matrix to transform the character into his rotated position. Keep in mind that this rotation needs to be performed in local space, not world space. So remember to transform the model before putting him in world space.

Cheers and good luck!
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
Chronicles of Elyria (An In-development MMORPG)
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints
now seeing that im sending the clients camera lookat position, and the camera eye location, couldent I just use the cameras lookat position vector3?

and also how do I go about seting the rotation before the world transform

right now im using

dev.Transform.World = Matrix.Transformation(ect...);
also what rotation matrix would I use the objects that im moving are space ships, so I was using RotationYawPitchRoll but this is not working here is what I have done

ma.Transform(new Vector3(), Quaternion.Identity, new Vector3(.3f,.3f,.3f), new Vector3(), Quaternion.RotationMatrix(Matrix.RotationYawPitchRoll(d_point.Y, d_point.X, 0.0f)) ,b_point);

then place it in the world

Device.Transform.World = ma;
then I draw the mesh...
Use the inverse of your view transform. In the other player's view, the entire world is moved to be in his own coordinate system. In this player, the other player needs to be move. So seems to me it's the inverse of the transform.

This topic is closed to new replies.

Advertisement