Paweł Mogiła's game development blog

Terrain destruction vol.2 July 5, 2011

Filed under: destruction,gamedev — szaman @ 17:24

After long break with posting ( caused by achieving bachelor’s degree – successful btw^^ ) I managed to create various holes in terrain.  Shape of hole can be circle, rectangle, convex polygon, concave also, generally every shape that can be represented by list of vertices. Here you can see circular holes (wire frame view enabled)

This slideshow requires JavaScript.

You can see on pics that in some places there are unnecessary triangles. The algorithm is not optimized, it is based only on dividing into smaller triangles:

1.    Find triangles that collide hole shape in certain place ( bullet AABB test)
2.    For each found triangle:

–    A = triangle vertices, B = hole vertices
–    Make polygon difference (complement), output polygon C =A\ B
–    triangulate C and add to world triangles that we get
–    delete original triangle A

I still need something to merge multiple triangles into one bigger


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s