Before you jump the gun:
1/ yes, I know the Autodesk.Navisworks.Api.Graphics class does not directly support rendering texts in 3D
2/ yes, implementing such rendering will probably push Navisworks near the edge (pun intended)
However our Render Plugin already render thousands of semi-complex objects without Navisworks sweating too much, so a few hundreds extra calls to Graphics class should be OK 😉
So now back to the question 😉
Did anyone already tried/managed to achieve such feat before I start and enter this expected to be very long tunnel?
If not, does anyone have experience/examples of using the following sets of Graphics methods, since these are quite mysterious at first sight but maybe can be used to at least draw a simplified text outline:
g.Color(textColor, 1.0);
//One of these 3:
g.BeginComplexPolygon(VertexProperties vertexProperties);
g.BeginComplexPolygonContour();
g.BeginPolygon(VertexProperties vertexProperties);
// set Winding rule?
g.PolygonTessellationWindingRule = TessellationWindingRule.Odd;
//Repeat this one?
//Need to finish with same as starting point?
g.Vertex(Point3D coordinate);
//One of these 3:
// hoping
g.EndComplexPolygon();
g.EndComplexPolygonContour();
g.EndPolygon();
Thanks in advance.
Solved! Go to Solution.
Solved by lanneauolivier. Go to Solution.
Hey,
Rendering 3D text is not so hard. You have to save your 2D text as Bitmap first then render it as a polygon.
// init
Bitmap bitmapText = new Bitmap() ... // render your text on the bitmap
int bitmapIndex = Autodesk.Navisworks.Api.Application.RegistrerBitmap(bitmapText); // save the bitmap
// in the rendering loop
graphics.BeginPolygon(VertexProperties.HasTextureCoordinates);
graphics.SetTexture(bitmapIndex);
// foreach corner A, B, C & D of your 3D text rectangle add thoses 2 lines
graphics.TextureCoordinate(new Point2D(1, 1)); // means the upper right corner of your 2D bitmap
graphics.Vertex(A); // means the upper right corner of your 3D rectangle
graphics.EndPolygon();
graphics.SetTexture(-1);
It works well, I used it to render QRcode on a face in the model.
Hi Alexis,
Rendering texts in 3D is entirely possible. Due to the policy of my company, I can't show you too much, but I can show you my result.
My implementation is inspired by this post, which I believe all of us have read at sometime in the past:
https://adndevblog.typepad.com/aec/2014/09/draw-text-graphics.html
Hope this can help you in a sense.
Instead of just text outlines, I can now render fully solid texts.
This is accomplished with ComplexPolygon and ComplexPolygonContour.
ComplexPolygon: Draws solid polygons.
ComplexPolygonContour: Forms holes in polygons.