-2

I am dealing with Constructive Solid Geometry(CSG) modeling with OpenGL.

I want to know how to implement binary operation. I read something about Gold Feather Algorithm and I know about OpenCSG but after reading its source code, I found it too complicated to understand. I just need a simple shortest OpenGL example how to implement it.

There's no restrict in Algorithm as long as it is easy to implement.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Ovilia
  • 7,066
  • 12
  • 47
  • 70

2 Answers2

7

OpenGL will not help you. OpenGL is a rendering library/API. It draws points, lines and triangles; it's up to you to tell it what to draw. OpenGL does not maintain a scene or even has a notion of coherent geometric objects. Hence CSG is not something that goes into OpenGL.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • I do have a CSG tree and corresponding data structure. But how can I render `intersection` if my data structure tell me to do so? – Ovilia Jun 04 '12 at 06:50
  • I think OpenGL can help, since OpenCSG is based on it. What I need is the algorithm easy to understand. – Ovilia Jun 25 '12 at 12:47
  • Down-voted not only because this answer is unhelpful, but also because there are rendering-oriented approaches to drawing the result of CSG operations; such approaches typically rely heavily on GPU (OpenGL or equivalent) code, so I find this answer misleading. –  May 31 '14 at 10:41
3

Nicol Bolas is correct - OpenGL will not help with CSG, it only provides a way to draw 3D things onto a 2D screen. OpenCSG is essentially "fake" CSG by using using OpenGL's depthbuffers, stencils and shaders to make it appear that 3D objects have had a boolean operation performed on them.

CSG is a huge task and I doubt you will ever find an "algorithm easy to understand" Have a look at this project: http://code.google.com/p/carve/ which performs CSG on the triangles/faces which you would then draw to OpenGL

sergeantKK
  • 644
  • 7
  • 16
  • Are there any articles about how to use `OpenGL's depthbuffers, stencils and shaders` to implement it? – Ovilia Jun 30 '12 at 13:05
  • OpenCSG will be the best place to find out, but as you found it complicated then I'd recommend the openGL Red Book - I always go back to that when looking to understand openGL better: www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321552628 – sergeantKK Jul 11 '12 at 11:07