Reidar Lange Posted October 31, 2004 Posted October 31, 2004 Does anyone know how to control the size of the resulting mesh when you use Mesh.TextFromFont(). System.Drawing.Font font = new System.Drawing.Font("Arial",1.0f,GraphicsUnit.Millimeter); GlyphMetricsFloat [] glyph = new GlyphMetricsFloat[1]; Mesh m = Mesh.TextFromFont(device,font,"8",1f,0.1f,ref glyph); Setting the font size does not change anything. One solution would be to aply scaling to the world transform before rendering, but that has a tendency to do strange things with 3d lighting. Quote
Reidar Lange Posted October 31, 2004 Author Posted October 31, 2004 Found a solution! The following code creates a 0-digit mesh and scales all vertixes down by 50% Mesh m = Mesh.TextFromFont(device,font,"0",1f,0.1f,ref glyph); int [] ranks = new int[1]; ranks[0] = m.NumberVertices; System.Array arr = m.VertexBuffer.Lock(0,typeof(CustomVertex.PositionNormal),LockFlags.None,ranks); for(int i=0;i<arr.Length;i++) { Direct3D.CustomVertex.PositionNormal pn = (CustomVertex.PositionNormal)arr.GetValue(i); pn.X *= 0.5f; pn.Y *= 0.5f; pn.Z *= 0.5f; arr.SetValue(pn,i); } m.VertexBuffer.Unlock(); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.