Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Reaperman
22
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Kent, England
Posted: 24th Sep 2013 00:17
Hello everyone.

Long time since I posted here, but I have a question I hope someone can answer.

I need to know if there is a way you can take an imported object (or create a mesh from object etc etc) and then randomly split it up in to smaller random objects.

Just like if you take a hammer and hit a stone and split it up.

Can this be done and if it can, does anyone have any code that I could use as a base.

Thanks for looking.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Sep 2013 01:08 Edited at: 24th Sep 2013 01:12
This may already have been done in DBPRO, a forum search may suffice, but if not; here are some real world inspirations for your creation.

In Valves games they spawn various objects at the point of impact; these objects are textured and made to look like they were a part of what was an object. These elements are given the func_physicsbox entity class; which is a Source equivilent of a PhysX rigid body box; in other words they become 3d particles.

In Blender there are modifiers designed to animate the destruction of a mesh.



Similar techniques can be exported into a multi-limbed object; objects with sub-objects, and each limb could be animated separately.

As always, something like this could be Vertex shaded; given a certain array of vertices each with a reference to a vector multiplied by a timeline; with the required split vertices set in place.

thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 24th Sep 2013 02:05
Regarding blender, I've created a simple demo that shows the feature Chris Tate describes. Basically, with a system like this you should have two meshes - a normal model and a fractured model. The fractured model is generated by blender which divides the model into chunks, animating data showing the object exploding or falling apart. Within dbpro you then load both objects, and hide the fracture mesh until the object is being destroyed. Then, you show the fracture mesh and have two options: In the demo I created I've chosen to use the baked animation, but you could also set up dynamic physics on each of the chunks. I can write a tutorial for this entire process from Blender to Dbpro if anyone wants more information.

I've attached a simple standalone demo, instructions included. the UV data is messed up on the fractured mesh but that's an artist mistake by me, the UV data works fine if you follow the proper technique

Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 24th Sep 2013 04:30 Edited at: 18th Nov 2013 00:11
One method for breaking an object is called voronoi fracture.
Voronoi Fracture is usually handled by a physics engine.
Bullet Physics library is an open source physics engine which includes voronoi fracture.

http://bulletphysics.org/wordpress/

We are currently working on making a Bullet Physics Wrapper for DBPro.
We just started testing voronoi fracture.
Here is a early test in DBPro.





