Game Development Community

Decals

by J.C. Smith · in Torque Game Engine Advanced · 09/08/2006 (12:52 pm) · 7 replies

I can't for the life of me find the thread, but about a month ago when people were inquiring about things in MS4, decals were brought up, and it was stated that decals would be in MS4. I was merging our project into MS4 today and it appears that decals are not enabled. Just curious if this is something we can expect at a later time or if we'll have to write our own decal manager?

#1
09/08/2006 (3:38 pm)
The decal manager was included in MS4 for the lighting system (for glowing decals and projectors). It looks like player decals and particle foot poofs are commented out of Player::updateActionThread - you can try uncommenting the code to see if it works. Assuming it does, the decal system is up and running to support it.
#2
09/08/2006 (4:01 pm)
Do the projective decals work like they did in TLK for TGE or are they conforming (as in adapting to seams and corners)?
#3
09/08/2006 (7:03 pm)
They work the same way as in TLK (both use the underlying Torque decal manager).
#4
09/11/2006 (11:39 am)
Just plugged up the code for them and tested it out. They work great, thanks John. For anyone who is trying to get them going the changes (think these are all of them) are basically:

in decalmanager.h

Be sure to add this at the end of the decaldata declaration:

DECLARE_CONSOLETYPE(DecalData)

in decalmanager.cpp

after the

DecalManager* gDecalManager = NULL;

make sure you have:

IMPLEMENT_CONOBJECT(DecalManager);
IMPLEMENT_CO_DATABLOCK_V1(DecalData);

and before the InitPersistFields function be sure to add:

IMPLEMENT_CONSOLETYPE(DecalData)
IMPLEMENT_SETDATATYPE(DecalData)
IMPLEMENT_GETDATATYPE(DecalData)

Finally in player.cpp. Make sure to add the following include:

#include "sim/decalmanager.h"

and then be sure to uncomment all of the decal related areas. I just did a search of decal and uncommented where necessary. I didn't uncomment the onimpact area since it wasn't directly related. For footprints though you will need to uncomment/modify the block following codeblock in updateactionthread:

if (triggeredLeft || triggeredRight)
      {
         Point3F rot, pos;
         RayInfo rInfo;
         MatrixF mat = getRenderTransform();
         mat.getColumn(1, &rot);
         mat.mulP(Point3F(offset,0.0f,0.0f), &pos);
         if (gClientContainer.castRay(Point3F(pos.x, pos.y, pos.z + 0.01f),
            Point3F(pos.x, pos.y, pos.z - 2.0f ),
            TerrainObjectType | AtlasObjectType | InteriorObjectType | VehicleObjectType, &rInfo))
         {
            S32 sound = -1;
            // Only put footpuffs and prints on the terrain
            if( rInfo.object->getTypeMask() & AtlasObjectType | TerrainObjectType)
            {
               TerrainBlock* tBlock = static_cast<TerrainBlock*>(rInfo.object);

               // Footpuffs, if we can get the material color...
   /*            S32 mapIndex = tBlock->mMPMIndex[0];
               if (mapIndex != -1) {
               NOTE: OMITTING LOTS OF COMMENTED OUT AREAS
                             emitter->deleteWhenEmpty();
                        }
                     }
                  }
               }*/

               // Footprint...
               if (mDataBlock->decalData != NULL)
                  mSceneManager->getCurrentDecalManager()->addDecal(rInfo.point, rot,
                     Point3F(rInfo.normal), getScale(), mDataBlock->decalData);
            }

Bullet holes also work but its a lot of different code blocks to paste and it's 2AM here, I need sleep. Basically though you can just cut and paste all areas with decal in the name from the TGE version of projectile.cpp and projectile.h after plugging up the decalmanager and then bullet holes will work. You will need to add the decaldata to your projectile also, of course.
#5
09/12/2006 (2:56 am)
Awesome - added to 1.0.
#6
10/25/2007 (9:09 am)
Was this really added to the TGEA codebase? Decals don't seem to function in 1.0.3...
#7
10/25/2007 (9:22 am)
I posted the fix to make them work correctly and what needs to be changed in a different thread.

they somehow got disabled again due to missing sgLighting implementation as it seems.