Game Development Community

First Person Weapon Model?

by XoCluTch · in Torque Game Engine · 08/18/2002 (10:17 am) · 128 replies

Hey,
I am trying to make a change to the engine so when the player is in First Person model of the weapon he see's will differ from the weapon he see's in Third Person or to anyone else looking at him.

Does anyone know how i can perform a engine change like this? I'm pretty good at coding changes to the engine. But this might be a little over my head =P

Any help is Welcome..


Thanks,
XoCluTch
#81
11/12/2005 (3:03 pm)
@Duncan "OziMan": "...the render function takes a parameter for the detail level and you can make some code changes to force it to the highest detail level when in 1st person mode..."

Think you could put up the code changes necessary to get the LOD forcing when in first person to work? That's all I need to get this working. :D
#82
11/12/2005 (4:48 pm)
@C2, I'm up to me ears in my own debug and development work. I'm convinced you won't need to make a code change if you set your detail levels in the mesh correctly. i.e. set your 1st person mesh LOD level to something like 300 or more, 2nd detail level to 120 then 80,60,40 etc

If you REALLY need to make a code change then look at the render methods in \ts\TsShapeInsyance.cc. The render functions all take a detail level as first parameter...
void TSShapeInstance::render(S32 dl, F32 intraDL, const Point3F * objectScale)

Therefore, go to player.cc and find void Player::renderImage(SceneState* state, SceneRenderImage* image)

Now in that method, locate the mShapeInstance->render(); What you want to do is call the render with a parameter of 0 (highest detail level) when in first person mode. Fortunately, just a few lines up from the render call is a test for 1st person which sets the fogExemption variable to true when in first person.

So just change the render call to something like
if(fogExemption)mShapeInstance->render(0);
else mShapeInstance->render();

I have not tested it but it might just work as is or require some minor debugging.
#83
11/12/2005 (6:06 pm)
Just curious.....would you want to make that LOD like huge like 10,000 or something....just cause what if somebody had their game resolution set at 1600x1200 and was standing and looking really close at the weapon model....then the hands would show up.
#84
11/12/2005 (6:17 pm)
I don't think those C++ changes work. Doesn't seem to be forcing LOD here. :/
#85
11/12/2005 (8:47 pm)
@C2, sorry can't help any further. I suggest you debug it and make sure the fogExemption variable changes when you change from 1st to 3rd etc.

Also hardcode the render parameter just as a test, try different LOD levels and see what happens, i.e I'm not sure if highest LOD level = 0 or 1
#86
11/12/2005 (8:58 pm)
@C2, ok, had another look. There is another function in player.cc which seems to be used for rendering mounted objects, like weapons.

void Player::renderMountedImage

Try making the same change there
#87
11/12/2005 (9:17 pm)
For fun i was playing around on the torque show room tool......i could get in really close....just so its about to start clipping the object......and the projected pixel size was 20,000
#88
11/13/2005 (9:52 am)
:O

IT WORKS!!!11oneomg

Yep. Got it working. Excellent. Amazing. Perfection.

I have made LOD 1 be the first person view version of the model, and LOD 2 be everything else.

In void Player::renderMountedImage(SceneState* state, ShapeImageRenderImage* rimage), you change image.shapeInstance->render(); to:

if(fogExemption == true)image.shapeInstance->render(1);
      else image.shapeInstance->render();

Make LOD 1 be your first person LOD with the arms and hands and those animations, and make LOD 2 and up be the regular model and animations you want displayed in 3rd person.

:D
#89
11/13/2005 (11:12 am)
AWESOME !!!!!!!, post some pics if you can.

uhm, I asume you changed the orginal render() call and not the animate() call as you post says
#90
11/13/2005 (12:03 pm)
Heh yeah render(), edited. :P

Will post screenies once I stick the arms/hands on and get the LODs and animations synched. Still a little new to how LOD is managed in modeling, but soon I'll stick up screens. :)

Oh a note: This will cause your game to crash if you swap to a weapon that only has one LOD. You must have an LOD 1 mesh and an LOD 2. And so forth. If all your meshes are LOD 1 it will crash.
#91
11/14/2005 (7:24 am)
So, are you saying the two 'models/LODs' are within the same dts file? or that you can use two separate dts shapes to acheive the FPS effect of highly detailed hands and weaponery?
#92
11/14/2005 (7:54 am)
There in the same file.......i made 3 LODs for my weapon model last night...the closest being around 2000.....farthest away being around 400
#93
11/14/2005 (9:20 am)
This is cool. I made a suggestion to our team awhile back about trying to implement hand animation this way using LOD. Kudo's for working this out:)
#94
11/26/2005 (10:39 am)
@Duncan: Got some screens of this in action finally. :)
It's great, full support for both first and third person animation, separately.

First Person:
www.ion-productions.com/preview/1st.jpg

Third Person:
www.ion-productions.com/preview/3rd.jpg
#95
11/26/2005 (10:40 am)
Looks sweet C2
#96
11/26/2005 (11:18 am)
Very nice.
#97
11/26/2005 (11:35 am)
I found only one minor flaw; the player's shadow has the player holding the 1st person version of the model. Hardly noticeable except by the developer, of course, but you can see a larger weapon than should be in the shadow. (Seeing the hands/arms shadow)
#98
11/26/2005 (12:15 pm)
Nice! So the only code change that's needed is in- void Player::renderMountedImage... right?
Thanks
#99
11/26/2005 (12:45 pm)
That's right. :)
#100
12/09/2005 (1:05 am)
@C2

Thanks for the resource. It works great.

I'm having a similar problem in regards to the shadows, except that my 1st person shadows cast is rotated. I think that it's a node/joint rotation problem, but I though I'd get a second (or third) opinion. I'm really just so tired of moving things around from fragmotion to milkshape and rotating them and... well you know the rest, that I just wanted an excuse to take a break.

www.reallyreallygoodthings.com/screenshot_shadow1.jpg
www.reallyreallygoodthings.com/screenshot_shadow2.jpg
www.reallyreallygoodthings.com/screenshot_shadow3.jpg
www.reallyreallygoodthings.com/screenshot_shadow3.jpg
Thanks again
- Alan
reallyreallygoodthings.com