Jump to content


Photo

Destructible Terrain


  • Please log in to reply
79 replies to this topic

#41 ydawg314

ydawg314

    GMC Member

  • New Member
  • 901 posts
  • Version:Unknown

Posted 13 July 2009 - 06:42 PM

I think that the thing that most people are missing with this thread is that physics should be applied when designing these examples. For example we should be seeing ground which is moved aside by bullets and explosion rather than deleted. Also structural integrity should be factored in. You really should be able to dig a hole in the ground just by using a gun...
  • 0

#42 TeBe

TeBe

    GMC Member

  • New Member
  • 4 posts

Posted 20 July 2009 - 10:17 PM

I've managed to come up with a pretty simple implementation of a destructible polygonal terrain. It uses a 2D array and the Marching Squares algorithm to polygonise the terrain, but instead of boolean values it uses real values to represent the terrain density at each point. This allows us to interpolate vertex positions between adjacent points, so we can make the terrain much smoother. Also there's no need to have a density value for each pixel, so the terrain can be linearly scaled.
Terrain drawing could be optimized with surfaces.

Download

Edited by TeBe, 17 November 2009 - 09:11 AM.

  • 0

#43 MitchGraham

MitchGraham

    GMC Member

  • Banned Users
  • 524 posts

Posted 20 July 2009 - 10:46 PM

TeBe, this is your first post?!

This is incredible mate, incredible. I'm still looking at the source, but good lord you've done a good job here.

#44 TeBe

TeBe

    GMC Member

  • New Member
  • 4 posts

Posted 20 July 2009 - 10:56 PM

TeBe, this is your first post?!

This is incredible mate, incredible. I'm still looking at the source, but good lord you've done a good job here.


Thanks.
I've also done a 3D version with the Marching Cubes using c++ and opengl but since this is the Game Maker forum I'll only share the 2D version here :P
  • 0

#45 MitchGraham

MitchGraham

    GMC Member

  • Banned Users
  • 524 posts

Posted 20 July 2009 - 11:04 PM

Yeah, I was just thinking about that, this is the only method I know of that was relevant also to 3d AND physics, in that you could compose a section into a separate object and apply physics to it. I personally would love to see the 3d version, but it would probably be ridiculously difficult to bring into gm.

#46 ydawg314

ydawg314

    GMC Member

  • New Member
  • 901 posts
  • Version:Unknown

Posted 21 July 2009 - 02:20 AM

I've managed to come up with a pretty simple implementation of a destructible polygonal terrain. It uses a 2D array and the Marching Squares algorithm to polygonise the terrain, but instead of boolean values it uses real values to represent the terrain density at each point. This allows us to interpolate vertex positions between adjacent points, so we can make the terrain much smoother. Also there's no need to have a density value for each pixel, so the terrain can be linearly scaled.
Terrain drawing could be optimized with surfaces.

Download


Wow I was trying to make something like this but I gave up when I couldn't figure out a polygon fill method plus I didnt actually get to the part where you make craters and stuff. Any way excellent job Tebe. Its really cool. you should make this a tutorial.

Also another nice touch you could add might be dust and rocks which are created during the explosion which land and add to the terrain

Edited by ydawg314, 21 July 2009 - 02:20 AM.

  • 0

#47 blue_chu_jelly

blue_chu_jelly

    Shut your FMaj7

  • GMC Member
  • 228 posts

Posted 21 July 2009 - 06:52 AM

it's nice and instantaneous, but it's still slow when you get heaps of triangles on screen. For me, 700 triangles gives me about 35-40 fps.
  • 0

#48 TeBe

TeBe

    GMC Member

  • New Member
  • 4 posts

Posted 21 July 2009 - 02:04 PM

it's nice and instantaneous, but it's still slow when you get heaps of triangles on screen. For me, 700 triangles gives me about 35-40 fps.


Yeah, this can be improved by drawing the triangles on surfaces and only draw them when they need updating. This makes the framerates not depend on triangle counts.

I've already implemented a surface method and got 500+ fps but it's still quite buggy.
  • 0

#49 vadim647

vadim647

    Quite Epic

  • New Member
  • 840 posts

Posted 21 July 2009 - 09:05 PM

Posted Image
  • 0

#50 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 22 July 2009 - 07:57 AM

Posted Image

that was already possible without the slowdown when drawing, go back a couple off pages and have a look at my surface 'n grid method...
  • 0

#51 vadim647

