Game Development Community

Turn off Player Render

by Timothy Castagna · in Torque Game Engine Advanced · 09/05/2008 (1:05 pm) · 22 replies

Anyone know how to make it so the player body does not render when in first person. renderfirstperson = false does not work. Thanks.
Page «Previous 1 2
#1
09/10/2008 (10:58 am)
Anyone?
#2
09/10/2008 (11:12 am)
It is currently broken in TGEA, feel free to port the missing code from TGE to get it working
#3
09/10/2008 (12:22 pm)
I got some options. If you don't want anything on the player rendered at all (like mounted weapons that would stick out in front and normally be rendered) you could do:

if(con->isFirstPerson())
	  {
		  PROFILE_END();
		  return false;
	  }

In shapeBase.cpp in prepRenderImage on line 2287.

If that's not what you're looking for I can cook something up, let me know.
#4
09/10/2008 (2:05 pm)
Yea thats not what i want...basically i dont want to see legs when i look down. I'm gong to model the player hands and have them attached like how half life 2 does it.
#5
09/10/2008 (7:44 pm)
I was thinking of the best way to do this at work. What I came up with is overriding prepRenderImage and renderImage in Player and calling Parent on prep if we're not a client and/or not in first person. Then dismissing renderImage if we're not a client and/or not first person. This will keep the performance boost of the batch rendering in ShapeBase for everything other then the first person client player.

I'll see if I can throw something together and let you optimize. You seem perfectly capable. :)
#6
09/10/2008 (8:08 pm)
Less work then I thought. No thorough testing, worked fine for me. Let me know

add the prepRenderImage declaration in player.h and add the following in player.cpp

bool Player::prepRenderImage(SceneState* state, const U32 stateKey, 
							 const U32 startZone, const bool modifyBaseZoneState)
{
	GameConnection *con = getControllingClient();
	if(con && con->isFirstPerson())
	{
		// Return if last state.
		if (isLastState(state, stateKey)) return false;
		// Set Last State.
		setLastState(state, stateKey);

		// Is Object to be endered?
		if (state->isObjectRendered(this))
		{	   
			RectI viewport = GFX->getViewport();
			MatrixF proj = GFX->getProjectionMatrix();
			GFX->pushWorldMatrix();

			MatrixF world = GFX->getWorldMatrix();
			TSMesh::setCamTrans( world );
			TSMesh::setSceneState( state );
			TSMesh::setCubemap( mDynamicCubemap );
			TSMesh::setObject( this );
			TSMesh::setOverrideFade(mFadeVal);


			gClientSceneGraph->getLightManager()->setupLights(this);

			Point3F cameraOffset;
			getRenderTransform().getColumn(3,&cameraOffset);
			cameraOffset -= state->getCameraPosition();
			F32 dist = cameraOffset.len();
			F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));

			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)
					{
						MatrixF mat;
						getRenderImageTransform(i, &mat);
						GFX->setWorldMatrix( mat );

						image.shapeInstance->animate();
						image.shapeInstance->render();
					}
				}
			}
			gClientSceneGraph->getLightManager()->resetLights();


			GFX->popWorldMatrix();
			GFX->setProjectionMatrix( proj );
			GFX->setViewport( viewport );

			TSMesh::setOverrideFade(1.0f);
		}

		return false;
	}

	return Parent::prepRenderImage(state,stateKey,startZone,modifyBaseZoneState);
}

Code pulled from ShapeBase::prepRenderImage and ShapeBase::prepBatchRender.

Hope it works out.
#7
09/10/2008 (8:36 pm)
Ahh I forgot to select the detail.

add
&& DetailManager::selectCurrentDetail(image.shapeInstance)

in the if(mCloakLevel conditional.

Edit* One more note. You might be able to remove the call to state->isObjectRendered. I couldn't think of an instance where a client connection that is first person would not render the player...
#8
09/11/2008 (8:22 am)
Thanks William, I'll give this a try tonite.
#9
09/11/2008 (8:24 pm)
Any results?
#10
09/17/2008 (10:41 am)
It works for the most part but there is a little glitching going on. when i move the mouse around it the mounted item some disapears for a second. its like there is a "hot spot" where it won't render the weapon image.
#11
09/17/2008 (10:45 am)
Nevermind, had to delete my dso files then it works. Thanks!!
#12
09/17/2008 (12:47 pm)
Glad I could help. :)
#13
09/18/2008 (12:45 am)
Ehm

sorry for my stupid question ....

but player::prepRenderImage where go in the engine to test it ???
in other words Where I must do the modifications in which code and where for test this code ???

Thanks

^_^
#14
09/18/2008 (12:50 am)
Hi Andrea,

As posted above, in player.h add the declaration. in player.cpp add the code that I posted.

player.h
bool prepRenderImage(SceneState* state, const U32 stateKey, 
							 const U32 startZone, const bool modifyBaseZoneState)

and above is the code for player.cpp. It can go anywhere in the file.
#15
09/18/2008 (2:03 am)
I have implemented the code but where i use the function ???
#16
09/18/2008 (2:05 am)
Interesting question.

I'd say, if you don't know what something does, you shouldn't use it.

But, to answer it. You don't do anything to "use" the function. It uses itself. To "see" the changes, go into first person.
#17
09/18/2008 (2:07 am)
Sorry but now during the test in the game i see it good !!! Thanks and sorry for the question !

^_^

THANKSSSSSS
#18
09/18/2008 (2:09 am)
No need to apologize. I just find it interesting that you'd want to use something without knowing what it does.
#19
03/09/2009 (12:06 pm)
hi there,
I recently implemented this, and it works fine, except that if I get near to a vehicle (to mount it), or near to an AI player, torque crashes telling me that "obj" cant be found.
it throws the 00005x00002 error, which has something to do with not enough buffersize.

can anyone help? I'd really like to get this working properly

BTW, if I "tab" to third person, then "tab" back to first person, then there are no problems whatsoever
#20
03/09/2009 (12:09 pm)
@deepscratch - this is fixed in 1.8.0 and 1.8.1. What version are you using?
Page «Previous 1 2