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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With