RenderFirstPerson - Vehicles and TSE
by Jacobin · in Torque Game Engine Advanced · 04/01/2007 (9:15 pm) · 5 replies
Greetings,
I decided to toy with some ideas I had using TSE, as it finally reached the release stage. It involves vehicles so decided to buy a few of the bravetree packs to prototype with.
The problem I'm having is illustrated by the following screenshot. I want to have the player, vehicle he's mounted upon and all attached imageshapes not render if the client is in firstperson view. Hell, if you look in the top right even his nametag is floating up in the distance! I wish to do this so I can display my own HUD with vehicle/ammo metrics. Akin to a dashboard.
i13.tinypic.com/33c14xv.jpg
So I decided to do the obvious. Just open up the code and replicate/extend the RenderFirstPerson bypass that already exists, getting rid of arms and the vehicle.
[pseudo]
If (FirstPersonMode) {
If I'm a player and I'm mounted on a vehicle: return;
If I'm a vehicle and I'm mounted by a player; return;
}
[\pseudo]
Easy right? I was then shocked to discover that while RenderFirstPerson is still defined in player.h, it didn't appear to be used anywhere outside of player.cpp! No wonder it appeared to have no effect in TSE. I looked elsewhere in the code and found in shapebase.cpp the prepRenderImage() function but am a little bit confused. It seems at a point to iterate through maxmountedimages++ yet preRenderObject() doesn't seem to do much. Is this the function in which to insert my bypass? Would the IsPilot/IsMounted console methods work?
Any guidance would be appreciated as I'm a little lost.
I decided to toy with some ideas I had using TSE, as it finally reached the release stage. It involves vehicles so decided to buy a few of the bravetree packs to prototype with.
The problem I'm having is illustrated by the following screenshot. I want to have the player, vehicle he's mounted upon and all attached imageshapes not render if the client is in firstperson view. Hell, if you look in the top right even his nametag is floating up in the distance! I wish to do this so I can display my own HUD with vehicle/ammo metrics. Akin to a dashboard.
i13.tinypic.com/33c14xv.jpg
So I decided to do the obvious. Just open up the code and replicate/extend the RenderFirstPerson bypass that already exists, getting rid of arms and the vehicle.
[pseudo]
If (FirstPersonMode) {
If I'm a player and I'm mounted on a vehicle: return;
If I'm a vehicle and I'm mounted by a player; return;
}
[\pseudo]
Easy right? I was then shocked to discover that while RenderFirstPerson is still defined in player.h, it didn't appear to be used anywhere outside of player.cpp! No wonder it appeared to have no effect in TSE. I looked elsewhere in the code and found in shapebase.cpp the prepRenderImage() function but am a little bit confused. It seems at a point to iterate through maxmountedimages++ yet preRenderObject() doesn't seem to do much. Is this the function in which to insert my bypass? Would the IsPilot/IsMounted console methods work?
Any guidance would be appreciated as I'm a little lost.
#2
I was able to turn off rendering of the vehicle with the above code changes in shapebase::prepRenderImage(). Thing is, the mounted player itself is still drawn. As the player is mounted to the vehicle (the controlling object) I would have thought that co->getObjectMount() == this would have caught it and caused the mounted player's render to be bypassed as well. Any advice?
04/02/2007 (6:23 pm)
// 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)
{
[b] // First person render bypass for vehicle HUD display
if((co->getType() & VehicleObjectType) &&
(isFirstPerson()) )
return false; [/b]
TSShapeInstance::smScreenError = 0.001;
fogExemption = true;
}
}I was able to turn off rendering of the vehicle with the above code changes in shapebase::prepRenderImage(). Thing is, the mounted player itself is still drawn. As the player is mounted to the vehicle (the controlling object) I would have thought that co->getObjectMount() == this would have caught it and caused the mounted player's render to be bypassed as well. Any advice?
#3
04/03/2007 (1:40 am)
FYI! I would also like this code... :-)
#4
This being the case if the code (according to it's comment) is looking for the control object's mounted images and not the object which the control object is mounted to, should not the following conditional...
Actually be written as follows?
Either way the getObjectMount conditional never seems to be triggered and the player is still being drawn. I've tried just about every approach to it, such as test code like the following.
Nothing I tried seems to be the ticket. Either something is wrong with my understanding, the way I'm approaching this or getObjectMount() is broken. I highly doubt the latter considering it's wide arcing usage. It'd be really nice if that long list of associates and employees posting over in the "OMG TSE IS ONLY BETA QUALITY!" thread could chime in and offer a guy their 2 cents.
04/03/2007 (10:50 am)
Quote:getObjectMount()
Purpose
Use the getObjectMount method to get the ID of the object this object is mounted to.
Returns
Returns an integer value representing the ID of an object that this shape is mounted to, or 0 if this object is not mounted to another object.
This being the case if the code (according to it's comment) is looking for the control object's mounted images and not the object which the control object is mounted to, should not the following conditional...
if(co == this || co->getObjectMount() == this)
Actually be written as follows?
if( (co == this) || (this->getObjectMount() == co) )
Either way the getObjectMount conditional never seems to be triggered and the player is still being drawn. I've tried just about every approach to it, such as test code like the following.
if( (this->getType() & PlayerObjectType) && (this->getObjectMount() == co)) return false;
Nothing I tried seems to be the ticket. Either something is wrong with my understanding, the way I'm approaching this or getObjectMount() is broken. I highly doubt the latter considering it's wide arcing usage. It'd be really nice if that long list of associates and employees posting over in the "OMG TSE IS ONLY BETA QUALITY!" thread could chime in and offer a guy their 2 cents.
#5
The above appears to work. Tried to make the order of the conditions as exclusionary as I could for efficiency inside this oft called routine. I appreciate everyone who took the time to lend their assistance.
04/03/2007 (8:33 pm)
GameConnection *con = GameConnection::getConnectionToServer();
ShapeBase *co = NULL;
F32 saveError = TSShapeInstance::smScreenError;
bool fogExemption = false;
if(con && ( (co = con->getControlObject()) != NULL) )
{
// First person render bypass for vehicle HUD
if( (co->getType() & VehicleObjectType) && (co->isFirstPerson()) )
if( (co==this) || ((this->isMounted()) && (co->getMountedObject(0) == this)))
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 :)
if(co == this || co->getObjectMount() == this) {
TSShapeInstance::smScreenError = 0.001;
fogExemption = true; }
}The above appears to work. Tried to make the order of the conditions as exclusionary as I could for efficiency inside this oft called routine. I appreciate everyone who took the time to lend their assistance.
Torque Owner Stefan Lundmark