Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QGLWidget - Cross section of 3-D hollow objects

I'm using QGLWidget to draw 3-D objects, the input to my program is the faces of the shapes.

Meaning that when I want to draw a cube, I got list of 6 elements each one represent a face and each face contain 4 points, (x,y,z) for each point.

The drawing is done, but I'm trying to implement a cross section feature, so far the result shape after the cross section is a hollow objects, How Can I get the cross section results as if the shapes were not hollowed?

like image 350
Mahmoud Hassan Avatar asked Oct 23 '13 12:10

Mahmoud Hassan


2 Answers

OpenGL doesn't know "objects". It doesn't know "solid" or "hollow". All OpenGL knows are points, lines and triangles. If you want to make your object appear solid, you'll have to calculate the geometry of the cut-away object, resulting in a new mesh, which you use as input data for drawing.

The cut-away process is part of a set of operations known as "boolean geometric operations" also coined "constructive solid geometry". If you Google for that, you'll find plenty of information.

like image 168
datenwolf Avatar answered Oct 13 '22 01:10

datenwolf


I believe what you are trying to achieve is some boolean operation on 2 geometry objects. For this purpose there is a perfect geometry library in Boost, and you need one of this algorithms: diff or intersection. Given the examples, it's easy to modify them for your specific object structure.

like image 22
yuyoyuppe Avatar answered Oct 13 '22 00:10

yuyoyuppe