Game Development Community

3rd-person only weapon models fix

by Drew Hitchcock · in Torque Game Engine · 01/12/2005 (1:22 pm) · 2 replies

Well, I did some lazy searching and didn't find anything about this, so I figured I'd share this with everyone.

The ShapeBaseImageData datablock has a field named "firstPerson" which, when set to false, is supposed to prevent the mounted image from being drawn in 1st person view. In practice, however, it doesn't do anything at all. In fact, it's not used in any meaningful way in the code that I could find, with the exception of the basic datablock addField/packData stuff.

It turns out this was really easy to fix. In shapebase.cc, around line 2178, you'll see this:

...
        if (image.dataBlock && image.shapeInstance)
         {
             DetailManager::selectPotentialDetails(image.shapeInstance,dist,invScale);
...

Change it to this:

...
        if (image.dataBlock && image.shapeInstance)
         {
			 [b]if(image.dataBlock->firstPerson || !isFirstPerson())
			 {[/b]
	        DetailManager::selectPotentialDetails(image.shapeInstance,dist,invScale);
...

Then add a closing brace around line 2207

state->setImageRefPoint(this, rimage);
				state->insertRenderImage(rimage);
				}
[b]			}[/b]
       }
      }
      TSShapeInstance::smScreenError = saveError;

Then if you want a weapon to only display in 3rd person mode, just add this to its datablock:

firstPerson = false;

I'm not sure if this qualifies as a bug or not, but it seemed like an incomplete feature or maybe an oversight, so I posted it in this section.

Hopefully this helps someone out. Let me know if I made any mistakes :)

EDIT: formatting...

#1
01/12/2005 (1:29 pm)
Nice, needed this for my game - thanks!
#2
02/20/2005 (7:01 pm)
Thanks I was very frustrated when firstPerson wasn't working; this fixes that and gives me an idea for other tweaks.