fractures

Blitz3D Forums/Blitz3D Beginners Area/fractures

chwaga(Posted 2007) [#1]
OK, i've been brainstorming on how to do fractures. I've got the theory made up, but I want to know if this is possible in blitz (maybe even real-time??)

2D (if 2d can be done, so can 3d)
a triangle is placed in a scene with points A, B, C. 1 extra vertex (D) is placed within the boundaries of ABC, and is triangulated to the nearest vertices, breaking the triangle into 3 triangles. Another 1 or 2 verts are placed within the boundaries of the 3 triangles, and again, triangulated. Once the fracture is complete, each new
"chunk" created is seperated into its own "entity", and (maybe?) physics are applied. This would essentially create a fracture. The main problem I'm having with coding it, is:
-how to triangulate
-how to place a vert within the boundaries of the fractured entity
-how to make new entities
mainly these problems all deal with cross-checking vertices to eachother, with a heavy mesh, this would laaag, but, could this be done in real-time with something like a box or other low poly things?

If this works out, a simple random tree could be applied to show "chain splits" like in glass or breaking ice, etc.

if anyone wants to put up code, feel free to, but don't kill yourself going 3d, a simple 2d line example would make me go
....!!
\____/


Ben(t)(Posted 2007) [#2]
I'm confused, so what are you trying to do?


chwaga(Posted 2007) [#3]
break a mesh into pieces, "fractures"


PowerPC603(Posted 2007) [#4]
You can create meshes, vertices and triangles on-the-fly (realtime), that's what I'm gonna do with my game.
But once a triangle is created, you cannot remove the triangle from the mesh.
To remove one triangle, you'll need to loop through all the vertices, recreate them and create all triangles again, without the triangle you wanted to delete.

You could create 3 vertices and place a fourth one somewhere in the middle.
And again and again, untill you have enough triangles which will make up your triangulated mesh.
Then you could go to the most outer vertex and find the 2 closest vertices near that one and connect them into a triangle.
And then go on from there, untill all vertices have been used to form triangles.

I cannot supply you with code, because this is a bit complex.


Stevie G(Posted 2007) [#5]
There's code in the archives to do this .. see big10p's explode mesh function. At least that's what I think it's called.

Stevie


chwaga(Posted 2007) [#6]
that's just taking each tri individually, and blowing it up, I'm thinking take a mesh and split it into 9-10 "chunks"...although once I start to really think about it, getting depth in 3d would be hard...


Ben(t)(Posted 2007) [#7]
why not just make one copy of the model as your character, and then replace it with the broken version. or do you mean that it can break in sections and not all a once?


Yeshu777(Posted 2007) [#8]
Isn't there an exploding mesh demo in the archives, which would achieve this with the variables set correctly?


chwaga(Posted 2007) [#9]
dont know...i'll double check...


chwaga(Posted 2007) [#10]
found it, but is there a way to do thickness??


big10p(Posted 2007) [#11]
The explode mesh demo only does individual tris - it doesn't do 'chunks'. It does contain tri subdivision code, though, which you may find useful...


Stevie G(Posted 2007) [#12]
I would suggest using Ben(t)'s idea - create the chunks yourself in a modeller, hide the original and show the chunks when required.

Creating random chunks in realtime will be a system killer even on quite low poly meshes.

In terms of preprocessing the only way I can think of doing it would be to create a function which takes a mesh and a clip plane ( position and normals ) as params and returns a pair of meshes - one for each side of the plane. For more chunks do this recursively with the new chunks. Big10p's clipping demo ( not the explode one ) could be useful for you here. Then you would need to find all the vertex pairs which form the outer edge and sit on this plane and use a triangulation / tessalation function to close the new mesh.

It'd be reasonably complex and if your maths isn't up to it stick to Ben(t) suggestion.

Stevie