Blood in the face how?

Blitz3D Forums/Blitz3D Programming/Blood in the face how?

D_Town_Tony(Posted 2003) [#1]
I'm working on a vs. shoot em up and want the characters to get bloody as the battle progresses. Any suggestions on how to accomplish this. I've been looking through the forum and have found some info to use vertexcoloring and multitexturing, the only prob is that I don't understand either at all. Can someone walk me through these please.


WendellM(Posted 2003) [#2]
I plan to have vehicles and characters sustain visible damage in my games as well, overlaying "splotches" of damage textures (appropriate to the type of damage inflicted: cut, burn, etc.) on the base textures, and thus no need to use multitexturing per se. I've tried a simple test:
SetBuffer TextureBuffer(Item\Texture)
Color 255,0,0
Rect Rand(TextureWidth(Item\Texture)-30), Rand(TextureHeight(Item\Texture)-30), 30, 30, True
SetBuffer BackBuffer()
where Item\Texture is the handle of a model's texture returned by LoadTexture(). This puts red rectagles on the model at random:

By using masked (or maybe alpha-ed) textures and applying them to the appropriate location of the base texture, I expect that pretty realistic results can be achieved. For example, if a character's right arm sustains a burn in the game, a burn texture is applied to the right arm area (the coordinate range of which has been determined beforehand) of the main texture.


Neo Genesis10(Posted 2003) [#3]
The downside with Wendel's approach is that it means tampering with the actual texture of the object. This is bad because the texture is referenced by ALL objects with the same texture. So, by adding blood marks to one they ALL recieve blood marks.

You can work around this by giving them individual textures (by copying the existing texture) or (and probably better still) using mutitexturing. Doing this means you would apply a second texture over the existing one, this would contain the blood marks and other damage.


; This code assumes the head is a seperate entity

Global bloodsplat = LoadImage("sprite/blood.bmp")
EntityTexture player1\face, player1\face_mask, 1
AddBlood player1\face_mask

Function AddBlood(texture)
	SetBuffer TextureBuffer( texture )
	max_x = TextureWidth( texture )
	max_y = TextureHeight( texture )
	DrawImage bloodsplat, Rand(0, max_x), Rand(0, max_y)
End Function

Reasonably simple coding. The only tricky part is getting it in the right places. If, for example, you wanted a bruise / blood patch to appear on the cheek when hit you would have to determine the location using CollisionX, Y and Z.


D_Town_Tony(Posted 2003) [#4]
Thanks for the replies.
WendellM - This is probably a very stupid question(which would show how dense I am on the subject of textures and such)but how do you get a texture handle off a model that put together in a program such as Milkshape, 3ds...I'm sure its a simple command but well...I can't seem to figure it out.
thanks again


WendellM(Posted 2003) [#5]
Currently, I don't think there's a built-in way of doing that, only workarounds. Because I use the same mesh with different textures, I don't assign texture in the modelling program but rather load them in Blitz with LoadTexture(). However, a couple of weeks ago, Mark Sibly wrote here that "GetSurfaceTexture or whatever it was..." will be included in the next Blitz3D update, so it should be easy to do once that's out.

Neo Genesis10 is right about changing one texture affecting all models with it and that multitexturing is the way around that. If your models each have a unique texture (as mine do) then drawing on their textures directly is more memory-efficient. However, if several copies of a model use the same texture, then applying another texture on top for damage is the way to go.

Along those lines, you'll need to have a full texture for the model (or at least those areas to be damaged). That is, models sometimes "cheat" by having several parts (such as both arms, both legs, etc.) UV-mapped to use the same portion of a texture. The model in the test above does this, which is why the arm and leg damage is always applied to both limbs (in the real version, though, such "cheating" won't be used).


abacadabad(Posted 2003) [#6]
How about colouring the nearest vertex to the polygon hit by the bullet dark red or something?


JoshK(Posted 2003) [#7]
I can do this for you, but you won't like it.


WendellM(Posted 2003) [#8]
I can do this for you, but you won't like it.
Isn't that what Mephisto said to Faust? ;)


Litobyte(Posted 2003) [#9]
Better use the 2nd layer of texture of the model for this.
You coul have them precalculated on certain places, and then assign them up ;)

EG: you got your texture.bmp which is your color map for your model assigned to the texture layer "0" of the model.

Then as if it was a lightmap (but with different blend setting of course) you will have: bloodmap.png bloodmap1.png bloodmap2.png and so on, which will be a set of texture that will be assigned to the texture layer "1" so colouring of blood your models in different comboz.

Is simple to achieve, and all those bloodmaps would be reapplicable to all of your models.

(you could use different filename as well, eg: bloodface.png bloodtorso.png bloodfaceandtorso.png and so on)

Just an idea ;)