question

Luciano Cavallero avatar image
2 Likes"
Luciano Cavallero asked Luciano Cavallero commented

draw text in 3d view

Hi,

I need to draw a lot of text into a 3d view into a drawtrigger. Using multiple call to "drawtext" command take a lot of time.
There are other way like opengl or mesh api?

Thanks

Luciano

FlexSim 19.0.4
drawingdraw opengl
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Luciano Cavallero commented

Yes, drawtext() has quite slow performance. It is designed to be flexible and easy, not fast.

If you are drawing static text that doesn't change very much (such as real words instead of variable number values), then you could create the text in a 3D modeling software, such as AC3D, and import entire strings of 3D text as shapes. Rendering an entire static string of text as a 3D shape is fast.

If you are trying to optimize for performance, I'd suggest doing that for as much text as you can and only using drawtext() for text that you know changes frequently and unpredictably (such as numbers).

In 19.2, we added a C++ class called a TextMesh that we use for rendering text very quickly. It generates a texture atlas for its characters within a single texture and then uses texture coordinates for mapping each character to its location in the texture atlas.

We added it so that we could render dynamic text such as label values on Rack slots very quickly:

We didn't make the TextMesh accessible in FlexScript, but in 19.2, you should be able to use it in C++ code, such as in the Module SDK.


text-mesh.png (1.5 MiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Luciano Cavallero avatar image Luciano Cavallero commented ·

Hi Phil,

Ok, I agree that drawtext() is designed to be flexible and easy.
I could try to use a 3d shape.
For the TextMesh I'll wait a future FlexScript version because in my library I trying use onyl FS.

Thanks

Luciano

0 Likes 0 ·