shadows are not rendered properly for skin mesh type
by Doyoon Kim · in Torque Game Engine · 10/22/2001 (1:59 pm) · 3 replies
Ok, this bug has been bugging me ever since I put my own player model in the game. Basically, the shadow of one player animates the shadow of another player. After further testing, I noticed this only happens on skin mesh type models and not normal segment models such as the default torque player. So I spent a couple days debugging this.
The skin mesh type verts needs to be updated before rendering the shadow.
Though you could probably clean it up a bit and find a better way to put it in there. Just make sure updateskin is called for a tsskinmesh type model before rendering the shadow.
Anyways, updateskin() basically tranforms the skin mesh verts to the bones and places them in tsmesh verts[]. And since verts[] is shared, when it came time to render the shadow, it used whatever verts that were last placed during the initial player renders so thats why it appeared one player could control the shadow of another player.
The skin mesh type verts needs to be updated before rendering the shadow.
void TSMesh::renderShadow(S32 frame, const MatrixF & mat, S32 dim,
U32 * bits, TSMaterialList * materials)
{
...
gShadowVerts.setSize(vertsPerFrame);
Point3F * vstart = &verts[frame*vertsPerFrame];
Point3F * vend = vstart + vertsPerFrame;
//>> INSERT
// update skin mesh verts if skin mesh type
if (getMeshType() == TSMesh::SkinMeshType)
static_cast<TSSkinMesh *>(this)->updateSkin();
//<< END
// result placed into gShadowVerts
shadowTransform(mat,vstart,vend,dim-1);
...Though you could probably clean it up a bit and find a better way to put it in there. Just make sure updateskin is called for a tsskinmesh type model before rendering the shadow.
Anyways, updateskin() basically tranforms the skin mesh verts to the bones and places them in tsmesh verts[]. And since verts[] is shared, when it came time to render the shadow, it used whatever verts that were last placed during the initial player renders so thats why it appeared one player could control the shadow of another player.
#2
Josh
10/22/2001 (2:04 pm)
Sounds like if you don't fix it you could make a great shadow boxing game... :-)Josh
#3
12/28/2001 (11:14 am)
Found this bug buried in my task list :( Fixed it and checked it in. I made renderShadow() a virtual function and had the SkinMesh override it. Basically the same thing it does for the normal render. Thanks for hunting this one down!
Torque Owner Karsten "Clocks" Viese
// Clocks out