#### Archived

This topic is now archived and is closed to further replies.

# Constructive Solid Geometry...

This topic is 6669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is a tough one, im trying to add some CSG functionality to my editor, basically I want to be able to, for example place two cubes together and ADD/SUBTRACT them. For example I have a room, i want to be able to subtract a cube from the centre of the wall to create a doorway. So to my question, does anyone have any good tutorials/examples/source showing this. I''m NOT using BSP trees, and the only one I have found uses the BSP tree to do a lot of the work. Thanks for any pointers/advice you can give, there doesn''t seem to be much information about this out there, and i''m having real trouble trying to figure it all out myself. Adam "Nutz" Hoult VB Gaming Central

##### Share on other sites
I don''t have actual code, but you can e-mail me to do it. My idea is to have a quad class(stores info on 4 vertexs).
  Quad *A(ax1,ay1,az1,ax2,ay2,az2,ax3,ay3,az3,ax4,ay4,az4);Quad *B(bx1,by1,bz1,bx2,by2,bz2,bx3,by3,bz3,bx4,by4,bz4);// a draw proc would look like thisA->QuadDraw();void Quad::QuadDraw(void){ glBegin(GL_QUADS); glVertex3f(ax1,ay1,az1); glVertex3f(ax2,ay2,az2); glVertex3f(ax3,ay3,az3); glVertex3f(ax4,ay4,az4); glEnd();}// When you substract b from aA=A-B;// you just override the draw func

I''m not sure this is the way to do it, but i''m here to learn, just like you ;P.

"Everything is relative." -- Even in the world of computers.

##### Share on other sites
Thanks for replying, well I actually need to modify the geometry in the editor, (i.e split the polys etc), then this geometry is loaded into the engine already modified if you see what i mean =)

If i figure anything out, i''ll e-mail you with what i find.

Thanks again

VB Gaming Central

##### Share on other sites
Check out genesis3d.com and download their 3d sdk. In the editor code (editor is called fusion) you''ll find examples of CSG. I was looking at their intersection code where they take two cubes stored as two vectors i.e. min(-x, -y, -z) and max(x, y, z) compare the vector components of both min and max vectors and obtain the new min, max vectors describing the new cube.

Cheers

my homepage
E-Mail: BlueOrbSoftware@mailcity.com

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632942
• Total Posts
3009339
• ### Who's Online (See full list)

There are no registered users currently online

×