View Full Version : CSG demo
10-16-2000, 01:08 AM
referring to the CSG demo (boolean operation between glut objects) : someone know how to to modify the original source in order to subtract two or more objects B from the base object A ?
Thanks in advance
10-16-2000, 09:02 AM
The demo you talk about uses the stencil buffer to do the CSG?
If I'm not mistaken, to e.g. subtract more than one object (say B and C) from the base object A, you could set different stencil buffer bits for each object you want to subtract from the base, where you draw the back faces of the primitives to subtract.
I hope that made sense http://www.opengl.org/discussion_boards/ubb/wink.gif
10-16-2000, 11:02 AM
in few word what I want to do is a little emulator of a CNC machine : the solid A is in effect the piece I want to mill ( a rectangular box) and the solid B is the tool ( a cylinder). The solid B must follow a linestring inside the solid A and subtracting material . Ok. I started the project following the csg demo that you can find on this site, and as you say, use the stencil buffer. I modified the function that create the solid B as follow
/* original code * this is the solid B (the tool) in my project */
glTranslatef(sphere_x, sphere_y, sphere_z);
glColor3f(1.0, 1.0, 0.0);
glutSolidSphere(5.0, 16, 16);
/* modified code */
for (step = 0 ; step < 10; step+=1)
glTranslatef(sphere_x+step, sphere_y, sphere_z);
glColor3f(1.0, 1.0, 0.0);
glutSolidSphere(5.0, 16, 16); /* or a cylinder */
Ok. compile ang go and select B sub A from the menu and look the result . What's wrong in my modified code ? the result is right when subtract the odd solid but wrong on the even solid
10-17-2000, 08:20 AM
What do you mean by odd and even solid?
Ok, if you want to subtract the same object multiple times your code looks like it makes sense to me. The only thing that I can imagine is the stencil function that might increment or decrement the wrong way. I don't have the original code so I can't say too much about it but I assume, that it's not prepared for subtracting multiple objects. If my perception of how it works is right, then the stencil buffer has to be left untouched where bits are already set (where a primitive to subtract from another has been already drawn), so that drawing it another time will not change the previously subtracted primitive.
Does that sound logical? http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.