First/Third Person Different Weapon Models
by Chris Byars · 02/23/2006 (10:49 am) · 41 comments
This resource will allow you to have different weapon models for first and third person perspective, so the addition of high quality hands and weapon models in first person are possible without them being visible in third person view.
Now this is a cheap hack, and there's more you can do with it than I'm going to show here, as my knowledge is limited in C++ :)
One code change is all it takes. In engine/game/player.cc, in void Player::renderMountedImage(SceneState* state, ShapeImageRenderImage* rimage), change
IF YOU ARE USING TSE IN MILESTONE 3.5 OR LATER
The image rendering code has been moved to shapeBase.cpp.
In engine/game/shapeBase.cpp, in void ShapeBase::prepBatchRender(...), change:
What this does is, if you are in first person view, the weapon image will render at LOD 1. This LOD will contain the arms/hands and their animations as well as the weapon. All other LODs above 1 will render normally, so you make your LOD 2 the mesh that you want visible in third person view (without hands/arms).
Yes it's cheap, and you won't see your reload animations or anything like that in third person, so if you want those too you will need to script or code in some synchronizing with the player model and the weapon model's animations.
Screenshots:
First Person
Third Person
For reference:
http://www.garagegames.com/mg/forums/result.thread.php?qt=6702
Now this is a cheap hack, and there's more you can do with it than I'm going to show here, as my knowledge is limited in C++ :)
One code change is all it takes. In engine/game/player.cc, in void Player::renderMountedImage(SceneState* state, ShapeImageRenderImage* rimage), change
image.shapeInstance->render();to
if(fogExemption == true)image.shapeInstance->render(1); else image.shapeInstance->render();
IF YOU ARE USING TSE IN MILESTONE 3.5 OR LATER
The image rendering code has been moved to shapeBase.cpp.
In engine/game/shapeBase.cpp, in void ShapeBase::prepBatchRender(...), change:
image.shapeInstance->render();to
if(isFirstPerson())
{
image.shapeInstance->render(1);
}
else
{
image.shapeInstance->render();
}What this does is, if you are in first person view, the weapon image will render at LOD 1. This LOD will contain the arms/hands and their animations as well as the weapon. All other LODs above 1 will render normally, so you make your LOD 2 the mesh that you want visible in third person view (without hands/arms).
Yes it's cheap, and you won't see your reload animations or anything like that in third person, so if you want those too you will need to script or code in some synchronizing with the player model and the weapon model's animations.
Screenshots:
First Person
Third Person
For reference:
http://www.garagegames.com/mg/forums/result.thread.php?qt=6702
#2
@Tim Heldna, Yep I agree and I'd even pay for it:)
02/21/2006 (2:19 pm)
@C2,Thanks for the resource. @Tim Heldna, Yep I agree and I'd even pay for it:)
#3
Thanks
02/23/2006 (3:20 pm)
Great resource, I have been waiting for awhile for someone to post a resource like this. But I have came across a problem and I'm not sure it just me. I'm using the soldier pack and when I have nothing mounted like the helmet or rucksack, it runs fine but when I try mounting the helmet or rucksack the game crashes. I don't know if its the code or the models. Could someone help me with this because I would like the use the other mount points on the soldier.Thanks
#4
-Jase
02/23/2006 (5:34 pm)
Just as a side note, in TST Pro it shows that LODs actually start at 0. So if you are having trouble making this resource work, try passing 0 instead of 1 into the render function.-Jase
#5
@Jase: 0 may work for some, but with my DTS exporter, LOD 0 is unrendered, so 1 was my only option, and works thus far flawlessly.
02/23/2006 (5:40 pm)
@Stephen: Didn't think of that, if they're mounted as images and don't have LOD set up as per the resource, it will crash.@Jase: 0 may work for some, but with my DTS exporter, LOD 0 is unrendered, so 1 was my only option, and works thus far flawlessly.
#6
02/23/2006 (6:28 pm)
I have tried to change the LODs and I can't get it to work, can you share your weapon model for a example?
#7
This model may be used for reference use only:
XM8, complete with arms, muzzle flash, animations (bob, fire, reload, activate), and LOD for 1st/3rd
02/23/2006 (7:46 pm)
It's a Milkshape 3D model, using the Torque DTS Plus Exporter.This model may be used for reference use only:
XM8, complete with arms, muzzle flash, animations (bob, fire, reload, activate), and LOD for 1st/3rd
#8
02/23/2006 (9:07 pm)
Using 3ds max 6 LOD 0 seems to work better (just for reference).
#9
I think I figured out why the game was crashing when I used the mountpoints. It was that they didn't have any LODs like the weapon. They just had LOD0, so I fixed it where there is 2 different LODs 1 and 2.
02/24/2006 (7:17 am)
Thankyou C2 for share your model!I think I figured out why the game was crashing when I used the mountpoints. It was that they didn't have any LODs like the weapon. They just had LOD0, so I fixed it where there is 2 different LODs 1 and 2.
#10
02/24/2006 (11:01 am)
Like I said. :P
#12
Any ideas on what's causing this and suggestions for a fix?
Edit: Just discovered if you disable the eyeOffset in your weapons ShapeBaseImageData section emapping works as it should.
03/13/2006 (11:27 am)
Just noticed something, with this resource implemented environment maps on the weapons don't work properly. Has anyone else noticed this? The emap still shows up on the weapon but remains static with mouse movement, if an animation is played you can see the emap moving. Also in 3rd person the emap works fine.Any ideas on what's causing this and suggestions for a fix?
Edit: Just discovered if you disable the eyeOffset in your weapons ShapeBaseImageData section emapping works as it should.
#13
03/19/2006 (8:30 am)
Edit
#14
03/19/2006 (6:14 pm)
Are you using an eyeOffset?
#15
03/30/2006 (6:39 pm)
Edit
#16
04/23/2006 (10:48 am)
Why'd you delete your last two posts C2?
#17
04/23/2006 (3:09 pm)
Realized I didn't check environment maps, heh.
#18
04/23/2006 (10:24 pm)
So they're not working for you either?
#19
Who is a lod....
Help my please for use this resource...
My problem is?....
THANKS
05/01/2006 (7:12 am)
Why my game crash?!?!?Who is a lod....
Help my please for use this resource...
My problem is?....
THANKS
#20
Are you guys using eyeOffsets and do they do anything? I'm just now revisiting this after a few months doing some other stuff, and I can't seem to be able to change my first person eyeOffset, and for the life of me, I can't remember I had been able to do so.
Thanks,
- Alan
05/10/2006 (10:10 pm)
@Tim and/or C2Are you guys using eyeOffsets and do they do anything? I'm just now revisiting this after a few months doing some other stuff, and I can't seem to be able to change my first person eyeOffset, and for the life of me, I can't remember I had been able to do so.
Thanks,
- Alan

Torque Owner Tim Heldna
As good as it is (compared to a floating, armless, motionless gun), it would be ideal to have two seperate models, one for each view. If someone were to contribute such a thing i'm sure many people would be forever in debt and extremely greatful :)