Jump to content
  • Advertisement
Sign in to follow this  
IlyaZ

Destructible terrain

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I read about different methods like Gemod and one that just lowers the Y of the hit polygons. I'm trying the latter version. So I made a big field for testing purposes: my.php?image=field0fj.jpg Now I want to lower the terrain at a point specified by the user. Say I want to lower the terrain at (52.12f,0,55.16f). How would I do that?

Share this post


Link to post
Share on other sites
Advertisement
How are you making that quad field? Is it made from a dynamic vertex(index) buffer? If it is, then hopefully you are storing each point and it's properties in an array of some sort (which shouldn't be any more complicated than a Vector3 array). If this is the case, you merely need to change the Y value of the points around where you want to affect it. You probably want to scale the magnitude of the change by the distance from the center of the target to get a nice gradient effect. And that should be about it.

Share this post


Link to post
Share on other sites
Yea, it's created through a dynamic vertex/index buffer.

Vertex* vGround = new Vertex[squares_x*squares_z+squares_x*squares_z+1];
int iVertexNumber=0;
Ground->LockVertexBuffer(0, (void**)&vGround);
for (int v_x=0; v_x <= squares_x; v_x++)
{
for (int v_z=0; v_z <= squares_z; v_z++)
{
vGround[iVertexNumber]=Vertex(boxsize_x*v_x, 0.0f, boxsize_z*v_z, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
iVertexNumber++;
}
}
Ground->UnlockVertexBuffer();


That's the code I use to generate the vertices. However, to lower the terrain at (52.12f,0,55.16f) I need to find the closest vertex (if we assume the terrain has been hit)? That way I need to calculate the vertex array number I think. I'm sure it's possible but what about if I use an imported dx model as terrain and want to be able to damage it too? How would I find the affected vertices then?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!