Sign in to follow this  
Tut

Custom environment rigs and animations

Recommended Posts

Introduction

This guide intends to teach 3ds Max users the basics, and more advanced ways, of working with (environment) animations and rigs to enhance atmosphere of the game.

Animations, moving images or however you name it, they are there, everywhere in games. GTA San Andreas and its predecessors do utilize animations, however to a limited extent; most environment models were kept frozen in the dark days of PC games to save computer resources. Few objects like mechanical oil drills and food store mascots are animated. Today we're past those days and have advanced in technology to exceed limits, and integrate known resource demanding features into our games without much of a performance impact. 

It's important to keep in mind that the Renderware engine has various limitations associated with models/3D assets. These limitations do apply very harsh on what this guide covers.

Table of contents

  • Demo reel - Custom rigs and animations
  • Prerequisites
    • Recommended
  • Character skeleton
  • Basics to skinning
  • Simulation conversion to bones workflow

 

Demo reel - Custom rigs and animations

 

Prerequisites
 

Recommended

  • You can use virtually any modeling or animation software e.g Blender or Cinema 4D to do 90% of the work. 3ds Max is required to export to GTA formats IFP and DFF.
  • It's recommended to have experience in game modding and 3D modeling software of choice.
  • It's highly recommended to use Shagg_E's anim/char helper for easy setup of bones and animation. For those who calculate bone hierarchy, add SPunknown = 4 to Root bone's object property.
  • It's possible to use ARKTOS Tools VertexToBones for converting vertex-baked animations to bone animations. It should be noted however that this does not create bone hierarchy the desired way. It creates bones that aren't linked to each other, only the root, so it generates the animation for each bone to move, not rotate, and thus the majority of the animation relies on position keys, where SA animations only support rotation keys.

 

Character skeleton

San Andreas uses bones for its character animations. These bones are linked together, forming a skeleton with joints that can be rotated. Motion capture data can be transferred onto bones to ease the creation of character and more detailed animations. This was done for GTA cutscene models primarily.
On 3ds Max, bones can be virtually anything, ranging from camera's to dummies. When exporting to GTA formats, the bone objects are automatically converted into dummies (helpers). This is how bones worked in early 2000's and/or 90's. If you desire to convert a helper or model into a dummy, follow this CGTalk post's instructions.

For creating a skeleton, place all bones around the inner mesh of the model. Everything must be in a hierarchy and bones can have as many children as desired. Naming conventions are only recommended for easier overview, however they can be named according to one's desire e.g Bone_0 - Bone_12. To have the bones show the way the imported skins ones do, head to Display Panel under Links, and check both boxes. Make sure this is done for every bone. This will display joint links in correct hierarchy in viewport.

Some games may use vertex baked animations, thus negating the need for bones. This is often seen on models such as all types of clothing. For game engines that do not support vertex animation or dynamic cloth, bones will be used instead. 

Below is a spoiler of valid bone ID's for regular ped models. There are 31 functional bone ID's, 32 with Root included. Once again, bones does not have to use same naming convenience as presented below. They also don't have to use same order of ID's or bone hierarchy, so for instance, Pelvis and Jaw ID's can be exchanged, as long as Root ID = 0. Or, the Head bone can be child of R Hand, not necessarily the Neck.

Spoiler

0 = Root
1 = Pelvis
2 = Spine
3 = Spine1
4 = Neck
5 = Head
6 = L Brow
7 = R Brow
8 = Jaw
21 = Bip01 R Clavicle
22 = R UpperArm
23 = R ForeArm
24 = R Hand
25 = R Finger
26 = R Finger01
31 = Bip01 L Clavicle
32 = L UpperArm
33 = L ForeArm
34 = L Hand
35 = L Finger
36 = L Finger01
41 = L Thigh
42 = L Calf
43 =  L Foot
44 =  L Toe0
51 =  R Thigh
52 =  R Calf
53 =  R Foot
54 =  R Toe0
201 = Belly
301 = R breast
302 = L breast

Warning: if the skeleton doesn't have ID 24 (right hand) it's possible the game will crash, since it wants ID 24 to hold the player's gun !

Hierarchy sorting:

unknown.png

 

 

Basics to skinning

Although not hugely covered in this guide; Skinned models use a different system from vehicles and map objects. Besides having their 3D mesh, they have a skeleton. A skeleton is made of bone joints linked to each other, so that when the shoulder moves, the lower arm does as well. A bone will only affect part of the mesh that it's weighed to. If you weigh all vertices of the player's hat to the Head bone, then the hat will move according to the head bone. If you weigh all of the hat's vertices to the Pelvis bone, then the hat will stay static in air while the head moves.

All vertices must be affiliated with at least one bone. Although a skin can have 32 bones, it'll work just fine if you weigh all vertices to only 3 bones. Not all bones require to be affiliated with a vertex. If you try to export a skinned model where 1 vertex is not weighted, the exporter will reject your request to export or your game will crash.

A skin can have as few as 2 bones (root and children), so if your model has only 8 vertices, there's really no point having 32 bones when only 8 are functional.

Below image (credits: IamObama) shows the basics to weighing joints to a character mesh.

Billedresultat for gta sa rigging guide ls-rp

While this doesn't show all of the bones, it can prove very helpful as a lookup while weighing vertices to your skin. You can also load in a GTA ped to reference its miscellaneous bones e.g facial and fingers.

 

Simulation conversion to bones workflow

Note: The following process or techniques may apply for Blender/Maya users as well.

3ds Max has inbuilt cloth physics. These can simulate with help of gravity, wind, etc. and is a great way to generate animations for cloth-like elements. With help of tracking markers, you can track a bone to follow the orientation of a marker, which can then be baked into keyframes. The process is incredibly simple, you just have to understand the basics of cloth physics and object constraints.

Video tutorial:

Text tutorial:

Create your model simulation model

Be mindful about geometry and bone count when creating your model. The fewer polygons, the more rough the animation will be. The more polygons, the more cloth-like it'll look. The more bones with keyframes, the larger the file size (lots) of your IFP. For flags, one bone should never have full influence of a vertex. A vertex should always be affected by 2 or more different bones for a nice blend.

It may be an idea to load in a GTA model so that you can somewhat reference the scale, if you don't have access to a dimension ruler. For the purpose of the guide (assuming you follow along the video), create a plane (primitive) with 8 segments in both directions. Make it length: 1,280 meter, width: 848 millimeters.

 

Prepare your simulation model

Convert the primitive to either editable mesh or editable poly. Polygon mode is more sustainable for modeling, but it needs to be in Mesh mode once you export it. Enable angle snap (default: A) and rotate it so it stands vertically. On the Hierarchy tab, reset transform to reset rotation values to 0. Add a Cloth modifier to your model. Go to sub-object level group of cloth modifier. Select the vertices that you want to act as solid points (e.g ones attached to flagpole). Click Drag as group mode.

 

Simulate the model

Head to Create tab > Space warps. Create a wind. Its position doesn't matter, only the rotation which represents the direction, matters. The default settings of the wind are usually too high.
Try setting strength: 0,12, Turbulence: 0,8, Frequency: 0,05.
Select the simulation model. On the cloth modifier, select Cloth forces and choose the wind. On the same interface, select Object properties. Select the model's name, then select Cloth, then pick a preset of your preference. Try silk or cashmere. You can optionally use Edge springs. I'm not fully sure what it represents, but I believe it's got to do with keeping the edges intact and not stretching them (which you don't want for bone animations). Try simulating the model. You may want to increase the timeline to a more reasonable duration, but be cautious as the higher it goes, the more your potato will suffer. If you aren't happy with the simulation, erase it and it'll let you try resimulate it. If you're unlucky enough to get the infamous error message dT increased/decreased you may want to start a new 3ds max project file...

 

Create your real model

In most cases you'll simply clone the simulated model, name the clone skin_mesh (name can be anything, but for easier scene management, name it something related). Remove the cloth modifier from your "real" model. For the simulated model, select the create keys button in cloth modifier. This will collapse your modifier and bake animation into keyframes, can NOT be reverted! Move the simulated model a bit away from the skin mesh, so that it'll make it significantly easier for a later procedure. Make sure to center the skin mesh to 0,0,0 or you'll get real trouble later. Convert the model to editable mesh. When you need to export later, it doesn't want it as editable poly.

 

Create bones for your model

