TGEA 1.03 Mounted Object Shadow Bug
by Ronald J Nelson · in Torque Game Engine Advanced · 04/11/2008 (9:51 pm) · 1 replies
I have checked this to make sure it wasn't me and I have seen an old post that TGEA 1.03 has this issue. I am trying to see if anyone has fixed it or if it was fixed in TGEA 1.7?


Torque Owner Ronald J Nelson
Code Hammer Games
What I have done is first check to see if the object is mounted to anything. If it is, do not render a shadow for that object as that object. That sounds confusing I know, let me explain. Each object is individually set to generate a shadow unless it is an shape image like a gun. Then it has its shadow generated when the object it is mounted to does. So what this first step does is just not generate the objects shadow yet.
Second I used a variation of the shape image shadow generation code to look for mounted objects in the normal seat nodes. I added a new variable to the shapebase code to allow you to only look in that area. Then I generate the objects shadow at the same time the main object and shape image shadows are being generated.
Here is my code. If you see anything wrong let me know.
In class ShapeBase : public GameBase right under the entry for MaxMountedImages, I added:
Then right at the beginning of void ShapeBase::renderShadow(SceneState *state, RenderInst *ri), I added:
Finally, in void sgShadowProjector::sgRenderShadowBuffer(TSShapeInstance *shapeinstance) right after:
for(U32 i=0; i<ShapeBase::MaxMountedImages; i++) { TSShapeInstance *mountinst = shapebase->getImageShapeInstance(i); if(!mountinst) continue; MatrixF shapeworld; shapebase->getRenderImageTransform(i, &shapeworld); shapeworld.scale(sgParentObject->getScale()); lightspace.mul(sgWorldToLightY, shapeworld); lightspace = shadowscale * lightspace; newmat.mul(proj, lightspace); sgRenderShape(mountinst, newmat, 0, newmat, -1); }I added this:
for(U32 h=0; h<ShapeBase::MaxMountedObjects; h++) { ShapeBase *mountObj = shapebase->getMountedObject(h); TSShapeInstance *mountObject = dynamic_cast<TSShapeInstance *>(mountObj); if(!mountObject) continue; MatrixF shapeObjworld; mountObj->getRenderTransform(); shapeObjworld.scale(sgParentObject->getScale()); lightspace.mul(sgWorldToLightY, shapeObjworld); lightspace = shadowscale * lightspace; newmat.mul(proj, lightspace); sgRenderShape(mountObject, newmat, 0, newmat, -1); }