-1

I have model soucast1.3DS If I open this model in CAD Autodesk Inventor it looks

model in Autodesk Inventor

if I use simple application using OpenGL it looks

model in OpenGL app

GL.Color3(Color.Aqua);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
DrawMatrix(); // draw model
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.Enable(EnableCap.PolygonOffsetLine);
GL.PolygonOffset(-1.0f, -1.0f);
GL.Color3(Color.Black);
DrawMatrix(); // draw model

so, my question is:

How can I get same result in my application (OpenGL) as you can see from Inventor? (Only edges of areas are black)

Martinxw
  • 7
  • 2
  • 1
    Similar to http://stackoverflow.com/questions/16997359/c-opengl-creating-glowing-lines/16998760#16998760 – dtech Sep 19 '13 at 09:04

2 Answers2

2

There are many approaches. You could use tricky shaders combination, stencil buffer or object scaling: Draw slightly scaled-up model with black color, dropping front faces (e.g. GL_CULL_FACE=GL_CW). Then draw normal model with correct scale and colors, dropping back faces (GL_CCW).

Not a perfect solution, usable for cartoon-like shading in games; may be too unprecise for CAD. If it isn't fit for you - google opengl edge outline.

To clarify things: 3D modeling software always have information about edges in addition to faces, so they can just draw edge lines after model is drawn, and you getting an outline. If you don't have edges (or, like in games - don't even want to have edges because of memory consumption and other issues) - you have to perform some form of edge detection or hack.

keltar
  • 17,711
  • 2
  • 37
  • 42
0

I solved it. Change model to STL (contains triangles and normals), found areas (compare of normals) and write algorithm to find border.

And result is: Opengl

Martinxw
  • 7
  • 2