damage effect

Blitz3D Forums/Blitz3D Programming/damage effect

cash(Posted 2008) [#1]
I have successfully implemented bulletholes appearing on my models when shot (with the help of the forums and archives.)

however when I shoot a rocket for example, the damage sprite is a lot larger and can overlap the edges of the model making it look odd.

i have been playing around with blending and paintsurface etc but cannot get the required effect at all.

I need to show damage (burnt) effect when a wall for example is hit, but need it to somehow wrap the model or something similar.

Don`t need anything too fancy, just an effect.

Any ideas please.


jfk EO-11110(Posted 2008) [#2]
I'd suggest drawing the damage to the texture buffer. (Tho this requires to use a manually copied (using createtexture and copyrect) clone of the texture, unless you want the effect appear on all textures of the same file.)

This will be wrapped nicely if your UV Mapping is supporting it. (eg. cylindrical mapping). Note editing a texturebuffer at runtime may be a little slow. Then again, you do it only one time, I guess during an explosion effect, so this little stutter won't be that bad. You may use the texture flag 256 that makes access to the texture much faster.

Unfort. there seems to be some incompatibility on a few cards that prevents you from drawing directly to the texturebuffer, so if you want full comaptibility, you'll have to copy the texture to the backbuffer, then DrawImage a masked damage picture to the texture, then copy this rect back from backbuffer to texturebuffer.

Even better: hold the original texture as an image in memory, then do something like this:
if hit(x)
 DrawBlock tex_orig,0,0
 DrawImage damage,rand(128),rand(128)
 damaged_tex=createtexture(512,512,256)
 copyrect 0,0,512,512,0,0,backbuffer(),texturebuffer(damaged_tex)
 EntityTexture rocket(x),damaged_tex
endif


You may also want to use one of the examples that show how to paint directly to a certain picked location of a texture, so you can position the damage image accurately. There was a sample on the Blitz3D CD, maybe it's also in the downloaded version. And I think there was also something like this in the code archives somewhere.