Carving a mesh

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
thefuzion
Posts: 10
Joined: Tue Mar 06, 2007 11:31 am

Carving a mesh

Post 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 ?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post 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.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

always wondered how that would work in irrlicht.

I really need to catch up with everyone on 3d stuff. :cry:
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post 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.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post 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.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
Legion
Posts: 15
Joined: Sun Oct 29, 2006 5:03 pm

Post 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.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post 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
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

Image
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
thefuzion
Posts: 10
Joined: Tue Mar 06, 2007 11:31 am

Post 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 ;)
Post Reply