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
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Adding Object into a New World

Starting to work with Unigine engine is easy. This tutorial will help you to find out how to create a simple static scene by adding an object from the third-party application into a new world.

To start with, we will need to export the model from a 3D model editor. We are going to use Autodesk 3ds Max, but export from Autodesk Maya is also available and can be done in the same way. After that, we will create a new world (a scene), add the model and tell the renderer how to make the model look like in real-time.

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

Still reading? Get started with your own Unigine-powered project right away!

Requirements

  • You should have Unigine plugins and ImageDDS installed. They are installed automatically by default.
  • It is supposed that you already have a finished 3D model with assigned materials ready to be exported.

See also

Step 1. Set Up a File Structure

First of all, set up a file structure of a new project. Recommendations are as following:

  • data - the new project should be stored in this folder, as all data required for rendering worlds is read from this folder.
    • new_project
      • materials - folder to store materials libraries. They contain settings for all materials used in the created world.
        • common
        • meshes
        • textures
          • uncompressed - a separate folder to store source uncompressed textures.
For Evaluation Kit the default data folder is C:/Unigine evaluation/data/ (see Unigine SDK structure).

Step 2. Export a Mesh

  1. Open the mesh in 3ds Max and prepare it for export:
    • Move the model close to zero as possible. Otherwise, you may encounter accuracy problems.
    • Unigine engine supports the following formats of textures:
      • Targa (TGA)
      • Portable Network Graphics (PNG)
      • JPEG (JPG)
      • PhotoShop Document (PSD)
      • Direct Draw Surface (DDS)
      PSD and DDS textures can be of either of 8-bit or 16-bit precision.
    • Make sure that either dimension of any texture is a power of two. Textures of improper size produce mipmap artifacts.
  2. 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.

  3. In the main menu bar click Unigine -> Mesh export. Only geometry will be exported.

  4. Select Mesh File dialog will be opened. Here, choose a folder to save the mesh and a name for the created mesh file.

    Warning
    All filenames in Unigine are case sensitive!
  5. Next you will see a dialog with export options.

    It means that the mesh will be exported with the following parameters:
    • Split by material. 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.
    • 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.
  6. Click OK for the mesh to be exported.

Step 3. Create a New World

  1. Run Unigine Editor. To release the mouse, if grabbed, press Esc. Other controls are listed here.
  2. Load the editor:
    • Press ` to open console.
    • Type editor_load command.
    Notice
    To reload the editor next time, simply press U. If you quit Unigine while the editor is opened, it will be loaded automatically next time you run Unigine.
  3. To create a new world, click Create new world button on the editor interface panel, or press CTRL + N.

  4. Choose the directory and a File Name for the new world. It must be created under <Unigine>/data folder.

    After that, two new files will be created:
    • newworld.world - an XML file containing nodes, material libraries and different rendering settings.
    • newworld.cpp - a world script file.

A new world with default sun node is created. You can keep it or delete at your own discretion.

Step 4. Adding a Mesh into the World

  1. On the editor panel click Add an object button and choose Static or skinned mesh.

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

  3. The model will appear in gray. This is because it uses a default material mesh_base. To change it, you will first need to create new material.

  4. The node can be renamed in the Name field (Nodes -> Node tab).

Step 5. Assign Materials

  1. Open the Materials panel by pressing M.
  2. Open the list of preloaded material libraries under the preview area:

  3. At the present moment no custom libraries are associated with the world. Click the Add library button to create one.

  4. Name the created library and click OK.

  5. Now you've got a material library to save new materials to.

  6. To 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 some setting in the parent material, its child materials will be changed automatically the same way, unless they override that setting.

  7. Choose the material library, where to the material will be saved, and specify the name.

  8. Select the new material in the list.

  9. Go to the Textures tab to load uncompressed textures, that need to be assigned to the mesh.

  10. Select the path to the textures.
    Notice
    The textures will be automatically compressed if they are stored in /uncompressed folder and have the following postfixes:
    • Diffuse - "_d"
    • Normal - "_n"
    • Specular - "_s"

    Notice
    If uncompressed textures are changed when the editor is loaded, they are compressed and automatically replace old textures. If changes are made while the editor closed, the compressed texture will not be updated.
  11. In the nodes list select a target node (by pressing N). Open the Surfaces tab on the right. Select the surfaces for which a material should be assigned.

  12. Materials can be assigned in two ways:
    • You can assign materials in the Node settings:

      And select the material in the list.

    • Or simply click Assign material button in Materials (it will be assigned to the currently selected surface of the node that is chosen in the Nodes list):

Step 6. Save the World

After finishing the work, save the world by pressing CTRL + S or Save world button on the editor panel.

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