Hello,
I can't figure out how to position my font in 3d space. I have drawn an axis in 3d space, it's a simple line.
Vertex[] vertex = new Vertex[2];
vertex[0].Position = new Vector3(0, 0, 0);
vertex[0].Color = Colors["axis_x"].ToArgb();
vertex[1].Position = new Vector3(1, 0, 0);
vertex[1].Color = Colors["axis_x"].ToArgb();
Device.DrawUserPrimitives<Vertex>(PrimitiveType.LineList, 1, vertex);
Now, I would like to draw a "X" at the end of the axis (line). But I need the exact pixel position if I do it this way.
Sprite fontSprite = new Sprite(Device);
SlimDX.Direct3D9.Font font = new SlimDX.Direct3D9.Font(Device, 12, 0, SlimDX.Direct3D9.FontWeight.Normal, 0, false, CharacterSet.Default, Precision.Default, FontQuality.ClearTypeNatural, PitchAndFamily.DontCare, "tahoma");
fontSprite.Begin(SpriteFlags.AlphaBlend);
fontSprite.Transform = Matrix.Translation((float) 100, (float) 30, (float) 0);
font.DrawString(fontSprite, "X", 0, 0, new Color4(Colors["axis_x"].ToArgb()));
fontSprite.End();
It's a little bit confusing for me, that the translation needs pixels instead of 3d units?! Is there a simpel way to get the pixel position? Or should I do it not this way? Propably there is a simple way to do this, but I'm relatively new to DirectX :-(
Thanks for some ideas!
Bye,
Martin