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
Page «Previous 1 2 3 4 5 6 7 Last »
#1
08/19/2002 (1:21 am)
I'm fairly sure that the weapon that is shown 1st person is already a different model than the one shown in 3rd person. It used to be the same but was changed. If you've not updated in a long time (pre-1.1.1?), then you can update your source to fix this.

From a quick look at crossbow.cs it seems datablock ItemData(Crossbow) defines the actual mounted dts, and datablock ShapeBaseImageData(CrossbowImage) defines the one that is seen in 1st person.

I'm sure someone useful will be along in a moment, as I'm not exactly the best person to answer this, but there are previous threads that discuss this.
#2
08/19/2002 (2:33 am)
Are you sure?
#3
08/19/2002 (5:52 am)
I'm pretty sure the ItemData is the weapon or item that exits in the world (when it's dropped or something). The ShapeBaseImageData is the mounted image. As far as I know there's not a different image used for 1st and 3rd person. The 1st person weapon offset and eye offset can be changed.
#4
08/19/2002 (12:14 pm)
Yes, that's what I thought ... Only the one that exsisted in the world differed from the one that was mounted but the 1st and 3rd person models where the same.


But I have noticed that when i am looking at my player in third person and i am not moving he holds his gun off to the side of him ( just a bug in the model) but when i go to third person he is holding it in the middle of the screen. So this kind of tells me that all i would need to do is change what model it uses maybe with only a few lines of code for third and first... cause it seems to me it already mounts and shows them differently... I don't know... i'll have to look at the engine code for this.. I havn't even start working on the code yet i've been busy on my radar
#5
08/19/2002 (12:19 pm)
I thought the same model is used regardless of the mode you're in. I added a new weapon model, but I only created one instance of it.
#6
08/19/2002 (12:33 pm)
Yep, it uses the same model. The reason for the static weapon image you see in first person is the eyeOffset setting in the ShapeBaseImageData section. This positions the weapon on the screen for first person use. You see where the weapon is really mounted in 3rd person view.
Change the eyeOffset to this:
eyeOffset = "0 0 0";
and you'll see the weapon in first person view according to where it's actually mounted on the player model (very low and to the right on the default blue guy). It will also move and recoil with the player model.
#7
08/20/2002 (4:09 am)
Oops, maybe it was the offset they added in the later versions then. I knew it had changed since the crimeforce demo. I was also under the impression that the crossbow in realm wars differed between the two views! ;)

There is another thread that discussed this somewhere (and the merits of both versions). Guess I grabbed the wrong end of the stick!

Trouble is i've modelled all my weapons seperatly now (a low res one for the model and a high res one for the player view!). Guess i'll have to look into adding this functionality then.

Can't be far off that functionality at the moment though, as the offset weapon definatly isn't a world object.
#8
08/20/2002 (5:28 am)
Someone else mentioned doing what you are talking about using two different models. I'm not sure if anything came of it but you might want to search the forums or post a seperate thread about it.
#9
08/25/2002 (3:02 am)
Nothing came out of the previous topics about this. They all ended up in discussion wether this is a good or a bad thing todo. Looks like a lot of people are interested in this tough. If you work on this please post your findings here so everyone can profit from it.
I still believe it can be done with just a few lines of code, wouldn't make much sense to redo a whole lot of engine code just becuase of this.
One solution could be LOD.... the closest lod could have hands and other animations.... so you'll always see that model in first person. In third person you normally wouldn't see the hands and the animations (becuase you're viewing another LOD)... but when you walk up really close to the player you'll see the same LOD he sees in first person tough and everything is screwed up again. This is however the closest to the solution we are looking for.... but we need a better solution, a real working one! So I can have my 800 poly hands holding the weapons ;)
#10
08/25/2002 (8:08 am)
I talked to the GG guys about this, and although no solution was decided upon, the genral consensus was that a split 1st and 3rd person weapon/hand arrangment was the best way to go.