Apply a Skin modifier to your model. This is used to carry the skeleton bones for later on. To make the bone creation and setup a whole lot easier, run Shagg_E's animation tools (link in top of thread). If you simply choose to create a set of dummies, his script won't recognise them as bones and you'll have to add all the object properties manually. So do yourself a favor and use his tool. Navigate to the Char helper section on the interface. Click create root, this'll create a dummy in center of the scene, assuming it corresponds to the model's center. Click create children, this'll create a dummy linked to the root. Drag it out from the model and title it "Pelvis" (again naming doesn't matter, can be "sampsucks" and samp modders will know once they load in your skin!). This bone is usually needed to keep part of the model's verts (abbreviation for vertices) in place, e.g flag pole attachments. Keep creating children bones until you reach your desired amount. It's a good idea to enable snaps (to vertex) so that you can magnet position bones directly onto the vertices. Select any bone in hierarchy and click Calculate for all hierarchy. This calculates bone ID's, bone index and bone type. If you were to set this yourself, you would need to understand how they work, on top of this it would be very time consuming. So we can all thank Shagg_E for making this wonderful script. Select the root bone, head to object properties, in user defined add to the string SPunknown = 4 or else your skin won't work as intended.

 

Prepare motion tracking

Create motion tracking markers. Head to create tab -> helpers -> point helper. Keep their scale at .2 or so. Spawn the amount equivalent to the amount of functional bones (excluding root and pelvis). Select all of the point helpers. Under the Animation rollout, select constraint -> attachment constraint -> select the simulated model. Go to Motion tab. The positions are based on triangle points, so you have to insert either 0 or 1 on A and B, then pick a face. It'll make more sense if you watch the video.
You need to position the point helpers to the vertices where the bones are positioned at. I don't know of any more efficient way of doing this. On the model's skin modifier, add all functional bones (except root and pelvis). If you're running Max 2017+, you can use Voxel Solver to automate rigging (rough solution) and works great for simulated models.
Use setting: falloff 0,2, max influence 3, max resolution 128.
Try rotating some bones and hopefully they should affect the skin mesh. Now add the rest of the bones which you didn't rig to the model. If the model is a flag, then select a few vertices that you want to be solid in place, and weight those to pelvis at 100 weight.

 

Track the motion of the simulated model

Select all point helpers, click E for rotate, click F12 for rotate transforms and reset all 3 axis to 0. If you don't, some of your bones will be rotated massively (undesired). Apply an orientation constraint to all of your bones, 1 by 1, to their point helper counterpart. This tracks the rotations of the point helpers onto the dummy bones. You can add a shortcut to speed this up a tad... Select all the functional bones. Go to motion tab, click trajectories. This is where you bake the orientation constraints into keyframes for your bone animation. Settings below.
Start time = 0 by default, or the first frame of your timeline
End time = last frame of timeline OR whenever you desire
Samples = amount of keys for the animation. If Start = 0, End = 1500, you can add 1500 samples to have 1500 keys generated, or 150 to have 150 keys generated. Don't use much more than 200 samples or you'll get in serious trouble. You'll have to optimize your keyframes at some point.

You can change the keyframe tangent mode (i prefer auto or spline) to change the velocity of the keyframes. Once everything is set, click collapse. This generates keyframes. Animation is now made.
Making the cloth simulation seamless/loop is another story.

Finishing up

Custom model and custom IFP is essentially done now. In order to export animation from 3ds Max, simply select all bones, find an IFP file on your computer and clone it, on 3ds Max run the IFP script, click "load IFP" and then save your custom animation to the cloned IFP file. You can remove excess IFP animations from the IFP archive by using Animation Manager Tool. Have fun with it!

There was a recent update where MTA made a couple dozens of unused ped ID's available for servers to use. This is what inspired me to make this guide, since you could use those ID's to "add" new models, of which could be environment models to bring life to the world. Custom IFP's can simply be added into the server, they don't need to replace existing ID's.

It's important to note that by changing bone ID's, you change the way that the custom model reacts to default animations. As such, models like banners will appear incredibly distorted. In those cases it's suggested to create some idle, walkstyle and run animations.

It's also important to note that you can create LOD animations, since there's really no limit for how many IFP's a server can have. LOD animations may be very handy for animations that have highly dense simulations applied, so the further away the player goes, the less keyframes will be processed.

  • Like 4
  • Thanks 1

Share this post


Link to post
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.