PDA

View Full Version : combining objects



adityask
03-21-2002, 06:47 AM
hello,
i want to create a object by boolean addition of two primitives say... a cube and a cylinder in OpenGL? Can it be done ? if yes, how? Otherwise is there a way of grouping the two and treating it as
a single object?
thanx in advance.

painterb
03-21-2002, 07:07 AM
OpenGL cannot help you with how you conceptually deal with objects. It is for drawing those objects to the screen only.

Now if you want to *draw* them as a single object, you could try looking into display lists.

If you need more information about what OpenGL can do, you should first read here before posting questions to the Advanced board: http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_PG/

Olumide
03-21-2002, 08:17 AM
Boolean addition can be done by simply enabling the depth test glEnable(GL_DEPTH_TEST) ... (See the Red Book 3ed Pg. 176)

Boolean Subtraction and Intersection however is not so trivial and requires careful and ingeneous use of the stencil buffer. Real-Time CSG as it is sometimes called was part of the (SIGGRAPH)Advanced Graphics Programming Techniques course in 1997, 1998 and 1999. See link below ...
http://www.opengl.org/developers/code/sig99/advanced99/notes/node22.html


You can also search the web. There are lots of papers on this subject. But I warn you it's not for the fainthearted.

Lot's of Luck ...


[This message has been edited by Olumide (edited 03-21-2002).]

knackered
03-21-2002, 09:04 AM
It's not that hard to do boolean subtraction 'offline' (ie. not using opengl, just operating on the raw data).
It's just clipping.

V-man
03-23-2002, 09:02 PM
Originally posted by knackered:
It's not that hard to do boolean subtraction 'offline' (ie. not using opengl, just operating on the raw data).
It's just clipping.

Not hard? I've never actually done it but it involves figuring out where inside is of the object that will substract, and then "cutting" some polygon. Addition will require the same thing. I know how to do it and it involved a fair amount of math & logic.

Doing it in GL is slightly easier. Look at the CSG example that come with GLUT. Mesa might have examples too. (links are in developper section)

V-man