Microsoft.DirectX.Direct3D
およびを使用しMicrosoft.DirectX
て、一部のデータを 3D でレンダリングしています。
ここで、スペース内の高さの値を示すテキストを描画したいと思います。下の図のように:
今、私は2つの主な問題に直面しています:
問題 1: ご覧のとおり、描画テキストが上下逆に設定されています。正しく表示するにはどうすればよいですか?
問題 2:Direct3DXException
画面を回転しようとするとエラーが発生します。以下のようなエラーメッセージ:
以下は、クラスをDrawText()
使用するための私のコードですSprite
Microsoft.DirectX.Direct3D Device = new Device(0, DeviceType.Hardware, this.panel1,
CreateFlags.HardwareVertexProcessing, presentationParameters);
private void Render()
{
device.BeginScene();
if(checkBox1.checked)
{
DrawText();
}
device.EndScene();
device.SetTexture(0, null);
device.Present();
}
private void DrawText()
{
Sprite fontsprite = new Sprite(device);
fontsprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.ObjectSpace);
_font = new Microsoft.DirectX.Direct3D.Font(device, 10, 10, FontWeight.Bold, 1, false, CharacterSet.Ansi, Precision.Default, FontQuality.ClearType, PitchAndFamily.DefaultPitch, "face1");
_font.DrawText(fontsprite, "1.5 Km", 120, 15, Color.Black);
_font.DrawText(fontsprite, "2.5 Km", 120, 25, Color.Black);
_font.DrawText(fontsprite, "3.5 Km", 120, 35, Color.Black);
fontsprite.Transform.Translate(120, 100, 100);
fontsprite.End();
}
問題 1 と問題 2 の解決に助けが必要です。ありがとうございます。
更新:問題 1 は自分で解決しました。問題2だけを残しました。
問題 1 を解決するコード:
fontsprite.Transform = Matrix.RotationZ((float)Math.PI);
fontsprite.Transform *= Matrix.Translation(heightBoxSize, heightValue, heightBoxSize);
fontsprite.Transform.Translate(100, 100, 100);