4.9.12 Decals

Written by Andrew Robberts and adapted by Jorrit Tyberghein

Note: A decal is a piece of geometry that wraps around the
existing world. Examples of this might be a bullet mark in a wall, a halo
projected onto the floor around a selected item, or even a simple shadow
underneath a player.

To create a decal you first need a reference to the global decal manager
and decal template designed for your decal.

Decal Manager

The decal manager is used to create decals. Use the iDecalManagerSCFF interface to access the decal manager.

You can load and get a reference to an iDecalManager through any mechanism
that loads a Crystal Space Plugin. For example, the following code will
attempt to load the decal plugin and give an iDecalManager reference.

‘decalTemplate’
This is the decal template you created earlier that will dictate the
settings used for the decal.

‘sector’
This is the sector where the decal will be placed.

‘pos’
This is the position of the decal in the given sector.

‘up’
This is the direction of the top side of the decal. This setting can be
used to rotate the decal.

‘normal’
This is the direction that will be perpendicular to the decal. This
setting can be used to tilt the decal. For something like a bullet mark,
you will probably want this direction to be perpendicular to the wall
that will receive the bullet mark.

‘width’
The width of the decal.

‘height’
The height of the decal.

‘oldDecal’
This is an optional parameter. If you're recreating a decal (ie,
moving/rotating an old decal) you can pass your old decal. The decal
manager will recycle this decal as much as possible so that supplying
an old decal is more efficient than deleting the old decal manually
and creating a new one from scratch.

Deleting Decals

If you set a lifespan for your decal through
iDecalTemplate::SetTimeToLive(), then your decal will die naturally
and delete itself.

However, if you want to remove your decal early or it does not have a
lifespan set, then you can remove your decal from the world by passing
your iDecal pointer into iDecalManager::DeleteDecal().