How to cut a model in the scene?

Before I ask the question, here’s an example of what I’m asking:

  1. Load a model into the scene
  2. Load a second (unrendered) model into the scene, same place as the first.
  3. Find where these models intersect and cut the first model along the faces of the second.
  4. Get each seperated model as a geometry or spatial or node.

Would this be possible? If you’re wondering what it’s for, it’s for my building destruction. I wanted to make it a bit more randomized, as well as reducing some rendering artifacts. I’d have a pre-made model of a sphere cut into pieces. When there’s an explosion, it places this sphere in the location and cuts any building models it comes in contact with. Any help is appreciated!

You’d have to do the same that 3d editors do, thats going through the vertices, remove some, reconnect the open faces etc. I think there was code in jME2 to do that for cutting the scene for the water processor reflection which was necessary on OpenGL1. The basics of going through the mesh and find out what to do for the separation along a plane should not differ much. So maybe check out the jME2 code in svn or find some documentation on the issue.

Alright, I’ll do that. You’ve seen the videos of the destruction, right? Doing this would allow me to make it more randomized and remove the small rendering cracks in the buildings.

Yeah, you’d have to do what that blender plugin does.

It sounds like you are wanting to do boolean operations on the shapes. You should be able to simplify things a lot though since this is a very specific case of fracturing an original…

What about UV coordinates? I guess thats going to be quite tricky, too?

In case of all adjacent vertices sharing the same texture: Okay. I guess thats easy.
But what if there are two or even more textures at a newly formed face? Whats going to happen here?

Can’t happen. If you are splitting a face in two then by definition both halves have the same texture. You just need to work out the new UV co-ordinates by taking the appropriate ones from the surrounding vertices and working it out from that.

This is potentially quite a fiddly little project though…I hope your maths and visualisation skills are good :slight_smile:

Visualization: check.
Maths: Look, a dinosaur! points and runs away

I have a feeling this will hurt my brain. But I’ll give it a shot. And yes, boolean operations is exactly what I mean. Also, the entire original will have the same texture throughout. The only problem texturing-wise I can think of is that there won’t be any texture coordinates on the newly generated faces so textures there might get a bit wonky.

That’s where the maths comes in. You can use the co-ordinates of the new vertex to work out the texture co-ordinates for it based on the surrounding texture co-ordinates.

i.e. if a triangle has [0,0] , [0,1], [1,0] then a point in the center would get [0.33, 0.33]