CSG routines

Community Forums/Showcase/CSG routines

Warner(Posted 2009) [#1]
Download here:
http://abcbasic.comyr.com/csg.zip
(updated with improved routines)

Finally I made progress with CSG routines. I started over again, this time using BSP trees.
The result is better than what I tried before when using the Laidlaw approach. I'm very happy.


ImaginaryHuman(Posted 2009) [#2]
Nice.


_33(Posted 2009) [#3]
You're my man!


Ross C(Posted 2009) [#4]
Impressively cool


*(Posted 2009) [#5]
would love to see code to do this :)


GIB3D(Posted 2009) [#6]
Laidlaw? http://en.wikipedia.org/wiki/Laidlaw


GfK(Posted 2009) [#7]
You're my man!
No, the man. He's the man.


Ross C(Posted 2009) [#8]
How do you know? :P


Nate the Great(Posted 2009) [#9]
ok so what exactly is csg? I know it means constructive solid geometry but what does that do? sorry. I just never understood it. and yeah I googled it and did a forum search but found out nothing more than it stood for constructive solid geometry


Gabriel(Posted 2009) [#10]
If you've used an 3d modelling programs, you've probably heard it called boolean operations. CSG means modelling using the boolean operations : Union, Difference and Intersection.

Union is effectively glueing two objects together.

Difference is cutting Object B out of Object A.

Intersection is.. well it's finding the geometry in Object B which is also part of Object A.

The special thing about CSG is that it creates new vertices where necessary so that you don't actually end up with any hidden bits of intersecting geometry tucked away inside the visible geometry. It also preserves UV coordinates.


Nate the Great(Posted 2009) [#11]
oh. that sounds hard to do. thanks for the explanation.


*(Posted 2009) [#12]

WTF has a school bus firm got even the slightest thing to do with CSG


Warner(Posted 2009) [#13]
Sure, I was refering to that company, they were a great help. Also this page:
http://www.flipcode.com/archives/Constructive_Solid_Geometry.shtml


Warner(Posted 2009) [#14]

I've made some progress. BSP trees are now merged when an object is
added/substracted.
To try out the routines I've made a testing program.
You can download it here:
http://abcbasic.comyr.com/csg.zip


RifRaf(Posted 2009) [#15]
looks good, but you need to sort out uv scaling to unify between shape sizes. If I make a small shape the UVs are tiny, but if I make a large one, the UVs are also scaled. Making it look like a circus of UV scaling :). Perhaps have uv scaling optional?


Warner(Posted 2009) [#16]
Thanks RifRaf. I have uploaded a new version, with unified UV coordinates
on the cubes. This wasn't intended to be a serious editor for now, though.
It is just a program to show/test how the CSG operations are working.

EDIT:
Again, updated. The new routines are working properly. Also, I first add a bounding box for new shapes, so the whole mesh doesn't get as fragmented as before when adding for example spheres.