The biggest problem with the 'old' system is that getting the weapon animations to look good in both 1st and 3rd person.

The biggest isssue now is how to create a set of hand animations that can be used in third person that don't require everyone to deal with all the issues that crop up when exporting characters.

Ideally, a default set of hands can be used for 3rd person, requiring most developers to only change the weapon model and have it mounted on these hands. If one wanted custom hands, they can make new weapon/hand animations, but it would not require adding hands to all weapon models.
#11
08/25/2002 (9:23 am)
Quote:
The biggest isssue now is how to create a set of hand animations that can be used in third person that don't require everyone to deal with all the issues that crop up when exporting characters.

The biggest issue is that the code is simply not there.. and altough it seems like a simple task no one (or at least no one wants to share) has succeeded splitting it up.
I wouldn't worry about exporter probs etc. Its no different then exporting a regular gun. There are just hands attached in the model and those hands are animated. Having 1 pair of hands and use that for all weapons won't do it... guns are held in a very different way.... it wouldn't look good for all weapons. So, I what I would do is simply include the hands in all weapon dts files.
#12
08/25/2002 (10:06 am)
Quote:I wouldn't worry about exporter probs etc. Its no different then exporting a regular gun.

It is different. Getting a weapon shape into the game is easy. Getting a deformable mesh character exporting correctly is not as easy.

I agree with you that higher quality can be acheived with the 1st person weapon including a hand model.

If it were to be implemented with the hands in the gun model, it would exclude anyone who does not have at their disposal a 3D application to create and edit the hand/gun files.

I don't see the implementation as the biggest issue. If it is going to be a global solution, it should be designed to offer the maximum flexibility to the most people without sacrificing quality.
#13
08/25/2002 (10:43 am)
ic what you're saying....
anyway.. we have no problems with modelling/animating side of things.. perfect model and animations at our disposal.. only, we can't seem to get it coded in. You say Garagegames thinks about this... are they waiting for the community to do this and submit it, or is someone looking at this?
#14
08/25/2002 (11:25 am)
I think that they are busy working on the Players Site AND also waiting to see what the final Hand to Hand combat system looks like for RW (design wise).

They want to have a solution that will be robust, but will not limit the speed at which new weapons can be added to the game (i.e. requiring new hand anims be done to add a new type of axe, etc..)

They have been thinking about this issue (we talked specifically about this last time I met with them) but they want to have a solution that is fairly global so that it works for everyone.

All off the possible implementations have certain benefits and drawbacks. I think after they players site goes live they will have a little more time to think about it.

I am not thinking that they are waiting for someone else to do it, I think that they just have not gotten to it yet.

I am not sure what the official stance is on this though, might be worth asking them. =)
#15
12/21/2003 (7:17 pm)
Did any on ever manage to use a seperate model for first person?
#16
01/08/2004 (9:03 pm)
I am totally lost on how to split 1st and 3rd persin rendering...

This seems to be because its the same!

Ok I think this is how it works:

Quote:Player picks up an item, and mounts that items image to a slot.

This image is rendered on screen in xyz position for each client.

Render image at mount0 of the player for each client.

However if player belongs to us, then..

If in third person render at mount0 as normal.

But if in first person render it at an offset from players eye.

Either way theres only a single render call for an image.. just the render matrix that chnages..

Does anybody have an idea how to split this up into seperate images?

We cant mount 2 different images at same slot, and only render each in 1 view... :S
#17
01/08/2004 (10:30 pm)
Well here is what happens to determine where the image is rendered.

getMuzzleVector()
   getMuzzleTransform()
      getImageTransform()
         if were using an eye offset and where 1st person
         {
            set matrix to eye offset transform
         }else{
            set matrix to mount transform (mountPoint)
         }  
-----------------------------------------------------
getMuzzlePoint()
   getMuzzleTransform(2 params)
      getImageTransform()
