🔒 Locked
Union, intersection & difference
Advertisement
Original Post
Hi guys, Im wondering if I draw 2 objects over one another, how can I get the Union, intersection & difference of these 2 objects? I'm thinking for intersection If there is anyway of drawing the overlapping region that is supposed to be clipped? Union? Maybe just draw one object over another? Difference? I'm not sure, any ideas? Eg would like to have a hole in my objects. Thanks!!
You can play with the stencil buffer. If rendering A-B, render the B object to the stencil buffer and then the A object normally, setting things so that the stencil test fails where the B object was drawn. For A&unionB, render only where B was drawn.
Of course, this obviously only work in 2D. If you want to do Constructive Solid Geometry in 3D, you have to explicitely compute the intersection or difference, generating new triangles.
Of course, this obviously only work in 2D. If you want to do Constructive Solid Geometry in 3D, you have to explicitely compute the intersection or difference, generating new triangles.
Actually, you can get 3D CSG working using the stencil and depth buffer. Have a read about it here. Of course this is only for *rendering*, you won't get a mesh you could use for collision detection out of it.
Quote:
Original post by Cacks
Thanks for the link!
I was reading last night about tessellaion. I read I can make polygons with holes? Does any 1 know if this is the case? And could I make a cube with a hole in it usign this?
I'm not quite sure what you mean. Tessellation can be used to subdivide nonconvex polygons so that they can easily be rendered. GLU provides routines for polygon tessellation. Have a look at the specification, or this tutorial.
Though, I don't think this is what you really want. You should look up constructive solid geometry, as suggested already.
Quote:
Original post by Cacks
If I could draw a cuboid using polygons(faces) with holes, I could draw an open cuboid within it and look at the sides of this open cuboid through the holes in those polygons?
Does that sound completely wrong?
Sure, but instead of actually having "polygons with holes", wouldn't it be more sensible to have "polygons around a hole"?
Have a look at this, it might be what you need.
As of my knowledge, none of the hardware renderers supports other faces than triangles directly. Even quads are at least internally divided up in tris. So I agree w/ James to "render polygons around holes".
However, if you have written a software renderer, than you may support holes directly, but I think most solutions out there will even divide up the polygon in such case. My modeler does support n-gons and holes, and I've chosen the way of tesselation into tris to render w/ OpenGL.
However, if you have written a software renderer, than you may support holes directly, but I think most solutions out there will even divide up the polygon in such case. My modeler does support n-gons and holes, and I've chosen the way of tesselation into tris to render w/ OpenGL.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement