shown in other instead.
This article describes ways of creating projects in Unigine.
The main purpose of the article is to provide insight into setting up the development environment and give the overview of programming. It contains links to other articles that help you to prepare the development environment, choose the language to programming and so on.
To create your own project with Unigine, you can use the following programming languages:
UnigineScript can be easily extended through the Unigine API. The Unigine engine enables exporting the C++ and C# code and vice versa. You can write some functionality by using the C++ or C# language, and export it to the UnigineScript. See usage examples articles of C++ API and C# API to know more.
Unigine supports the following platforms:
- Windows (7 SP1/8/10)
- Linux (kernel 3.0+)
A 64-bit system is required to develop applications using UNIGINE 2 SDK. The engine fully and efficiently uses multi-core CPU architecture.
With Unigine you can build applications for these platforms with a single codebase.
Read more about the Hardware Requirements.
You can use any of these PC platforms to write your Unigine-powered project:
In addition to UNIGINE SDK, each platform requires specific software that you need to install in order to start coding. You can find requirements for each platform here:
Unigine's Application Logic System has three main concepts of logic:
System logic - the logic of the application. You can implement your logic that will be performed during application life cycle. Your custom logic can be put in the system script file (by using UnigineScript API only), or you can inherit SystemLogic class and implement your logic (C++ and C# APIs).
UnigineScript unigine.usc system script file is created automatically in the your project's folder. When you create a new C++ / C# project, it has already inherited system logic class with implemented methods to put your logic code inside.
World logic - the logic of the world - here you should put the logic of the virtual scene. The logic takes effect when the world is loaded. You can put your logic inside the world script file (by using UnigineScript API only), or you can inherit WorldLogic class and implement your logic (C++ and C# APIs).
The world script *.usc file is automatically created with the new world and has the name of your project. When you create a new C++ / C# project, it has already inherited world logic class with implemented methods to put your logic code inside.
Editor logic - the logic of the editor. The logic takes effect only when the editor is loaded. You can put your logic inside the editor script file (by using UnigineScript API only), or you can inherit EditorLogic class and implement your logic (C++ and C# APIs).
When you create a new C++ / C# project, it has already inherited editor logic class with implemented methods to put your logic code inside.
The UNIGINE engine internal code and the application logic are executed in the pre-defined order:
- Initialization. During this stage, the required resources are prepared and initialized. As soon as these resources are ready for use, the engine enters the main loop.
- Main loop. When UNIGINE enters the main loop, all its actions can be divided into three stages, which are performed one by one in a cycle:
- Update stage containing all logic of your application that is performed every frame
- Rendering stage containing all rendering-related operations, physics simulation calculations, and pathfinding
- Swap stage containing all synchronization operations performed in order to switch between the buffers
This cycle is repeated every frame while the application is running.
- Shutdown. When UNIGINE stops execution of the application, it performs operations related to the application shutdown and resource cleanup.
Read this article to know where to put your logic code.
Applying Logic to Objects#
For an object to be conveniently integrated into application logic, properties are used. Properties specify the set of user‑defined parameters and the way the object will behave and interact with other objects and the scene environment. Once a property is assigned to a node (or to a surface, if the property is inherited from surface_base), it specifies the logic that will be applied to this object.
A property, being a "material" for application logic, represents a set of logic-related parameters. For example, properties can be used to specify character's health points or material parameters of a surface that can be used in physical interactions.
Learn how to implement game logic by using properties in the Programming Quick Start series. Get familiar with the way to access nodes and assets specified in the parameter fields of a property in the corresponding Accessing Nodes and Files via Properties article.
A property and the logic associated with it can be integrated by using the Custom Component System to extend the functionality of nodes.
While a property represents a tag for logic and provides a set of user-defined parameters, a logic component integrates a node, a C++ class, containing logic implementation, and a property.
The basic workflow is as follows:
- Inherit a new C++ class representing your component from the ComponentBase class.
- In the header file determine and declare the list of parameters to be used by this component. All of these parameters with their default values (if specified) will be stored in a dedicated property file.
- Implement component logic inside the certain methods (init(), update(), render(), etc.), that will be called by the corresponding functions of the Engine's main loop.
- Assign the created property to a node to give it the desired functionality.
See a usage example in the Using Custom Component System article.
Interactions between objects can be processed using Intersections. Intersection is a shared point of the defined area (or line) and an object. Unigine has different methods to detect intersections.
There are three main types of intersections:
- World intersection - an intersection with objects and nodes.
- Physics intersection - an intersection with shapes and collision objects.
- Game intersection - an intersection with pathfinding nodes like obstacles.
Examples of Managing Inersections are provided in the Programming Quick Start series.
There are three sections with usage example samples:
The programming code is the same for all supported platforms, the difference is in compiling.