vadim647

    Quite Epic

  • New Member
  • 840 posts

Posted 22 July 2009 - 08:35 AM

Posted Image

that was already possible without the slowdown when drawing, go back a couple off pages and have a look at my surface 'n grid method...

Can you show me a platform engine for that please?
  • 0

#52 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 22 July 2009 - 04:58 PM

Posted Image

that was already possible without the slowdown when drawing, go back a couple off pages and have a look at my surface 'n grid method...

Can you show me a platform engine for that please?

didn't bother to write a platform example for it, shouldn't be too hard, you can just read from a list if a place is free from collision with the terrain...
linky
  • 0

#53 vadim647

vadim647

    Quite Epic

  • New Member
  • 840 posts

Posted 22 July 2009 - 05:36 PM

I'm not talking about hardness, i'm talking about perfomance.
Calculating the entire collision thing of several nonsquare shaped objects using grids is going to kill all your perfomance. (since even for square with good collisions you'll have to check your grid like 4*vspeed times per step, and you are normally going to have something else then player with collisions, I suppose Posted Image)
  • 0

#54 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 23 July 2009 - 10:28 AM

I'm not talking about hardness, i'm talking about perfomance.
Calculating the entire collision thing of several nonsquare shaped objects using grids is going to kill all your perfomance. (since even for square with good collisions you'll have to check your grid like 4*vspeed times per step, and you are normally going to have something else then player with collisions, I suppose Posted Image)

true, but you don't need pixel perfect collision checking, just checking all the corners is good enough...
EDIT:and you can use the ds_grid_get_disk_max function to check for circles, and the ds_grid_get_max function to check for squares, and most shapes are a composite off those...

Edited by ditdingiscool, 23 July 2009 - 10:30 AM.

  • 0

#55 jinnyjuice

jinnyjuice

    GMC Member

  • New Member
  • 14 posts

Posted 28 July 2009 - 02:23 AM

this is similar to splashing water with your hand.

drawing water is difficult yes. splashing water is even more difficult.

first difficult step: terrain destruction in the shape of hand (or water destruction)
second difficult step: random but not random splashes water bubble sizes
third difficult step: water refilling the destructed parts of water
fourth difficult step: water bubbles conjoining with the water
fifth difficult step: water making waves due to splash

i couldn't do anything about this problem so i just set limits to what the hand can do, how deep the hand can go. and i just made an animation of the splash out of flash and sony vegas, so it's a sprite into a video file, but i converted the video to animated image of course.

any suggestions??? sigh...

should this be a new topic?
  • 0

#56 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 28 July 2009 - 04:24 PM

<snip>
should this be a new topic?

yes it should, what you're currently doing is hijacking this topic, although the question is related-ish it isn't the same as the topic...
  • 0

#57 makron666

makron666

    GMC Member

  • New Member
  • 22 posts

Posted 12 August 2009 - 02:35 AM

I know this isn't the most er.. expert suggestion, but it worked for me.
I have a landscape sprite, and when a bomb hits it, it creates a hole sprite at that position, when you drop another bomb in the collision with the land it checks if there is already a hole, if so it continues until there isn't.
This is fast(For me) and im able to destroy the whole terrain without dropping one frame.
  • 0

#58 ditdingiscool

ditdingiscool

    GMC Member

  • New Member
  • 335 posts

Posted 12 August 2009 - 09:36 AM

I know this isn't the most er.. expert suggestion, but it worked for me.
I have a landscape sprite, and when a bomb hits it, it creates a hole sprite at that position, when you drop another bomb in the collision with the land it checks if there is already a hole, if so it continues until there isn't.
This is fast(For me) and im able to destroy the whole terrain without dropping one frame.

that's not the problem anymore, enough solutions for that already(just browse this topic), now were mainly thinking off ways to make the terrain fall if there are holes in it...
  • 0

#59 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1619 posts
  • Version:GM:Studio

Posted 15 August 2009 - 05:41 PM

@TeBe - I admire the simplicity of your solution. The quality of the implementation stems from the interpolated marching squares. Most marching (squares, tetrahedrons, cubes) implementations use boolean values, and thus appear blocky when compared to your solution. Thank-you for sharing this.
  • 0

#60 theg721

theg721

    G Dawg

  • GMC Member
  • 1959 posts
  • Version:GM8

Posted 29 August 2009 - 02:21 PM

I made http://myfreefilehos...e6dbe56a_0.04MB . What do you think?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users