Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

3D Text

Started by betaisao Aug 9, 2006 at 11:40 PM 2 replies 550+ views
Original Post
betaisao
betaisao
How to write a 3D text string in an arbitrary size and direction quickly? I used transform methods like scale, rot, but it slowed down my system seriously. I want to draw 3D co-ordinate with numbers attached to the axis. dev.Material = meshMaterial; tmp = dev.Transform.World; xvalue = 0; yvalue = 0; zvalue = 0; xdiv = 1; ydiv = 1; zdiv = 1; Mesh mx, my, mz; for (int i = 0; i <= div; i++) { mx = Mesh.TextFromFont(dev, localFont, xvalue.ToString(), 0.001f, 0.0f); dev.Transform.World = Matrix.RotationZ((float)Math.PI / 2) * setAxisTransformMatrix(xaxis); mx.DrawSubset(0); xvalue += xdiv; my = Mesh.TextFromFont(dev, localFont, yvalue.ToString(), 0.001f, 0.0f); dev.Transform.World = setAxisTransformMatrix(yaxis); my.DrawSubset(0); yvalue += ydiv; mz = Mesh.TextFromFont(dev, localFont, zvalue.ToString(), 0.001f, 0.0f); dev.Transform.World = setAxisTransformMatrix(zaxis);//Matrix.RotationX((float)(Math.PI / 2)) * mz.DrawSubset(0); zvalue += zdiv; } dev.Transform.World = tmp; Thanks
Evil Steve
Evil Steve
DrawSubset calls DrawIndexedPrimtive internally, and you want to cut those calls to an absolute minimum. 500 per frame will completely destroy your frame rate.
So, you should be using a dynamic vertex buffer and filling it with data once, then rendering all of your text in one call.

How is your text handled? Are all letters completely independant of each other, or are you rendering a string of text, where all letters are in a row?
betaisao
betaisao
Unfortunately, they are all independent. Each of them is rendered to different positions. Is dynamic vertex buffer useful in this situation? I'll try it anyway. Thanks.
Evil Steve
Evil Steve
Yes, definitely. Using meshes like this is not a good idea. Meshes are really designed to have only a few onscreen, certainly not 3 per letter like you seem to be doing.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.