1
\$\begingroup\$

Im working on a 3D engine in Java using OpenGL. Animated models are set up and working by transforming vertices based on joint weights in the vertex shader, i think this is common practice.

I am now trying to figure out how to manage equipment that can be worn or carried by a character, like armor and weapons. How is this commonly done, or whats the best way to do it?

Im imagining that you make some sort of attachment point for weapons on the character model, but since that all happens in the vertex shader, how do you go about that? Would you "intercept" the joint transformations and render the weapon independently? Also, how do you find out what the attachment point for the weapon is? Im using a collada file loader to parse .dae files for models and animations, can you somehow "index" bones with special attributes in Blender/other 3D programs?

And for armor: Since armor has to not just move with the character but also stretch and deform with him, do you somehow merge the models, or overlap them?

Im really in the dark about the practices for this but i can't find anything comprehensive on the internet that explains it.

\$\endgroup\$
1
\$\begingroup\$

This is handled differently depending on the equipment type.

You already have the rotation matrices per bone if you are doing vertex skinning, so you can just use those for the equipment. You should be able to rename bones in Blender to find them that way, but this gets into file loading, which is a very vast topic.

Rigid Items

These are the easiest the only deformation they undergo are per-object transformations depending on the bone(s) the object is attached to. An example of this would be a tool such as flashlight attached to single hand bone (or multiple bones).

Armor/Clothes

These are usually treated just like a character. For applications that have customizable characters, this becomes tricky because the clothes must fit the characters. It's usually best to just break down the characters into different meshes for each "part" (such as an arm, or the whole torso). You can even just replace part of the VBO for the character and swap in/out armor parts in some cases if you have a small number of textures. Otherwise, render each part as everything as a separate mesh (or do some sort of batching, to help with performance).

The problem with overlapping is that there can sometimes be strange offsets from bones that contribute to the base mesh clipping through, not to mention this adds to the computation needed. Even floating point precision can be an issue here and lead to z-fighting. It's very difficult to make overlapping skinned meshes work together.

Realistic Capes/Cloth

Realistic capes (applicable to other cloth materials) are an especially difficult object to render because they are impacted by both physics and the skeletal animation. Capes in this case can be done either on the CPU or on the GPU (with computer shaders or an alternative) via physics computations on a coarse cape mesh. Each vertex of this coarse mesh is then treated as a bone of a cape skeleton and then the higher resolution rendering mesh is deformed according to this coarse mesh, usually using a bezier curve or something similar. Ubisoft used this technique.

\$\endgroup\$
  • \$\begingroup\$ Thank you. Regarding Armor/Clothes: Are there any resources you can recommend about that? I can't find a lot about this topic. \$\endgroup\$ – JKunstwald Feb 8 '17 at 2:11
  • \$\begingroup\$ This is mostly from personal experience. There are some discussion threads on this on the web, but usually people either try to overlap or they use a "part" or "slot" system. Some character creation tools operate in a similar way, such as Fuse. \$\endgroup\$ – aces Feb 12 '17 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.