开发者

Write 3D text in XNA

开发者 https://www.devze.com 2023-03-28 12:15 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消