Feb 7, 2013 at 9:53 AM
Edited Feb 7, 2013 at 9:54 AM
I have a project where I draw an image over one marker. I want that when I rotate the marker the image rotates with it. Say, I rotate the marker 90 degree the image also must turn 90 degree.
I tryed something like this but it doesn't work( the image keeps rotating 0-90)
StreamWriter sr = new StreamWriter("out.txt", true);
pers1.WorldTransformation.Decompose(out x, out outRotation, out y);
float a = x.X;
float b = x.Y;
scene.CameraNode.WorldTransformation.Decompose(out x, out outRotation, out y);
q = Math.Atan2(b - x.Y, a - x.X);
if (q != 0)
rotire = q;
sr.WriteLine("q= " + q);
coor2d = State.Device.Viewport.Project(
vect, // The 3D coordinates (Vector3) you want to project to screen space
State.ProjectionMatrix, // Projection matrix of your camera
Matrix.Identity, // View matrix of your camera (since ALVAR camera is located at 0,0,0 we can just pass Identity)
DrawImage(imagine, Convert.ToInt32(coor2d.X) - 50, Convert.ToInt32(coor2d.Y) - 50, rotire);
private void DrawImage(Texture2D nume_imagine, int x, int y, double q)
if (imagine != null)
//spriteBatch2.Draw(nume_imagine, new Rectangle(x, y, 100, 100), Color.White);
spriteBatch2.Draw(nume_imagine, new Vector2(x, y), null, Color.White, rotire, new Vector2(0, 0), new Vector2((float)(100) / (float)(nume_imagine.Width), (float)(100) / (float)(nume_imagine.Height)), SpriteEffects.None, 0);
//nume_imagine is the image name and rotire is the rotation angle.
Can someone help?