Page 1 of 1

Carving a mesh

Posted: Wed Mar 07, 2007 6:21 pm
by thefuzion
(at first, i post in advenced help because i think it's a difficult topic. Also, even if i've posted only 3 messages, i've used irrlicht since v0.8 so i'm not a begginer (i'm not saying i'm good with irrlicht ! just not a begginer ;) ))

If you have ever used Worldcraft (HL map editor) you will see exactly what i want to do : the carving function of worldcraft.
The principle is very simple : you use a mesh to carve another.

1) you have two meshes
Image

2) you place the meshes to carve what you want, and you select the mesh which will carve the other
Image

3) you click on "carve" and... magic ! the mesh is carved :lol:
Image

I thought a little, and i don't see how to do...
I think we have to use mesh buffers and stuff like this... but that's all...
Have you any idea to do this ?

Posted: Wed Mar 07, 2007 7:32 pm
by arras
It is possible but you would need to make a lot of coding in order to get it. With cubes it would be quit simple but anything more complex would need that you make 3D editing tool out of Irrlicht ...which it is currently not. It is graphic engine not modeling tool. No functions/classes suporting something like you want.

Posted: Wed Mar 07, 2007 8:59 pm
by bitplane
arras is right, you can't really do this in irrlicht as it represents everything in triangles rather than shapes. you'd need to make your own format for 3d polygons which make up closed shapes, then write algorithms for operations on them. the reason is closed shapes have a clearly defined inside and outside, which you will need to do boolean operations used in carving.

there's code in burningwater's renderer (aka software2) to clip triangles against a plane, and there's code in the collision manager to tell where the edges of triangles intersect, but working with triangles alone will give messy results. you'll be better off avoiding irrlicht and working with 3d shapes rather than triangles.

Posted: Thu Mar 08, 2007 8:22 am
by sio2
You probably could do what you describe in your screenshots in Irrlicht.

This is CSG (Constructive Solid Geometry). You could probably do it with the stencil buffer. Shader Model 3 shaders may also be an option with their dynamic flow control. Or render-to-depth-texture. There's probably a few ways of doing it.

Posted: Thu Mar 08, 2007 2:36 pm
by Midnight
always wondered how that would work in irrlicht.

I really need to catch up with everyone on 3d stuff. :cry:

Posted: Thu Mar 08, 2007 5:26 pm
by omaremad
I think i can achieve this in about 3-4 postprocessing passes. (i love post processors :D )

It would be cool since once again its means infinite objects for the same speed (well transform and lighting costs are almost neglible compared to complex shaders or cpu based stuff)

Im hungry now, but ill come back with a picture by picture guide on the renderflow.

Posted: Thu Mar 08, 2007 9:41 pm
by omaremad
Sorry for the delay, im trying to make the method better by reducing the pass number, currently i have to add an extra pass for a special case(total pentration of the object) maybe i can squeeze stuff in the alpha channel.

Posted: Thu Mar 08, 2007 10:56 pm
by Legion
There are several approaches on how you can do CSG.
One common way is to use BSP tree merging to perform boolean operations.

Posted: Fri Mar 09, 2007 8:41 pm
by omaremad
Instead of writting a lengthy document, i need to do homework. This is a critical time in my school and i need to study. so this and my volumeteric lighting have to wait. However if anyone is interested in my method here are some pics.
The circled part is the "insides" fragments which will be drawn to give the illusion of an intersection, since this is a postprocessor method no polygons are harmed so you can keep clean meshes nice and .... clean even after intersects.
also all im doing is measuring vectors in eyespace and deciding with simple flowcontrol which pixels get rendered in the end, SM3 wouldnt bring much benift since the flow control only stops 2/3 texture ops, so normal non SM3 cards wouldnt suffer too much.

Image
Image

Posted: Fri Mar 09, 2007 8:42 pm
by omaremad
Image

Posted: Mon Mar 12, 2007 3:03 pm
by thefuzion
thanks omaremad ! I don't know anything about postprocessor method so I can't do it immediatly... I will have to learn what is postprocessor method before. This is a critical time in my studies too, so I have not a lot of time for Irrlicht and so i'll see all of this later...
but thank you for help ;)