Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rendering texts in 3D in a RenderPlugin, graphics.BeginComplexPolygon etc.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
alexisDVJML
553 Views, 5 Replies

Rendering texts in 3D in a RenderPlugin, graphics.BeginComplexPolygon etc.

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.

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
5 REPLIES 5
Message 2 of 6

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.

Message 3 of 6

Excellent suggestion.
I had this in mind but was little bit worried of entering unknown territory 😉
Will give it a try soon!

Thanks again
Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
Message 4 of 6
cation234ctci
in reply to: alexisDVJML

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.

Message 5 of 6
cation234ctci
in reply to: alexisDVJML

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.

 

Message 6 of 6
alexisDVJML
in reply to: cation234ctci

Nice work, I still need to find time to work on this feature on our side...
Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report