Game Development Community

multiple projectile decals

by Gibby · in Torque 3D Professional · 12/03/2013 (10:33 am) · 4 replies

Greets all:

Curious, is it possible to have more than one decal for a projectile? I'd like to have five or six decals to add randomness to the bullethole effect...

#1
12/03/2013 (10:43 am)
I don't believe there is a feature at the moment to support that but it shouldn't be too hard. Check out projectile.cpp you'll find the code you're looking for in the Projectile::explode() function. This in particular:

// Client (impact) decal.
      if ( mDataBlock->decal )     
         gDecalManager->addDecal( p, n, 0.0f, mDataBlock->decal );

What I would do is mimic how the code works for things like stateSequence where it's an array with a maximum number of values. Create a constant to hold the max number of decals, make decal into an array, and then either pick a random number between 0 and max_decals or use the method of your choice to determine which decal to use.

Edit: spelling.
#2
12/03/2013 (12:12 pm)
You can make a single texture, divided up into cells, and stock T3D will randomly choose the cell to use as decal. (eg: 1024 image divided into 128 pixel cells makes ... er ... math ... 8x8)

Check out the art/decals/bullet_hole.png image and the accompanying materials and managedDecal file.
#3
12/03/2013 (2:01 pm)
This in the decal datablock in combination with a properly setup image sheet:
randomize = "1";
texRows = "2";
texCols = "2";
... numbers are for a different number of "cells" but works just like Steve indicated.
#4
12/04/2013 (11:42 am)
ahhhh, perfect!

I found it in my old TGE code, but this is the same without recoding...