Dynamic shadowing
by Matthias Georgi · in Torque Game Engine · 01/17/2008 (2:38 pm) · 1 replies
I need a solution to cast shadows from any object to a tsStatic shape in TGEA. Dynamic shadowing should work for all ShapeBase objects if the relevant fields are enabled in the datablock.
There are two solutions for this problem:
- using static shape objects
- using tsStatic objects and implementing/modifying the shadow projection code
Static shapes are not a real solution for me in this case, as they are not covered by the polysoup resource. So I tried to implement the shadow projection for tsStatic objects.
I added following code to the sgObjectBasedProjector class:
I'm searching for all tsStatic objects and getting their TSShapeInstance. This is exactly the same code as for the ShapeBase objects. It actually works somehow, but for some reason the shadow is rendered repeatedly all over the shadow receiving tsStatic object. It looks like the shadow is rendered for each polygon of the tsStatic object.
My understanding of the shadow projection code is quite limited. I have no clue why this thing is happening.
I'm not sure if the original code for casting on ShapeBase objects is correct. Maybe the projection was developed only for small objects.
I would appreciate any help on this topic or some pointer for a better understanding of the shadow casting code. Thanks!
There are two solutions for this problem:
- using static shape objects
- using tsStatic objects and implementing/modifying the shadow projection code
Static shapes are not a real solution for me in this case, as they are not covered by the polysoup resource. So I tried to implement the shadow projection for tsStatic objects.
I added following code to the sgObjectBasedProjector class:
// find all tsStatic objects:
gClientContainer.findObjects(StaticTSObjectType,
sgShadowProjector::dtsCallback, this);
for(U32 o=0; o<sgShadowReceivers.size(); o++)
{
TSStatic *tsStatic = dynamic_cast<TSStatic *>(sgShadowReceivers[o]);
if (tsStatic)
{
shape = tsStatic->getShapeInstance();
if(!shape)
continue;
shapeworld = tsStatic->getRenderTransform();
shapeworld.scale(tsStatic->getScale());
}I'm searching for all tsStatic objects and getting their TSShapeInstance. This is exactly the same code as for the ShapeBase objects. It actually works somehow, but for some reason the shadow is rendered repeatedly all over the shadow receiving tsStatic object. It looks like the shadow is rendered for each polygon of the tsStatic object.
My understanding of the shadow projection code is quite limited. I have no clue why this thing is happening.
I'm not sure if the original code for casting on ShapeBase objects is correct. Maybe the projection was developed only for small objects.
I would appreciate any help on this topic or some pointer for a better understanding of the shadow casting code. Thanks!
About the author
Integration of Torque and Ruby
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft