Game Development Community

Hiding parts of the player model

by Justin Mette · in Torque Game Engine · 01/30/2002 (4:40 pm) · 32 replies

I've recently started researching how to programmatically hide/show parts of the player model - like the head or the arm, for instance. Initial investigation left me thoroughly confused so I thought I'd tap the forums. Any suggestions out there on how this might be accomplished (or started)?

Thanks in advance,
Justin Mette
21-6 Productions
Page «Previous 1 2
#1
01/30/2002 (5:54 pm)
I have also been pondering this question.
Any ideas? Anyone?

I have a few questions to get us all thinking:

1. Wouldnt doing this force torque to use a seperate player model for each player? That seems awfully resource intensive... Is there a way around?

2. Torque supports LODs. So it CAN switch models "on-the-fly" Do you think there is a way to use this, perhaps create a new LOD (or set of), to allow for quick switching?

3. I realy have no idea on this next one: How are actual meshes stored in torque in-game? Would they be easy or incredibly difficult to alter?

Can anyone offer us a helping hand? Thanks. :)
#2
01/30/2002 (6:02 pm)
I think I have an idea regarding resources:

All you'd do is make a ptr (maybe stick it in the netgraph object?) with all the sets of heads and you draw instances of them (so only writing instances to video memory). I think a player model is loaded for each new player object (so 32 players = 32 player models in memory). You could probably make it more efficient by just having 2 players (or how many different characters you have) in RAM and when you render them you simply refer to the appropriate shape in memory. So if you had 5 different heads and 3 differnt player models you'd only need 5 bodies and 3 heads in memory. Instead of 32 bodies and 32 heads.

Just for shapes of course.
#3
01/30/2002 (7:30 pm)
Quote:Wouldnt doing this force torque to use a seperate player model for each player? That seems awfully resource intensive... Is there a way around?

Torque loads the resources for each shape only once, but the shapeinstance controls what's rendered. It's possible, but I'll have to dig around to see where to start.
#4
01/31/2002 (5:40 am)
oooh! I just had an idea:

Is there a way to change the TEXTURE of a model while the game is running? If so, you could set whatever part you want to dissappear to have a ompletley transparent texture... Is that possible?

If we could change the textures like that, it would also allow for modifications like blood stains where ever a player is hit. It would be very cool to find a way to alter the texture during a mission.
#5
01/31/2002 (6:21 am)
To give a little more insight into what we are trying to do; our main Myrmidon model will be customizable by the gamer - much like other RPG's where you can choose a face, eyes, hair, skin color, clothing, etc. As well, the different armor (or other items) you can wear during the game will change your character's appearance as you would expect.

Typically, these changes are acommodated by different textures being applied to the appropriate parts of the model, but we want to try something a little different. To add more realism, we wanted to look at having different meshes for the different heads and armors the character can have, for example.

One way to accomplish this, which one of our artists did on a previous project, was to model the different heads and armor meshes in the same MAX (or DTS) file. The code would then programatically hide/show the appropriate head/armor model as needed.

Anyway, I'm gonna keep looking into this. I have alot to learn about the internal structure of the character model as well as how to hide/show meshes (or nodes) in the model itself. I'll keep the community informed of my progress. If you come up with any ideas, please dont hesitate to post :)

Justin
#6
01/31/2002 (7:08 am)
I dont know much about modelling and the way torque handles models, but here's what I think about it.
I worked on some half-life modifications. And in half-life you could create sub models for parts of the models. Our models had more then 1 submodel for the head, and it could change on the fly. One of the submodels was a neck with a bone and lots of blood... so, ingame you could let the he head being shot off. to get a system like this into torque defenetly wont be easy (at least I think so)... but a good way of doing it
#7
01/31/2002 (7:36 am)
Justin, would it not be possible to increase the number of attachment points and have an attachment point at say the shoulders, head, legs, etc. so that you can attach different limbs and what not to the model?

I did some of this when doing a never-released but fully functional CTF mod for Rune [yes, I realize its an Unreal powered game] which had skeletal animation.
#8
01/31/2002 (7:36 am)
Hmm... I think you can set the visibility of a mesh in an animation.
#9
01/31/2002 (7:54 am)
Chris - that's an interesting idea. I'll have to think it through a little more - but at first it seems problematic because there really isn't anything to attach to - since the legs, arms, head, and upper/lower torso all can be represented by different models.

James I have started down just that road however I still have no progress to report. Straight-forward searching for "visible", "hide", "show", or anything related doesn't seem to result in anything useful. The TSShape and TSShapeInstance classes look like they have the right content it's just still unclear how to manipulate the mesh accordingly.
#10
01/31/2002 (7:58 am)
Hmmm. I was actually wondering how to do EXACTLY what you guys are doing Justin... I never thought of trying to hide a piece of the model. I will be VERY interested when you find a solution... :)

I thought that you were doing it to allow for "removable limbs", like in Rune. You could cut off an arm or a leg, or a section of one with a good blow. I would like that feature in my game as well, and hiding limbs would provide an excellent way to do that.

