Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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();

  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...