では傾斜した画像を表示させましたが、今回は文字列を傾斜させて表示させます。
StringOutlineというクラスを使用していますが、これは
で作成したものです。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
public partial class Form1 : Form { public Form1() { InitializeComponent(); ShowLabel(); outline = new StringOutline("あいうえお"); } StringOutline outline = null; private void glControlEx1_Paint(object sender, PaintEventArgs e) { GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // 視点を変更する SetSight(EyeX, EyeY, EyeZ); GL.PushMatrix(); { GL.Translate(X, Y, Z); GL.Rotate(RotateX, 1, 0, 0); GL.Rotate(RotateY, 0, 1, 0); GL.Rotate(RotateZ, 0, 0, 1); DrawString(1.0, 0.03); } GL.PopMatrix(); Lighting(); glControl.SwapBuffers(); } void DrawString(double size, double thickness) { List<List<Point>> outlines = outline.OutlinePoints; List<List<Point>> stringPoints = outline.StringPoints; int x = outline.MaxX / 2; int y = outline.MaxY / 2; GL.Normal3(Vector3.UnitX); GL.Material(MaterialFace.Front, MaterialParameter.Ambient, Color.Gray); double rate = size * 0.01; foreach(List<Point> pts in outlines) { GL.Begin(BeginMode.TriangleStrip); foreach(Point pt in pts) { GL.Vertex3((pt.X - x) * rate, -(pt.Y - y) * rate, 0.0); GL.Vertex3((pt.X - x) * rate, -(pt.Y - y) * rate, thickness); } GL.End(); } GL.Material(MaterialFace.Front, MaterialParameter.Ambient, Color.Gray); GL.Normal3(Vector3.UnitZ); double rate2 = rate / 2; foreach(List<Point> pts in stringPoints) { foreach(Point pt in pts) { GL.Begin(BeginMode.TriangleStrip); GL.Vertex3((pt.X - x) * rate + rate2, -(pt.Y - y) * rate + rate2, thickness); GL.Vertex3((pt.X - x) * rate + rate2, -(pt.Y - y) * rate - rate2, thickness); GL.Vertex3((pt.X - x) * rate - rate2, -(pt.Y - y) * rate + rate2, thickness); GL.Vertex3((pt.X - x) * rate - rate2, -(pt.Y - y) * rate - rate2, thickness); GL.End(); } } } } |