-----------------------------------------------------
getRenderMuzzleVector()
   getRenderMuzzleTransform()
      getRenderImageTransform()
         if were using an eye offset and where 1st person
         {
            getRenderEyeTransform() // Returns eye to world space transform
               gets the transform of eyeNode  
         }else{
            set matrix to mount transform (mountPoint)
            getRenderMountTransform() // Returns mount point to world space transform
               mountTransform set to mountPoint Nodes transform
         }
-----------------------------------------------------
getRenderMuzzlePoint()
   getRenderMuzzleTransform()
      getRenderImageTransform()
         if were using an eye offset and where 1st person
         {
            getRenderEyeTransform() // Returns eye to world space transform
               gets the transform of eyeNode  
         }else{
            set matrix to mount transform (mountPoint)
            getRenderMountTransform() // Returns mount point to world space transform
               mountTransform set to mountPoint Nodes transform
         }
#18
01/17/2004 (9:21 am)
So to use seperate models for first person and third person, couldnt we just define a firstperson model in the image datablock, and the when itsays to render in first person, render the firstperson model instead.
#19
01/17/2004 (5:33 pm)
I have managed to use seperate dts models for first and third person, however it wont play any animations.

Heres What i did.

All chnages were in shapeImage.cc

In

ShapeBaseImageData::ShapeBaseImageData()

Add

fpshapeName = "";          //first person dts shape

In

ShapeBaseImageData::preload

change

if (shapeName && shapeName[0]) {

to

if (shapeName && fpshapeName && shapeName[0]) {

after

shape = ResourceManager->load(shapeName, computeCRC);

add

fpshape = ResourceManager->load(fpshapeName, computeCRC);

under that add

if (!bool(fpshape)) {
         dSprintf(errorBuffer, 256, "Unable to load shape: %s", fpshapeName);
         return false;
      }

At the bottom of the function above return add

TSShapeInstance* pfpDummy = new TSShapeInstance(fpshape, !server);
delete pfpDummy;

Ok in ShapeBaseImageData::initPersistFields()

add

addField("fpshapeFile", TypeFilename, Offset(fpshapeName, ShapeBaseImageData));

In ShapeBaseImageData::packData() Add

stream->writeString(fpshapeName);

And also in ShapeBaseImageData::unpackData() add

fpshapeName = stream->readSTString();

In MountedImage::MountedImage() Add

fpshapeInstance = 0;


Also in MountedImage::~MountedImage() Add

delete fpshapeInstance;

At the ends of the file, Add these 2 functions

void ShapeBase::setFirstPersonImage(U32 imageSlot)
{
	MountedImage& image = mMountedImageList[imageSlot];
	image.shapeInstance = new TSShapeInstance(image.dataBlock->fpshape, isClientObject());

}


void ShapeBase::setThirdPersonImage(U32 imageSlot)
{
	MountedImage& image = mMountedImageList[imageSlot];
	image.shapeInstance = new TSShapeInstance(image.dataBlock->shape, isClientObject());
}


now in ShapeBase::getRenderImageTransform() call these functions.

after

mat->mul(nmat,data.eyeOffset);

add

setFirstPersonImage(imageSlot);

and after

mat->mul(nmat,data.mountTransform);

add

setThirdPersonImage(imageSlot);

Ok thats it.

You will have to add the appropriate references to the new values and function in shapeBase.h

Then in your scripts image datablock

add
fpshapeFile = "path/to/dts";

So does anybody spot why this would stop the animation for the image working?
#20
01/17/2004 (5:49 pm)
Simple. You have to call the appropriate animation calls on each ShapeInstance for everything to work out right. Otherwise the shape instance... won't animate.

I'd just find a way to swap the existing shape pointer based on the view. Any other approach would necessitate changing every single reference to the shape point to _two_ points, and then either doing the animation twice (ew) or having an if statement... either way, very gross.
Page «Previous 1 2 3 4 5 6 7 Last »