Explosion marks on Terrain

Blitz3D Forums/Blitz3D Programming/Explosion marks on Terrain

Josh R(Posted 2004) [#1]
Hello friends,

I just bought blitz3d this week so please forgive me if I have overlooked the obvious. How can I leave explosion marks on a terrain?

What I want to achieve is an explosion on a terrain which modifies the ground(as an explosion would) and leaves the ground black in that spot. I have seen in the castle.bb sample program how to use ModifyTerrain to adjust the terrain, but how can I leave the ground black in that spot?

Thanks in advance for any advice
Josh


jfk EO-11110(Posted 2004) [#2]
Since it's likely that you are using a tiling texture for the terrain, you cannot simply draw the black color to the terrain texture. There are two alternative methods:

1
Use a towel mesh that will be aligned to the terrain surface. This towel mesh will contain the explosion traces, using alpha transparency (use TGA with alpha channel for invisible parts of the texture).
2
Use a second texture layer on the terrain that stretches exactly one time across the entire terrain. Then simply draw the black color to the coordinate where the explosion took place. You have to calculate this coordinate using a formula that goes something like
x=(terrain_width# / (explo_x# - terrain_x_start#))* texture_2_width()

where terrainwidth is the worldrelative width (segments * scale ?), x_start is the true world coordiante, where the terrain starts, explo_x is of course the world coordinate of the explosion, and texture_2_width is the width in pixels of the second texture layer.

But there's a problem with alpha textures and drawing to them: Alpha information gets lost, so you probably have to update the alphachannel manualy. Try to use flag 256 on the texture, maybe this helps too.

If you won't use a true Terrain, but instead a Mesh based terrain, then you could use VertexColor to make some parts black, using linepick, pickedsurface and pickedtriangle etc.

Try the free landscape editor some of are currently working on, in the blitz creations zone of this forum.


Josh R(Posted 2004) [#3]
Thanks for replying to my post jfk. I am going to play with these two methods and see what I can get working. As I mentioned in my original post I am new to blitz and 3d programming. If anyone has any sample code on implementing a towel mesh, it would be greatly appreciated.

thanks again
Josh


jfk EO-11110(Posted 2004) [#4]
Here's a shadow source that is using a dynamic towel:
http://www.blitzbasic.com/codearcs/codearcs.php?code=434

But to be hones, I think this towel idea wasn0t that good since the more explosions you got, the more towels you need and the slower the game gets.

I would definitively try the method with the 2nd layer texture. It sounds complicated, but it's simple.