[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] [ Search: ]

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 iDecalManager SCFF 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.

iObjectRegistry* object_reg = ...;
csRef<iDecalManager> decal_mgr = csLoadPluginCheck<iDecalManager> (
  object_reg, "crystalspace.decal.manager");

Decal Templates

A decal template holds all the generic settings that are needed to create a decal such as lifespan, color, material, and other more complicated settings.

A decal template is created using the decal manager's ‘CreateDecalTemplate’ function:

iMaterialWrapper* matWrap = ...;	// Material wrapper for your decal.
csRef<iDecalTemplate> decalTemplate = decal_mgr->CreateDecalTemplate(matWrap);

The returned decalTemplate has sufficient default values to create a decal, but the decal template can be greatly customized by calling the many settings functions of iDecalTemplate.

Creating Decals

Once you have an iDecalManager reference and your iDecalTemplate you can create a decal using the decal manager's CreateDecal function:

iDecal * iDecalManager::CreateDecal(iDecalTemplate * decalTemplate,
  iSector * sector, const csVector3 & pos, const csVector3 & up,
  const csVector3 & normal, float width, float height, iDecal * oldDecal)

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().

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html 1.76.