how do I show the shadow of a hidden object?
by deepscratch · in Torque 3D Professional · 05/10/2014 (1:03 am) · 1 replies
I am working on a project that requires the feet of the player to be shown when in 1st person mode, this I have succeeded in doing by splitting the player's body into 2 sections, torso and legs,
the problem is that the hidden torso shows no shadow.
anyone have an idea how to show the hidden torso's shadow?
this is the routine I am using to hide/unhide the torso:
here is a video to show the problem
the problem is that the hidden torso shows no shadow.
anyone have an idea how to show the hidden torso's shadow?
this is the routine I am using to hide/unhide the torso:
function toggleFirstPerson(%val)
{
if (%val)
{
ServerConnection.setFirstPerson(!ServerConnection.isFirstPerson());
$isFirstPersonBody = !$isFirstPersonBody;
LocalClientConnection.player.setMeshHidden("torso", !$isFirstPersonBody);
}
}
//////////////////////////////////////////////////////////////
if (%client.getControlObject() == %client.player)
{
LocalClientConnection.player.setMeshHidden("torso", false);
%client.camera.setVelocity("0 0 0");
%control = %client.camera;
}
else
{
%client.player.setVelocity("0 0 0");
%control = %client.player;
LocalClientConnection.player.setMeshHidden("torso", !$isFirstPersonBody);
}
//////////////////////////////////////////////////////////////////
function serverCmdDropPlayerAtCamera(%client)
{
// If the player is mounted to something (like a vehicle) drop that at the
// camera instead. The player will remain mounted.
%obj = %client.player.getObjectMount();
if (!isObject(%obj))
%obj = %client.player;
%obj.setTransform(%client.camera.getTransform());
%obj.setVelocity("0 0 0");
%client.setControlObject(%client.player);
LocalClientConnection.player.setMeshHidden("torso", !$isFirstPersonBody);
clientCmdSyncEditorGui();
}
function serverCmdDropCameraAtPlayer(%client)
{
LocalClientConnection.player.setMeshHidden("torso", false);
%client.camera.setTransform(%client.player.getEyeTransform());
%client.camera.setVelocity("0 0 0");
%client.setControlObject(%client.camera);
clientCmdSyncEditorGui();
}here is a video to show the problem
About the author
email me at medan121@gmail.com
Andrew Mac
I haven't actually attempted it, but as far as I can tell you'll want to create your own version of hidden that prevents the object from actually rendering, but still leaves it as part of the scene so it can be processed by the other render bins which handle the shadows.
So, taking a look at the render bins (from core/scripts/renderManager.cs):
// Normal mesh rendering. DiffuseRenderPassManager.addManager( new RenderTerrainMgr() { renderOrder = 0.4; processAddOrder = 0.4; } ); DiffuseRenderPassManager.addManager( new RenderMeshMgr() { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } ); DiffuseRenderPassManager.addManager( new RenderImposterMgr() { renderOrder = 0.56; processAddOrder = 0.56; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } ); DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Shadow"; renderOrder = 0.7; processAddOrder = 0.7; } ); DiffuseRenderPassManager.addManager( new RenderMeshMgr() { bintype = "Decal"; renderOrder = 0.8; processAddOrder = 0.8; } ); DiffuseRenderPassManager.addManager( new RenderOcclusionMgr() { bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } );I think what you'll want to do is exclude it only from this one:
DiffuseRenderPassManager.addManager( new RenderMeshMgr() { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } );It's not the only bin that uses the type RenderMeshMgr but you can jump in: void RenderMeshMgr::render(SceneRenderState * state) and added a special hidden condition to the MeshRenderInst to exclude it, but you'll have to check which bin you're currently dealing with, unless you don't care (or prefer) decals are also excluded.