how to display text

To display text on a 3D plane and place the text exactly in the plane. If the plane is rotated, the text is expected to be always in the plane. I try to use "ISession_Text". The text could be displayed. However, when rotated its underlying plane, the text is always facing to the viewport. Please advise!

EricThompson's picture

I can think of two possible approaches:

1) Create a bitmap from the text you want to draw, then texture-map that bitmap onto a planar shape. I have never tried texture-mapping in OpenCascade.

2) Draw the text using OpenGL instead of OpenCascade, creating an outline font and applying a transform to it to rotate it to the desired plane. I have used this technique to create scaleable text, but have not tried other rotations.

Francois Lauzon's picture

We have been using the MFT framework for some time now. I have subclass MFT_TextManager for the following methods:

virtual void BeginString(const Quantity_Length X,const Quantity_Length Y,const Quantity_PlaneAngle anOrientation,const Quantity_Length aWidth,const Quantity_Length aHeight,const Quantity_PlaneAngle aSlant,const Standard_Integer aPaintType) ;
virtual Standard_Boolean BeginChar(const Standard_Integer aCharCode,const Quantity_Length X,const Quantity_Length Y) ;
virtual Standard_Boolean SetCharBoundingBox(const Quantity_Length X1,const Quantity_Length Y1,const Quantity_Length X2,const Quantity_Length Y2,const Quantity_Length X3,const Quantity_Length Y3,const Quantity_Length X4,const Quantity_Length Y4) ;
virtual Standard_Boolean SetCharEncoding(const Standard_CString anEncoding);
virtual Standard_Boolean Moveto(const Quantity_Length X,const Quantity_Length Y);
virtual Standard_Boolean Lineto(const Quantity_Length X,const Quantity_Length Y);
virtual Standard_Boolean Curveto(const Quantity_Length X1,const Quantity_Length Y1,const Quantity_Length X2,const Quantity_Length Y2,const Quantity_Length X3,const Quantity_Length Y3,const Quantity_Length X4,const Quantity_Length Y4) ;
virtual void ClosePath();
virtual Standard_Boolean EndChar(const Quantity_Length X,const Quantity_Length Y);
virtual void EndString();

And I managed to build 2d geom curves this way. From those curve you could easily build 3d curves onto a plane. You are limited to the Open Cascade *.mft font, build it is fine for our need.

Best regards,
Francois.