Can't disable first person player rendering with 1.01
by Daz · in Torque Game Engine Advanced · 05/30/2007 (11:30 pm) · 8 replies
Hi all.
I have searched the forums looking for a solution to my problem, but to no avail.
My problem is: when I use the 1st person view in TGEA 1.01 and all prior versions, I can't stop the player from rendering. I have set renderfirstperson to false in player.cs and player.cc, but the player is always rendered. This becomes problematic when trying to use the ModMaker packs with the model hands, as the player has 2 sets of hands.
Has anyone found a fix for this yet?
I have searched the forums looking for a solution to my problem, but to no avail.
My problem is: when I use the 1st person view in TGEA 1.01 and all prior versions, I can't stop the player from rendering. I have set renderfirstperson to false in player.cs and player.cc, but the player is always rendered. This becomes problematic when trying to use the ModMaker packs with the model hands, as the player has 2 sets of hands.
Has anyone found a fix for this yet?
#2
07/07/2007 (8:19 am)
I got mine working a LONG time ago, forgot what I did though. Its a real easy fix in shapebase.cc or player.cc
#3
07/07/2007 (8:46 am)
Mind checking what it was ? :)
#4
However, I don't see exactly where in the code it says for the main shape (not mounted objects) to be rendered.
07/08/2007 (7:03 am)
I narrowed down the code to what looks to be ShapeBase::prepRenderImage and ShapeBase::prepBatchRender. I was able to stop the mounted Images (crossbow) from being rendered on the player but not vice versa. I was also able to make neither render as well.However, I don't see exactly where in the code it says for the main shape (not mounted objects) to be rendered.
#5
07/08/2007 (10:25 am)
We did this awhile back, basically we duped prepRenderImage from ShapeBase into Player class and then handled what was needed there//----------------------------------------------------------------------------
// dupe of ShapeBase prepRenderImage - so we can control rendering - jwf
//----------------------------------------------------------------------------
bool Player::prepRenderImage(SceneState* state, const U32 stateKey,
const U32 startZone, const bool modifyBaseState)
{
AssertFatal(modifyBaseState == false, "Error, should never be called with this parameter set");
AssertFatal(startZone == 0xFFFFFFFF, "Error, startZone should indicate -1");
if (isLastState(state, stateKey))
return false;
setLastState(state, stateKey);
if( ( getDamageState() == Destroyed ) && ( !mDataBlock->renderWhenDestroyed ) )
return false;
// Select detail levels on mounted items
// but... always draw the control object's mounted images
// in high detail (I can't believe I'm commenting this hack :)
F32 saveError = TSShapeInstance::smScreenError;
GameConnection *con = GameConnection::getConnectionToServer();
bool fogExemption = false;
ShapeBase *co = NULL;
if(con && ( (co = con->getControlObject()) != NULL) )
{
if(co == this || co->getObjectMount() == this)
{
TSShapeInstance::smScreenError = 0.001;
fogExemption = true;
}
}
// jwf: handle player/item render setup
// Decide whether we are going to render the player/items or not
bool renderPlayer = true;
bool renderItems = true;
if (con && con->getControlObject() == this && con->isFirstPerson())
{
renderPlayer = mDataBlock->renderFirstPerson;
// Options that let the client turn off (but not on) rendering
// jwf: always render Items for now
if (!sRenderMyPlayer)
renderPlayer = false;
//if (!sRenderMyItems)
// renderItems = false;
}
if( state->isObjectRendered(this) || gClientSceneGraph->isReflectPass() )
{
mLastRenderFrame = sLastRenderFrame;
// get shape detail and fog information...we might not even need to be drawn
Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
cameraOffset -= state->getCameraPosition();
F32 dist = cameraOffset.len();
if (dist < 0.01)
dist = 0.01;
F32 fogAmount = state->getHazeAndFog(dist,cameraOffset.z);
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
if (mShapeInstance)
DetailManager::selectPotentialDetails(mShapeInstance,dist,invScale);
if (mShapeInstance)
mShapeInstance->animate();
if ((fogAmount>0.99f && fogExemption == false) ||
(mShapeInstance && mShapeInstance->getCurrentDetail()<0) ||
(!mShapeInstance && !gShowBoundingBox))
{
// no, don't draw anything
return false;
}
for (U32 i = 0; i < MaxMountedImages; i++)
{
MountedImage& image = mMountedImageList[i];
if (image.dataBlock && image.shapeInstance)
{
DetailManager::selectPotentialDetails(image.shapeInstance,dist,invScale);
if (mCloakLevel == 0.0f && image.shapeInstance->hasSolid() && mFadeVal == 1.0f)
{
prepBatchRender( state, i );
// render debug
if( gShowBoundingBox )
{
RenderInst *ri = gRenderInstManager.allocInst();
ri->obj = this;
ri->state = state;
ri->type = RenderInstManager::RIT_Object;
ri->mountedObjIdx = i;
gRenderInstManager.addInst( ri );
}
}
}
}
TSShapeInstance::smScreenError = saveError;
if(renderPlayer && mDataBlock->shadowEnable)
{
RenderInst *ri = gRenderInstManager.allocInst();
ri->obj = this;
ri->state = state;
ri->type = RenderInstManager::RIT_Shadow;
gRenderInstManager.addInst(ri);
}
// render debug
if( gShowBoundingBox )
{
RenderInst *ri = gRenderInstManager.allocInst();
ri->obj = this;
ri->state = state;
ri->type = RenderInstManager::RIT_Object;
ri->mountedObjIdx = -1;
gRenderInstManager.addInst( ri );
}
// jwf - Prep the Batch Render, only if we want to be rendered
if (mShapeInstance && renderPlayer && DetailManager::selectCurrentDetail(mShapeInstance))
prepBatchRender( state, -1 );
calcClassRenderData();
}
return false;
}
#6
Now I need to look and render different detail levels for my first person player and third person players weapons. That should be pretty straightforward though.
07/08/2007 (1:26 pm)
Thanks! Seems to work well.Now I need to look and render different detail levels for my first person player and third person players weapons. That should be pretty straightforward though.
#7
07/08/2007 (4:49 pm)
First person/third person weapon details was easy. I copied prepBatchRender from shapeBase into player and added the following lines before the image.shapeInstance->... code.if(!isFirstPerson())
image.shapeInstance->setCurrentDetail(1);
image.shapeInstance->animate();
image.shapeInstance->render();
#8
05/01/2008 (3:18 pm)
Thanks Jeremiah. Much appreciated.
Torque 3D Owner Matt Huston
Atomic Banzai Games
The best bet is to look in ShapeBase.cpp/h as I believe that is where the rendering code takes place, ideally I think it should have its own rendering code though? (I think it had its own in TGE)