Renderfirstperson = false, but still does it
by Chris Byars · in Torque Game Engine Advanced · 01/31/2006 (5:45 pm) · 25 replies
I have every renderfirstperson set to "false" in my TSE scripts, however the good old Mech Orc's arms/body still appear in first person as if I had it set to "true". I've searched through all the files and it is indeed set to false.
Any ideas why it disobeys?
Any ideas why it disobeys?
#2
that has nothing to do with this I'm afraid. You're talking about the camera, where C2 is talking about rendering the player mesh in 1st person.
C2,
check out player.cc @ ~3876 to ~3887 and make sure the code is called on your TSE copy as well. I'm not close to any IDE to take a look myself, but this should solve your problem as far as I remember.
However, if it does not solve your problem, keep the change I suggested above and simply force the renderFirstPerson = true; in playerdata (also in player.cc). This will keep the playermodel from being rendered. Sure it's a hack, but I would use it until it's fixed in the codebase.
Good luck.
Edit: Bah, grammar.
01/31/2006 (11:34 pm)
John, that has nothing to do with this I'm afraid. You're talking about the camera, where C2 is talking about rendering the player mesh in 1st person.
C2,
check out player.cc @ ~3876 to ~3887 and make sure the code is called on your TSE copy as well. I'm not close to any IDE to take a look myself, but this should solve your problem as far as I remember.
However, if it does not solve your problem, keep the change I suggested above and simply force the renderFirstPerson = true; in playerdata (also in player.cc). This will keep the playermodel from being rendered. Sure it's a hack, but I would use it until it's fixed in the codebase.
Good luck.
Edit: Bah, grammar.
#3
01/31/2006 (11:37 pm)
Or else we wouldn't have to change the code (:
#4
02/20/2006 (7:39 am)
Actually that code that you mentioned seems to be commented out. It's got this /* thing going on and that entire section is in green (the commented color in VS .NET 2003).
#5
04/15/2006 (12:29 pm)
Would anyone happen to have been able to disable the player from rendering in first person as is supported by TGE?
#6
Actualy, give this a try... it's not tested or anything, but I think it should work.
Add this to the top of Player::renderImage:
04/15/2006 (12:35 pm)
Should be a trivial thing to fix, just take a look at the Player rendering methods.Actualy, give this a try... it's not tested or anything, but I think it should work.
Add this to the top of Player::renderImage:
GameConnection *con = GameConnection::getConnectionToServer();
if(con && con->getControlObject() == this && con->isFirstPerson() && !mDataBlock->renderFirstPerson)
return;
#7
BTW it's "getServerConnection" for those who want to use this solution as well for MS2.
04/15/2006 (1:04 pm)
Edited: Works perfectly, user error beforehand. :PBTW it's "getServerConnection" for those who want to use this solution as well for MS2.
#8
Basically took parts of the commented out code and moved them up and just verified that it handled things properly. Normally would have Item/Object mount checking too, but haven't bothered to rehook that into the rendering flow yet.
Josh's piece of code is cleanest for no other options, but when certain parts are re-implemented or whatever, it may have to be modified or moved around, similiar to what I have
and getConnectionToServer() is proper for MS3+
04/15/2006 (3:57 pm)
Here is what I'm currently using:PROFILE_START(PlayerRenderPrimary);
GFX->pushWorldMatrix();
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
GFX->setWorldMatrix( mat );
GameConnection *con = GameConnection::getConnectionToServer();
// Decide whether we are going to render the player shape or not
bool renderPlayer = true;
bool renderMounts = true;
if (con && con->getControlObject() == this && con->isFirstPerson())
{
renderPlayer = mDataBlock->renderFirstPerson;
// Options that let the client turn off (but not on) rendering
if (!sRenderMyPlayer)
renderPlayer = false;
}
if (mShapeInstance && renderPlayer && DetailManager::selectCurrentDetail(mShapeInstance))
{
mShapeInstance->animate();
mShapeInstance->render();
}
GFX->popWorldMatrix();
PROFILE_END();
return;Basically took parts of the commented out code and moved them up and just verified that it handled things properly. Normally would have Item/Object mount checking too, but haven't bothered to rehook that into the rendering flow yet.
Josh's piece of code is cleanest for no other options, but when certain parts are re-implemented or whatever, it may have to be modified or moved around, similiar to what I have
and getConnectionToServer() is proper for MS3+
#9
04/15/2006 (4:07 pm)
Glad it somewhat-works.
#10
@Josh or Jeremiah, would it be possible to have a little more specific location, since I believe there have been a few changes in TGEA since these fixes were posted (of course the problem itself hasn't been)
Or if anyone else has the current fix location I'd appreciate it. I've dropped the code(s) in all over the place in both shapebase and player, no errors, but the player is still being rendered in first person.
Thanks for your patience with a non coder.
10/15/2007 (9:51 am)
Hate to dredge up an old thread, but I'm having a little trouble finding where to implement either of these changes.@Josh or Jeremiah, would it be possible to have a little more specific location, since I believe there have been a few changes in TGEA since these fixes were posted (of course the problem itself hasn't been)
Or if anyone else has the current fix location I'd appreciate it. I've dropped the code(s) in all over the place in both shapebase and player, no errors, but the player is still being rendered in first person.
Thanks for your patience with a non coder.
#11
The way we do it now is by duplicating prepRenderImage from ShapeBase, making sure to also copy the declaration from the ShapeBase header to Player's header.
That is a snippet of the function, you'd then put this in:
Note: there isn't really anything to deal with items yet, havent experimented
The final addition would be adding:
before the final prepBatchRender function call at the end of the function
10/17/2007 (11:55 am)
Yep, renderImage was removed.The way we do it now is by duplicating prepRenderImage from ShapeBase, making sure to also copy the declaration from the ShapeBase header to Player's header.
// 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;
}
}
INSERT CODE HERE -----
if( state->isObjectRendered(this) || gClientSceneGraph->isReflectPass() )
{That is a snippet of the function, you'd then put this in:
// 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;
}Note: there isn't really anything to deal with items yet, havent experimented
The final addition would be adding:
// jwf - Prep the Batch Render, only if we want to be rendered if (mShapeInstance && renderPlayer && DetailManager::selectCurrentDetail(mShapeInstance))
before the final prepBatchRender function call at the end of the function
#12
I think it probably has to do with the fact that I'm not sure what this means:
I'm going to have my son Kyle look at it later this evening, since he actually knows what he's doing...as opposed to me, since I have trouble even copy an pasting things in the right place...
10/17/2007 (4:07 pm)
Alright Jeremiah, bear with me on this, all seems ok but I get a single error,C:\Torque\TGEA_1_0_3\engine\game\player.cpp(2055): error C2039: 'renderFirstPerson' : is not a member of 'ShapeBaseData'
I think it probably has to do with the fact that I'm not sure what this means:
Quote:making sure to also copy the declaration from the ShapeBase header to Player's header
I'm going to have my son Kyle look at it later this evening, since he actually knows what he's doing...as opposed to me, since I have trouble even copy an pasting things in the right place...
#13
You can add those in the player.h under
10/18/2007 (6:44 pm)
Oh.. Didn't even think about that part :)bool renderFirstPerson; ///< Render the player shape in first person bool renderItems; ///< Render items in first person
You can add those in the player.h under
struct PlayerData: public ShapeBaseData {
typedef ShapeBaseData Parent;
enum Constants {
RecoverDelayBits = 7,
JumpDelayBits = 7,
NumSpineNodes = 6,
ImpactBits = 3,
NUM_SPLASH_EMITTERS = 3,
BUBBLE_EMITTER = 2,
};
#14
I was just trying to implement your solution, but I got a crash on startup. Basically, whenever the prepBatchRender didn't get run, it would crash TGEA. Are you sure you don't have an else part of that if statement?
Sorry, I'm not a coder and I appreciate your sharing.
lee
10/28/2007 (7:11 pm)
Hi Jeremiah,I was just trying to implement your solution, but I got a crash on startup. Basically, whenever the prepBatchRender didn't get run, it would crash TGEA. Are you sure you don't have an else part of that if statement?
Sorry, I'm not a coder and I appreciate your sharing.
lee
#15
10/28/2007 (7:19 pm)
Hm it ocurrs to me that one thing you were not explict about was where in player.h to declare Player::prepRenderImage. Does it matter, much?
#16
void unpackUpdate(NetConnection *conn, BitStream *stream);
11/03/2007 (12:16 pm)
It shouldn't matter, but its just at the very bottom undervoid unpackUpdate(NetConnection *conn, BitStream *stream);
#17
GFXPrimitive *info = &mCurrentPrimitiveBuffer->mPrimitiveArray[primitiveIndex];
Inside of the void GFXDevice::drawPrimitive( U32 primitiveIndex ) function, which is in the gfxDevice.cpp file.
Any ideas?
And thank you for helping out with this.
Mike
11/03/2007 (2:59 pm)
I'm having the same problem as Lee from above is. When I run the engine with these fixes, it crashes after it loads the objects. More specifically, it appears to crash on this call:GFXPrimitive *info = &mCurrentPrimitiveBuffer->mPrimitiveArray[primitiveIndex];
Inside of the void GFXDevice::drawPrimitive( U32 primitiveIndex ) function, which is in the gfxDevice.cpp file.
Any ideas?
And thank you for helping out with this.
Mike
#18
void GFXDevice::drawPrimitive( U32 primitiveIndex )
in GFXDevice.cpp change the lines:
and put an if statement around these lines so they look like this:
it will stop the crashing and actually works. The only issue is that it doesn't update the player shadow in first person. But, that's another problem for another day.
11/05/2007 (3:12 pm)
I think I may have found a solution to the game crashing. If you go into void GFXDevice::drawPrimitive( U32 primitiveIndex )
in GFXDevice.cpp change the lines:
GFXPrimitive *info = &mCurrentPrimitiveBuffer->mPrimitiveArray[primitiveIndex]; // Do NOT add index buffer offset to this call, it will be added by drawIndexedPrimitive drawIndexedPrimitive( info->type, info->minIndex, info->numVertices, info->startIndex, info->numPrimitives );
and put an if statement around these lines so they look like this:
if (mCurrentPrimitiveBuffer.isValid()){
GFXPrimitive *info = &mCurrentPrimitiveBuffer->mPrimitiveArray[primitiveIndex];
// Do NOT add index buffer offset to this call, it will be added by drawIndexedPrimitive
drawIndexedPrimitive( info->type, info->minIndex, info->numVertices, info->startIndex, info->numPrimitives );
}it will stop the crashing and actually works. The only issue is that it doesn't update the player shadow in first person. But, that's another problem for another day.
#20
11/05/2007 (8:16 pm)
People are/were still having trouble with this? It's worked out of the box for me since TGEA 1.0 I think.
Associate John Kanalakis
EnvyGames
function PlayGui::onWake(%this)
{
...
$firstPerson = false;
...
}