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
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Adding Object into the World

Starting to work with the Unigine engine is easy. This tutorial will help you to find out how to create a simple static scene: export an object from the third-party application, add it into the world of the Unigine-powered project, create the material library with materials and assign materials to the mesh.

Requirements

It is supposed that you already have:

Notice
Within this tutorial, we are going to use art assets (an static model and textures) available in Unigine SDK Browser.

Step 1. Prepare a Model for Export

  1. Open the model in 3ds Max or Maya and move the model close to zero as possible. Otherwise, you may encounter accuracy problems after exporting.
  2. Save your textures for the model in an appropriate format. Unigine engine supports the following formats of textures:
    • Targa (TGA)
    • Portable Network Graphics (PNG)
    • JPEG (JPG)
    • PhotoShop Document (PSD)
    • Direct Draw Surface (DDS)
    • Tagged Image File (TIF)
    • Portable Pixmap (PPM)
    • Portable Graymap (PGM)
    • High Dynamic Range Image (HDR)
    • Silicon Graphics Image (SGI)
    • RGB file (RGB)
    • RGB file with alpha (RGBA)
    Notice
    PSD and DDS textures can be of either of 8-bit or 16-bit precision.
  3. Make sure that either dimension of any texture is a power of 2 (for example, 32×32, 64×64 and so on). Textures of the improper size produce mipmap artifacts.

We recommend you to save your source uncompressed textures into the data/<project_name>/textures/uncompressed folder. They will be automatically compressed to the DDS format and placed in the data/<project_name>/textures folder when you assign them to the mesh.

Notice
In this case, all the textures should have the following postfixes:
  • Diffuse / Albedo - "_d"
  • Normal - "_n"
  • Specular / Metalness - "_s"
  • Emission - "_e"
If the uncompressed textures are changed when UnigineEditor is loaded, they are compressed by the engine and automatically replace old textures. If changes are made while the editor closed, the compressed texture will not be updated.

Step 2. Export a Model

Notice
We are going to use Autodesk 3ds Max, but exporting from Autodesk Maya is also available.

  1. Select the mesh. All the selected objects will constitute one mesh with different surfaces. The surfaces will be automatically named after objects in 3ds Max. Each object will be a separate surface of the exported mesh.

  2. Go to Utilities panel (click on the right-hand column) and click More....

  3. Choose UnigineMesh Utility in the list that appears and click OK.

    The UnigineMesh panel appears in the right-hand column.

  4. On the UnigineMesh panel, specify parameters to export the mesh.

    Read more about export parameters in the Plugins for 3ds Max article.

  5. Click Export As... In the export dialog that opens, choose a folder to save the mesh and specify a name for the mesh file.
    Notice
    We recommend you to save the exported mesh into the data/<project_name>/meshes/ folder.

  6. Click Save for the mesh to be exported. The window with export information opens if the export is done successfully:

Notice
A model is exported as a pure geometry, without materials. They are created directly in the UnigineEditor. The reason is that the engine has its own shaders and an optimized hierarchical material system, which is far more efficient and provides better performance.

Step 3. Adding a Mesh into the World

  1. Run the project with the loaded editor via the SDK Browser.

  2. On the Menu bar click Create and choose Object -> Mesh Static.

  3. In the file dialog that opens, choose the mesh file you've exported from 3ds Max.

    The model will appear in gray as it uses a default material mesh_base.

    According to Virtual Worlds Structure all objects in the world appear as nodes. You can open the Nodes window (click Windows -> Nodes or press N) to see all nodes in your world:

    If you choose the imported object, you can find information about it:

    Notice
    The node can be renamed in the Name field (Nodes -> Node)

Step 4. Assign Materials

  1. Create a custom material for the mesh: select mesh_base (or any other basic material) in the list and click inherit the material.
    Notice
    The inherited (child) material takes all properties and their values from its parent material but overrides those that should be different (like textures). If you change a setting in the parent material, child materials will be changed automatically, unless they override that setting.

  2. Choose the default material library (it was created automatically and named after the project), specify the name of the new material and click Ok.

  3. Select the new material in the list of materials.

  4. Go to the States tab and set Workflow option to Metalness.
  5. Go to the Textures tab to load the necessary textures.

  6. Select the path to the textures.
    Notice
    The textures will be automatically compressed and placed in the data/<project_name>/textures folder if they are stored in the uncompressed folder.

    When you change the texture, the field name will change its color to green:

  7. In the hierarchy list of Nodes panel (Windows -> Nodes or N) select a target node. Open the Surfaces tab and select the surfaces to which the created material should be assigned.

    Materials can be assigned in two ways:

    • You can assign materials on Surface tab of the Nodes panel by choosing the target surface (or surfaces) and click Load material:

      And select the material in the list.

    • You can assign material in Materials panel (Windows -> Materials or press M) by pressing the Assign material button. The material will be assigned to the currently selected surface of the node that is chosen in the hierarchy list on the Nodes panel).

  8. After the material has been assigned, go to the Parameters tab of the material and specify options to make the material more plausible.

Creating a Glass Material

Since we exported from 3Ds Max a mesh with body shell object and glass object, we need to create another material of glass. Textures are not necessary for glass material.

To create a glass material do the following:

  1. Create another material and specify the name of it.
  2. Enable the Glass option on the States tab of the material.

  3. Go to the Common tab of the created material and specify the following values:
    • Set the source of blending to zero.
    • Set the destination of blending to one.

Step 5. Save the World

After finishing the work, save the world: click File -> Save world on the Menu bar or press CTRL + S.

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