[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Sep 2013 11:50
Looks good SITD.

TheNerd, I get a 'file does not exist' error when I run the fracture program.

thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 24th Sep 2013 13:53
The technique I've used is exactly what Stab in the Dark software is describing.

I believe I've fixed my demo, for some reason the particle definition didn't include itself in the file.

Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 24th Sep 2013 15:55
Chris

thankyou.

TheNerd

Very nice demo.
In our Bullet Wrapper we can only fracture convex hulls.
Can Blender fracture any shaped mesh?
I believe Blender uses Bullet Physics to create the animation.
It would be great if you could make a tutorial on the process from Blender to DBPro.

[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Reaperman
22
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Kent, England
Posted: 24th Sep 2013 16:07
Hi guys, thanks for the info.

And nice demos too.

What I really wanted to know though was if DBP could do it.
Are there any commands or ways that DBP can take an object and break it up in to smaller objects.

Thank you for the help so far.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Sep 2013 16:10 Edited at: 24th Sep 2013 16:14
I wish I had some time but sadly not. I'd hate to rush a tutorial. I am building a game, an engine and an editor for it; plus I told Lee I would give this FPSCR terrain AI task a go, and I got to go to work soon.

Your solution seems to be more easier.

In Blender you would need to use a modifier, split the object into separate objects by applying the modifier and using numerous separate mesh calls (P Key); then use Dark Dynamix or some physics plugin that supports physics limbs to apply forces to those separate chippings.

A good thing about this method is that you can spend a lot of time perfecting where things will crack in large complex objects such as buildings.

In vanilla DBPRO you could use CSG commands found in the Game FX help documentation to use objects to carve out other objects, thus breaking them apart; however there will be a performance issue regarding complex objects.

Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 24th Sep 2013 16:37
Reaperman

DBPro does not have native commands to fracture an object.
That being said you could write a DBPro version of a voronoi algorithm.

http://en.wikipedia.org/wiki/Voronoi_diagram

Then use DBPro native commands to create the pieces and texture them.
Bascically this is what we do in our Bullet Wrapper.
Bullet Physics has a built in library that helps with handling a convex mesh which makes it easier to accomplish.
It is faster to do inside a c++ dll.


[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2013 17:51
There's really no effective way for DBPro to do this natively, not at the sort of speed that you would expect, the best option seems to be to wait on that awesome looking plugin from SITD & co.

Of course, there might be a specific case that you want to tackle, and doing that with plain old objects is an option, it's just that it's quite a lot of complex modelling work to do it right.

Take a light bulb for example - that's always gonna be a complex problem to smash, because it's not like bricks or wood, where the whole mesh can be broken up - you'd want hundreds of little pieces of glass, and a solid metal base etc to do it properly.
To smash it in DBPro, well I'd have a seperate model for a whole light bulb, then when it needs to smash - I'd swap it for a broken light bulb base object and position lots of glass shards radially. Maybe each piece of glass is like a physics particle, it would react with geometry, but not necesserily with other pieces of glass, or the player... a disposable entity if you like.

Just to get the light bulb in game would mean a lot of modelling work, you'd need to have the broken bits of lightbulb as objects ready to go. So for a FPS game it's probably not ideal to go to those lengths - but for a game where you break light bulbs, well it'd be worth doing it then... At least until that plugin is released, then people will want the whole level to be destructible

I am the one who knocks...
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Sep 2013 02:50 Edited at: 25th Sep 2013 02:53
I agree with Van B. But come to think of it; the modelling part is actually quite easy in Blender, easier than I thought.

There a number of ways, but one way is to use the Remesh modifier which uses an octree algorithm to split up the object, then use the random select and separate commands so that you get different objects; this is similar to what I said in my third post, but having tried it out it is more easier than I expected.

But like Van B says it looks like SITD's plugin will get the job done without having to open Blender.

[edit] OMG , this Blender Remesh modifier is wicked! There is this block mode that makes your model look Minecrafty! - Sorry for going off topic

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Sep 2013 12:03
There's a trick you can use in DBP to fracture a mesh:



Object 2 now no longer has the original index data assigned to its vertices, which means you can fracture each polygon without any being connected to the other (through vertexdata commands, for instance).

Here's an exploding sphere demonstrating just that:
http://forum.thegamecreators.com/?m=forum_view&t=141809&b=6

TheComet

Your horse has been erased by a signature because it was larger than 600x120
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Sep 2013 23:38
Good!

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Sep 2013 02:16 Edited at: 29th Sep 2013 21:08
Hi there.
Studying a little of fracturing a mesh, maybe not fast, but it would be worth studying this function. What it does, is cut a box in the middle randomly several times . Perhaps someone can find this useful for little purposes.



Cheers.

I'm not a grumpy grandpa
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 26th Sep 2013 02:51
what @TheComet has shown is great for quick effects. The issue with that system though is that the results are not very realistic - the model doesn't have a solid interior. I think the most effective way to fracture a mesh realistically is through a 3rd party tool such as blender, or through csg commands such as what chafari has shown, and both of these are not done in realtime.

Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 26th Sep 2013 09:31
Stab in the Dark software, that was a very cool demo!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Reaperman
22
Years of Service
User Offline
Joined: 9th Sep 2003
Location: Kent, England
Posted: 26th Sep 2013 18:27
Well just to say.... I did not want to use the fracture of a 3d object in DBP within a game.

It was something I was looking at doing for a util, so the speed of the fracture is not important... its just getting it to fracture in DBP that I need.

But thanks for the help from everyone....very informative

I will try the examples Thecomet and chafari gave, but if thats the only way to do it, then I may have to wait for Stab in the Dark software to finish their plugin.

(any idea when its going to be finished SITD?)

Oh one more question to SITD....

You said: "Bullet Physics has a built in library that helps with handling a convex mesh which makes it easier to accomplish.", and "Bullet Physics library is an open source physics engine which includes voronoi fracture.

http://bulletphysics.org/wordpress/"

Maybe im geting old...but I cant find the download for the engine on the site LOL. Can you link it please.

Thanks to everyone for the help.

Cheers
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 27th Sep 2013 04:57
Quote: "(any idea when its going to be finished SITD?)"


Well we are hoping to have it finished before the end of the year.
We will be starting a WIP post soon so everyone can follow.

Quote: "Maybe I'm getting old...but I can't find the download for the engine on the site LOL. Can you link it please."


Upper left top of page. LOL
Just in case here you go.

http://code.google.com/p/bullet/downloads/list

Its C++ and it builds as LIBs not DLLs.
You could just look at the algorithm in the fracture demo and translate to DBPro.

[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.

Login to post a reply

Server time is: 2026-07-06 10:36:21
Your offset time is: 2026-07-06 10:36:21