Render a Shadow Without Rendering its Source Object?
by Chad Kilgore · in Torque Game Engine · 08/07/2007 (11:39 am) · 9 replies
It has to be possible. How can I easily render a shadow of an object without rendering the source object? I'm trying to create that eerie feeling of ghostly apparitions. Thanks.
#2
08/08/2007 (12:56 pm)
When I made a completely transparent texture, the object was rendered as an entirely black object.
#3
08/08/2007 (12:59 pm)
I would use setCloaked to make an invisible object, then modify shapeBase.cc to render the shadow even while cloaked.
#4
Can anybody point me in the right direction so that I can add a renderShadow variable, which can dynamically change, in the script Player object? Thanks a lot.
08/08/2007 (5:38 pm)
I have created a variable mRenderShadow (= true) and modified line 4037 to read:if (mRenderShadow ||
mShapeInstance && renderPlayer && mCloakLevel == 0.0f &&
mMount.object == NULL && image->isTranslucent == true)Can anybody point me in the right direction so that I can add a renderShadow variable, which can dynamically change, in the script Player object? Thanks a lot.
#5
Follow their example and create something similar for mRenderShadow
08/09/2007 (8:07 am)
I think the easiest way is to create a consoleMethod for it. Look at how they create the setCloaked method:ConsoleMethod( ShapeBase, setCloaked, void, 3, 3, "(bool isCloaked)")
{
bool cloaked = dAtob(argv[2]);
if (object->isServerObject())
object->setCloakedState(cloaked);
}Follow their example and create something similar for mRenderShadow
#6
08/09/2007 (8:45 am)
I goofed up btw. You would want to change the rendering code in the appropriate place, like player.cc, not shapeBase.cc
#7
I anticipate times that I would want to have a cloaked player without a shadow and just display its footprints. So I am trying to add a variable that is read in from the bit stream and change it as needed. Using a consoleMethod seems more like a hack then solid implementation. I am having problems with the bitstream in player.cc. Any ideas or am I just being stubborn?
08/09/2007 (9:06 am)
That good. Because I wasn't smart enough to find the shadow rendering code in the shapeBase.cc.I anticipate times that I would want to have a cloaked player without a shadow and just display its footprints. So I am trying to add a variable that is read in from the bit stream and change it as needed. Using a consoleMethod seems more like a hack then solid implementation. I am having problems with the bitstream in player.cc. Any ideas or am I just being stubborn?
#8
In shapeBase.cc, ShapeBase::ShapeBase()
In shapeBase.cc, anywhere:
In player.cc, within the renderImage function, replace
With:
I just tested this and it worked for me.
*EDIT* - Fixed error with variable name in ConsoleMethod. Nice catch Chris
08/09/2007 (9:24 am)
In shapeBase.h, declare this public function:void setRenderShadow(bool bRenderOn)
{
mRenderShadow = bRenderOn;
}In shapeBase.cc, ShapeBase::ShapeBase()
mRenderShadow = true;
In shapeBase.cc, anywhere:
ConsoleMethod( ShapeBase, setShadowRender, void, 3, 3, "(bool renderShadow)")
{
bool renderShadow = dAtob(argv[2]);
if (object->isServerObject())
object->setRenderShadow(renderShadow);
}In player.cc, within the renderImage function, replace
if (mShapeInstance && renderPlayer && mCloakLevel == 0.0f &&
mMount.object == NULL && image->isTranslucent == true)
{
renderShadow(dist,fogAmount);
}With:
if ([b]mRenderShadow || [/b]mShapeInstance && renderPlayer && mCloakLevel == 0.0f &&
mMount.object == NULL && image->isTranslucent == true)
{
renderShadow(dist,fogAmount);
}I just tested this and it worked for me.
*EDIT* - Fixed error with variable name in ConsoleMethod. Nice catch Chris
#9
It appears as though the mRenderShadow variable isn't getting set to the appropriate value, or at least not in the appropriate place.
08/09/2007 (1:56 pm)
Where are you putting your bool mRenderShadow variable? I have mine under/// @name Cloaking
/// @{
bool mCloaked;
F32 mCloakLevel;
TextureHandle mCloakTexture;
bool mHidden; ///< in/out of worldat line 825 in the shapeBase.h but it doesn't want to work.It appears as though the mRenderShadow variable isn't getting set to the appropriate value, or at least not in the appropriate place.
Torque Owner Cory Anderson
Default Studio Name