While the "animate the skin" suggestion may work, I would like to find another way that is less complex and time consuming, and would allow for things like blood decals (so when a player is hit, you can see where).
#11
01/31/2002 (8:16 am)
Justin: You could create an invisible dummy model as the "base" of the character, to which the torso, limbs and head would be attached.

-Jussi
#12
01/31/2002 (8:24 am)
If you look at the player model (the original one) and did your characters like that, it'd be simple to add/remove/change parts of the model, as theyre all individual mesh objects (just controlled by a simple skeleton).

If youre using skinned objects though, youve got a problem, in that the skinning has to change to alter the model.

If your using the skinned method, its probably as easy to replace the static mesh (i.e. the skinned vertices), but you'd have to hack the shape code to do it.

Shape code is NASSSTY :))

Phil.
#13
01/31/2002 (4:22 pm)
Here is what I have discovered so far. It works, but I'm not sure if the solution has any adverse long term effects yet - gotta do some more testing.

This code was tested in the ShapeBase class.

First, you need to find the node you are interested in hiding:

S32 armNode = mShapeInstance->getShape()->findNode("rarm 145");
Then, you need to find the mesh in the model that is connected to that node:

if(armNode != -1) {
   int s = mShapeInstance->mMeshObjects.size();
   for(int x = 0; x < s; x++) {
      S32 nodeIndex = mShapeInstance->mMeshObjects[x].object->nodeIndex;
      if(nodeIndex == armNode)
         mShapeInstance->mMeshObjects[x].visible = 0.0;
   }
}
Alternately, setting visible to 1.0 will make the mesh completely visible. You can actually create some neat effects by setting visible to 0.5, for example, which results in a partially transparent mesh.

I am going to write some generic functions on the ShapeBase class for hiding and showing meshes by node name and implement some test code in script. I will report here if I find any problems in testing the proposed solution.
#14
01/31/2002 (5:48 pm)
Note that code only works on the client version of the ShapeBase. You have to jump through a few more hoops to make a server method out of it. In particular, the client ghosts need to be updated with the changes when the server is told to hide/show a particular node.
#15
02/01/2002 (9:34 am)
A little more information - in addition to setting the visible property on the mesh, you also have to set the "vis" property on the corresponding object state, as follows:

[b]mShapeInstance->getShape()->objectStates[x].vis = 0.0;[/b]
This is because the TSShapeInstance::animateVisibility() method resets the visibility on all nodes based on the objectStates array.

If you dont set this objectState visibility, your node will disappear - until the next animation is run :)
#16
02/01/2002 (1:27 pm)
Ok, this is a thread in which some of the heavy-hitters of the TGE are currently residing and you Mr. Mette have stumbled upon something I really want to implement. Just give me 60 second of your guys' valuable time if you can... I'm not trying to digress here, but I can't miss this opportunity:)

I am currently making a Vietnam-era shooter and instead of using 1st or 3rd person view in the typical sense, I want my character to be transluscent to me, but not to the other players. This way I could accomplish a "look down the barrel" view of my weapons "through" the translucent player model. So, my player model's head and upper body would take up about 50% of the screen to accomplish this.

Are we on the same page here with what you found out and what I am trying to do (if you can understand my inept description :). It just sounded like if it was client only (If I understood your last post correctly) that this would accomplish just that!

Am I way off base here?

Any help would be great and I'm sorry for changing topic of your post, Justin.

Scott
#17
02/01/2002 (3:44 pm)
I tried your method but the node index returned by the findNode() function doesn't exist in the mMeshObjects array. I tried outputting both values to the console.

Any ideas as to why?
#18
02/01/2002 (5:43 pm)
Figured out why, you gotta search for the lowest detail level for some reason (in my case 3). I would've thought the contrary...

I'm supposing that you'd have to hide all detail levels wouldn't you?

Wouldn't it be easier to pop it out of the mMeshObjects vector? Or is that shape only loaded once for all instances of it too? Hence popping out there would pop it out on all instances?
#19
02/02/2002 (12:28 am)
One more thing, would it be possible to detect nodes which are attached to other nodes?

So for example, find the Bone Head node and traverse the items attached to it and make them all invisible.
#20
02/02/2002 (5:39 am)
Scott - at first glance, you should be able to use this method to make just the client partially visible. There looks to be another technique, however, that might fit your needs better - and that is the "fade" capabilities in the ShapeBase class. Check out the "startFade" method in particular. This controls the transparency of the entire model. You would still have to do some fancy work to make only the client version of your player be transparent, but it's definately possible.

Luigi - ah yes, detail levels. The model I am testing with doesn't have multiple detail levels which is why I didn't stumble on it yet. I would guess that the detail level at which the model is currently being rendered is what you have to search through when looking for the particular node. I'm actually not sure if the head node, for example, would be named differently for each detail level - which would of course, make this a tad more complicated. You would have to come up with a naming convention for the model nodes in that case so the code could more generically search the model.
Page «Previous 1 2