7
\$\begingroup\$

The title says it all. An artist makes a 3d model of a character. How does a programmer use the model to make the character run around?

\$\endgroup\$
  • 4
    \$\begingroup\$ This seems like a "getting started" question, and it shows no research effort. It might also be to broad, if you take into account the fact that different game developers would do it differently. \$\endgroup\$ – Gnemlock Jan 2 '17 at 3:00
  • 3
    \$\begingroup\$ By reading vertices movement information from an animation file of some sorts. No black magic involved. The programmer most of the times does not code the movement but a function to read the movement already designed from a file. And some fancy code to interpolate between animation to provide smooth movement. Cannot write a definitive answer because many variations on the method exist. \$\endgroup\$ – rlam12 Jan 2 '17 at 3:09
  • 2
    \$\begingroup\$ You pretty much got it. While you can of course do everything in code, a civil war would form inside the game studio. \$\endgroup\$ – rlam12 Jan 2 '17 at 3:28
  • 4
    \$\begingroup\$ There, a +1 to compensate for the -1. This is a decent question. \$\endgroup\$ – Alexandre Vaillancourt Jan 2 '17 at 3:30
  • 2
    \$\begingroup\$ This is where animation layering and blending come in. Check out this talk about animation in Uncharted for a good overview of the ways multiple animations & inverse kinematics can be combined. There are games that do their animation purely procedurally, like Overgrowth, but having animation created by an animator or captured from a performer are more commonplace. \$\endgroup\$ – DMGregory Jan 2 '17 at 3:48
12
+50
\$\begingroup\$

There are multiple ways to do this:

The first and the most popular way is to create a skeleton for the model, then use this skeleton to move around the vertices of it. This is also usually done by the artist, because it needs to contain what areas are affected by which bone.

When the animation is done the artist saves it in a file (for example the COLLADA file format is very popular between beginner game programmers, because it is readable by humans, but because it's based on XML, it's big, so bigger game companies use files like .fbx).

The skeleton is made out if bones. The artist can define which vertices need to be moved by giving them a weight. The higher the weight, the higher the amount of movement it produces when the specific bone is moved. There's a separate weight table for each bone, so the same vertex can be affected by multiple bones

The second way is called morphing. It's more ancient but is still used today, because it doesn't require the use of a skeleton, thus it's better for things like the face of a model, or when you need to move the separate vertices around. Instead of creating a skeleton, the artist creates the states the model can be in, then the program loads in each frame and interpolates between them in the vertex shader.

Literally any model format is able to store an animation this way in the form of multiple separate files (like in .obj files), but some are able to handle them natively inside 1 file (one of the most famous one between beginners is id Software's .md2 format).

The third method of animating something is called procedural animation. It's not widely used, because it doesn't result in humane movements. It can be used when animating water or grass or any other natural objects, that has a pattern in it's motion.

The fourth and arguably the most complex is muscle-based animations. For example GTA IV used this engine, which calculates motion using a defensive AI and a skeleton structure. It's based on the first technique but it doesn't require the artist to animate the body. It's kind of like ragdoll but with better motions.

The fifth way is ragdoll. You probably know this, there are even games which almost purely rely on this, like the infamous Goat Simulator, but most games use it for dead characters. This also requires the artist to create a skeleton, but moving the joints is done with algorithms. These algorithms take max angles and drag into consideration.

\$\endgroup\$
  • \$\begingroup\$ Nice answer. Could you expand a bit on how a skeleton can be used to deform a 3D model? What is the extra data that allows a set of skeleton internal coordinates to be transformed into a deformation of model vertices? There's no need to provide an implementation ;) but what information in the artist's output makes this possible? If there's a good Wikipedia article describing this, it would be enough to just drop its title. \$\endgroup\$ – Praxeolitic Jan 4 '17 at 22:07
  • \$\begingroup\$ @Praxe added, let me know if you need something else \$\endgroup\$ – Bálint Jan 5 '17 at 7:02
  • \$\begingroup\$ The fourth you talked about, muscle based, is totally new to me. Very interesting. Sad that the Euphoria engine is proprietary and probably expensive. If they used some kind of automatic learning to develop it the data set sure is big an difficult to get. \$\endgroup\$ – Hatoru Hansou Jan 5 '17 at 8:35
  • \$\begingroup\$ @Hatoru it probably uses a learning program with pre-calculated data \$\endgroup\$ – Bálint Jan 5 '17 at 10:57
7
\$\begingroup\$

Animatable 3D models come with a skeleton (either the modeller or animator does this step of modelling, since it's in a bit of no man's land).
The skeleton is made of bones, relatively positioned between eachother, and every bone is mapped to a set of vertices of the 3D model, with influence values ranging from 0 to 1 (0.2, 0.5, etc.).
When this is done, the animator makes an animation, which can be a separate file or be stored within the model's file itself depending on format.
Animations are basically a set of instructions to each bone, telling them when to move or rotate, and how much.
By moving the bones around, you indirectly move the model's vertices around.

this is a very dumbed down explanation, and there are many different ways to do basic and more advanced animation, some being completely programmatic, however nowadays you won't find many animated models in a game without a skeleton (N64 models didn't have skeletons i believe, instead the model pieces worked as the skeleton)

\$\endgroup\$
  • 1
    \$\begingroup\$ Slight exception to the line "nowadays you won't find an animated model in a game without a skeleton": some simple animation effects are handled through vertex shaders. For example, animated gear in Destiny is done this way. The spirit of the answer stands though - if you see a model performing any complex animated movement in a game (especially if it's a character or creature) it's a safe bet that there's an underlying skeleton. \$\endgroup\$ – DMGregory Jan 4 '17 at 14:00
  • \$\begingroup\$ @DMGregory editting my answer \$\endgroup\$ – Brian H. Jan 5 '17 at 8:14

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.