This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Adding Animated Object into the Loaded World

Adding an animated object into Unigine is no harder than adding a simple static model. You just have to choose, whether to export a model from a 3D editor together with animation (will do for simple objects, for example, lift doors), or export model geometry and its animation as separate files. The latter is suitable for complex objects with a number of animations, such as a character that can walk, run, jump etc. After the export is done, the model is added into the loaded world, assigned materials - the same steps for a static one. Playing its animation in Unigine-based application is just one or two clicks away.

Animated object

Detailed recommendations and tips for skinned meshes can be found in Animation article.

Requirements

  • You should have Unigine plug-ins and ImageDDS installed. By default, they are installed automatically.
  • It is supposed that you already have a finished animated model ready to be exported.

Step 1. Export an Animated Mesh

There are two methods to export skinned mesh and animation into Unigine:

  • In separate files. In this case one skinned mesh can be assigned different animations.
  • In one file. This export option is suitable for simple objects.

1 Method: Separate Files for Mesh and Animation

  1. Select the skinned mesh in its bind pose for export.

  2. In the main menu bar click Unigine -> MeshSkinned export.

  3. Select MeshSkinned file dialog will open. Here, choose a folder to save the skinned mesh and a name of the created file.

    Warning
    All filenames in Unigine are case sensitive!
  4. A dialog with export options.

    This means, the skinned mesh will be exported in the following way:
    • Split Multi/Sub. Unchecked box indicates that the mesh need not be split by multi-material ID assigned to polygons. Instead, it will be exported as one mesh.
    • Vertex Cache. This optimization allows to take the maximum advantage of the vertex cache by reordering the faces of the mesh so that triangles sharing vertices are exported reasonably close together. It maximizes vertex cache hits and is better to be always checked.
    • Bind pose. This box MUST be checked in order to export the bind pose.
    • Align. Here you can select the origin of coordinates for experted mesh. "World" means the world origin of coordinates. "Pivot" means the pivot point of the model. Other values specify positions relative to the model bounding sphere.
    • Scale. This is a multiplier to scale the model, if it is modeled too large or too small. The default value of 1 means the mesh is exported without scaling. Keep in mind that all default Unigine settings (for example, camera speed and default light radii) imply that 1 unit = 1 meter.
    • Digits. This field specifies a required precision of numbers. In our case, the amount of digits after a decimal point will equal 6. In most cases this value can be left unchanged.
    • Map channel 1 and Map channel 2. Here it is specified that into the first channel of the exported UV map should be copied the first UV channel. The second channel will be filled with zeros.
  5. Clicking OK will save the skinned mesh (vertices and weights) in .smesh format.

  6. Now select the bones to be exported.

  7. In the main menu bar click Unigine -> MeshSkinned animation export to export only the animation.

  8. Select MeshSkinned animation file dialog will open. Here, choose a folder to save the animation file.

  9. The export options must be the same, except that Bind pose is NOT checked.

  10. The animation data (bones and their transformations) is successfully saved in .sanim format.

2 Method: One File for Mesh and Animation

  1. Select the skinned mesh (the frame does not matter).

  2. In the main menu bar click Unigine -> MeshSkinned export.

  3. Select MeshSkinned file dialog will open. Choose a folder and name of the file to save the skinned mesh with its animation.

  4. In the export options Bind pose should NOT be checked (the options are described in detail above).

  5. After clicking OK, the skinned mesh and its animation is saved in one file.

Step 2*. Check animation playback

This an additional step to check if skinned animation was correctly exported.

  1. Load Resource Editor. MeshViewer tab will open.

  2. In the right panel choose Load mesh (or press CTRL+O).

  3. Select the skinned mesh file to load. In our case, this file contains only mesh data and no animation.

  4. Bones and their hierarchy can be displayed.

  5. Pressing CTRL+O, load the file with animation for the mesh. Check the Animation only box for the animation to be applied to the previously loaded skinned mesh.

  6. Play the whole animation or choose the frame by dragging the slider at the bottom.

Step 3. Load the World

  1. Run Unigine.
  2. If the editor is not loaded, do one of the following:
    • Press the U button
    • Activate console (by pressing `) and type editor_load command
  3. Load the world by pressing CTRL + O, or choosing Open world button on the editor panel.

  4. Choose the folder and the name of the world from /data directory.

Step 4. Add Skinned Mesh into the World

  1. On the editor panel find Add an object button and choose Mesh/smesh.

  2. In the opened file dialog, choose the skinned mesh you've exported from 3ds Max. It can be both with animation or without.

  3. The model will appear in gray, as it uses the default mesh_base material.
    Notice
    If the model is not lit enough, try tweaking the angle of light: select a light source used in the scene, press C hot key and tweak the angle of incident light.

  4. If the .smesh file does not contain animation, it needs to be loaded separately. Go to Node Settings -> Mesh tab -> Animation.
    Otherwise, it can be played at once.

  5. Select path to the .sanim file with animation.

  6. Loop the animation and press Play.

  7. Assign materials as described in Add Objects into a New World tutorial.

  8. Save the world by pressing CTRL + S. After adding all staic geometry, here is how our scene will look like:

Last update: 2017-07-03
Build: ()