ent_decal (ENTITY*, BMAP*, var size, var angle)

Attaches a decal to an arbitrarily shaped surface of the level, a terrain, or a model. A decal is a bitmap image that looks as if painted onto the surface and bends around corners. It can be used for bullet holes, scorch marks, footprints, ground shadows and so on.


ENTITY* Entity to place the decal onto, or NULL for putting it at a level surface. By default the decal is placed at the hit position of a preceding c_trace.
BMAP* Bitmap to serve as decal image; must have an alpha channel, a square power of 2 size (f.i. 64x64, 256x256...) and transparent border.
size Diameter of the decal in quants, or 0 for using the bitmap size.
angle Rotation of the decal about the hit surface normal (hit.nx) in degrees, relative to the orientation of the target entity.


PARTICLE* pointer to the created decal particle.






Example (lite-C):

BMAP* bmMark = "blood.dds";
SOUND* sndShot = "bullet.wav";

// control a decal-placing gun with the camera
function use_decal_gun()
   while (1)
// calculate the target vector
      VECTOR trace_target;
      vec_set(trace_target,vector(5000,0,0)); // the weapon has a firing range of 5000 quants
      vec_rotate(trace_target, camera.pan);
      vec_add(trace_target, camera.x);
// display a red spot at the target position
      if (c_trace(camera.x,trace_target, IGNORE_PASSABLE | USE_POLYGON| SCAN_TEXTURE) > 0) // hit something?

// fire and then place a decal at the hit position			
      if (key_ctrl) // fire
         if (HIT_TARGET) // target hit?
            PARTICLE* p = ent_decal(you,bmMark,7+random(3),random(360)); // place a random sized decal at the hit entity 
            p.lifespan = 1600;   // remove decal after 100 seconds
            p.material = mat_model; // assign a decal material  
         snd_play (sndShot,100,0); // play the shot sound at a volume of 100
         wait(-0.5); // reload

See also:

PARTICLE, lifespan, c_trace, effect, material, ent_getdecal

► latest version online