Write 3D text in XNA
I'd like to render three-dimensional text. In Managed DirectX, I'd use Mesh.TextFromFont to create a 3D mesh out out of a given string with a given font, e.g.
var myMesh = Mesh.TextFromFont(device, myFont, "Hello World!", 0, 3DwidthOf开发者_Python百科TheText)
However, this method no longer exists in XNA. Is there a replacement?
To do extruded 3D text in XNA, the best method - providing you know what fonts you need at build-time - is probably Nuclex.Fonts. It imports TrueType fonts via the content pipeline into a VectorFont
type (similar to SpriteFont
).
This page contains some pretty pictures and a brief tutorial.
(If you need to dynamically import fonts at runtime, then Nuclex might still be worth a look - it's possible it could be separated from the content pipeline.)
One possibility is to use RenderToTexture to render your text on a mesh and just place that mesh in the world.
精彩评论