Game Development Community

Another Dynamic Shadow Question - Player Shadow on StaticShape not working

by Nicolai Dutka · in Torque Game Engine Advanced · 05/29/2009 (2:48 pm) · 6 replies

I've done some research and finally got my object casting a shadow on the ground as well as 'selfShadow' working, but the player will not cast a shadow on the object in question.

Datablock:
datablock staticShapeData( SemiTrailer )
{
   category = "StaticShape";
   shapeFile = "~/data/shapes/vehicles/semitruck_trailer1.dts";
   emap = true;
   allowPlayerStep = 1;
   shadowEnable ="1";
   shadowCanMove="1";
   shadowSelfShadow ="1";
   shadowDTSShadow ="1";
   shadowSize ="512";
   shadowSphereAdjust = "1.5";
   shadowBias = "0.001";
   shadowMaxVisibleDistance ="50";
   shadowProjectionDistance ="50";
};

Object Instance:
new StaticShape() {
         canSaveDynamicFields = "1";
         Enabled = "1";
         position = "461.761 1017.35 -0.510515";
         rotation = "0.0671366 0.0548482 -0.996235 78.7071";
         scale = "1 1 1";
         datablock = "SemiTrailer";
         receiveSunLight = "1";
         receiveLMLighting = "1";
         useCustomAmbientLighting = "0";
         customAmbientLighting = "0 0 0 1";
      };

Can someone explain why my player is not casting shadows on my static shape?

#1
05/29/2009 (11:29 pm)
shadowSelfShadow ="1";  
shadowDTSShadow ="1";

It should be a part of your playerdata datablock too.
#2
05/30/2009 (12:51 am)
Dig through all of the shadow projection code and look for things like this:

gClientContainer.findObjects((AtlasObjectType | TerrainObjectType | InteriorObjectType | StaticTSObjectType), sgShadowProjector::collisionCallback, this);


That's in sgShadowProjector::sgCalculateBoundingBox, but there may be other places it's necessary. You'll need to make sure your object mask is included in these, i.e. you could add a | StaticShapeObjectType if you're using that as part of your object type mask.


What I would do is do a search for "StaticTSObjectType" and if it's used in a mask, add yours there too.

#3
05/30/2009 (1:07 am)
I created a simple staticshape and the player casted its shadow over it.
So the shadow worked and it seems StaticShapeObjectType is a part of the mask in the Shadow Projector class.
#4
05/30/2009 (1:31 am)
Quote:
So the shadow worked and it seems StaticShapeObjectType is a part of the mask in the Shadow Projector class.

No it's not, at least not in the stock TGEA 1.8.1 code. As you see I pasted the code from sgShadowProjector class that finds the objects with a bounding box within the shadow area, and StaticShapeObjectType is clearly not a part of that mask. I just did my own test to be sure, and adding StaticShapeObjectType there enables shadow casting on a StaticShape, while removing it causes no shadow to be cast.

Keep in mind that StaticShape is not the same thing as TSStatic, which is what you get when you add a "Static Shape" from the mission editor.

Of course, now that I think about it, self-shadowing should not work without it either, so OP may be having a different problem.

#5
05/30/2009 (1:41 am)
OK,you are right.
I used 1.7.1 and i am sure it is a staticshape,because i made a datablock for it.
#6
05/30/2009 (1:54 am)
Sorry, actually you're right. I didn't have shadowDTSShadow set in the player data class for my test. I see now that there is a separate call for all ShapeBaseObjectType in sgShadowProjector::sgRender if that is set for the caster.