视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes

编程概述

This article describes ways of creating projects in Unigine.本文介绍了在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.本文的主要目的是提供有关设置开发环境的见解并提供编程概述。它包含指向其他文章的链接,这些文章可以帮助您准备开发环境,选择编程语言等等。

Languages语言能力#

To create your own project with Unigine, you can use the following programming languages:要使用Unigine创建自己的项目,可以使用以下编程语言:

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. UnigineScript可以通过Unigine API轻松扩展。 Unigine引擎可以导出C ++和C#代码,反之亦然。您可以使用C ++或C#语言编写一些功能,然后将其导出到UnigineScript。有关更多信息,请参见C++ APIC# API的用法示例文章。

Platforms平台类#

Unigine supports the following platforms: Unigine支持以下平台:

  • 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.使用UNIGINE 2 SDK开发应用程序需要64位系统。该引擎完全有效地使用了多核CPU架构。

With Unigine you can build applications for these platforms with a single codebase.使用Unigine,您可以使用单个代码库为这些平台构建应用程序。

Read more about the Hardware Requirements.详细了解硬件要求

Development Environments开发环境#

You can use any of these PC platforms to write your Unigine-powered project:您可以使用这些PC平台中的任何一个来编写由Unigine支持的项目:

  • Windows
  • Linux

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 SDK外,每个平台还需要安装特定软件才能开始编码。您可以在此处找到每个平台的要求:

Execution Sequence执行顺序#

Unigine's Application Logic System has three main concepts of logic: Unigine的应用逻辑系统具有三个主要的逻辑概念:

  • 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).
    System logic-应用程序的逻辑。您可以实现将在应用程序生命周期中执行的逻辑。您的自定义逻辑可以放在系统脚本文件中(仅使用UnigineScript API ),也可以继承 SystemLogic类并实现您的逻辑( C ++和C#API )。

    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. UnigineScript unigine.usc系统脚本文件是在项目文件夹中自动创建的。 创建新的 C ++ / C#项目时,它已经继承了带有已实现方法的系统逻辑类,可以将您的逻辑代码放入其中。

  • 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).
    World logic - 世界的邏輯-在這裡您應該放置虛擬場景的邏輯。 邏輯在加載世界時生效。 您可以將邏輯放入世界腳本 文件中 (僅通過使用UnigineScript API), 或者,您可以從WorldLogic類繼承一個類並在其中實現您的邏輯(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. 世界脚本*.usc文件是使用新世界自动创建的,并具有您的项目名称。 当您创建新的 C ++ / C#项目时,它已经继承了带已实现方法的世界逻辑类,可以将您的逻辑代码放入其中。

  • 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).
    Editor logic-编辑器的逻辑。该逻辑仅在加载编辑器时生效。您可以将逻辑放在编辑器脚本文件中(仅通过使用UnigineScript API ),也可以继承 EditorLogic类并实现您的逻辑( C ++和C#API )。

    When you create a new C++ / C# project, it has already inherited editor logic class with implemented methods to put your logic code inside. 创建新的 C ++ / C#项目时,它已经继承了带有实现方法的编辑器逻辑类,以将您的逻辑代码放入其中。

注意
In case of inheriting *Logic classes (C++ / C#), implemented methods will be called right after corresponding scripts' methods.如果继承*Logic类(C++ / C#),则将在相应脚本的方法之后立即调用已实现的方法。

The UNIGINE engine internal code and the application logic are executed in the pre-defined order: UNIGINE引擎内部代码和应用程​​序逻辑按预定义的顺序执行:

  1. 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. 初始化 。在此阶段,准备并初始化所需的资源。这些资源准备就绪后,引擎就会进入主循环。
  2. 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:
    1. Update stage containing all logic of your application that is performed every frameUpdate stage containing all logic of your application that is performed every frame
    2. Rendering stage containing all rendering-related operations, physics simulation calculations, and pathfindingRendering stage containing all rendering-related operations, physics simulation calculations, and pathfinding
    3. Swap stage containing all synchronization operations performed in order to switch between the buffersSwap stage containing all synchronization operations performed in order to switch between the buffers

    This cycle is repeated every frame while the application is running.This cycle is repeated every frame while the application is running.

    Update stage containing all logic of your application that is performed every frameRendering stage containing all rendering-related operations, physics simulation calculations, and pathfindingSwap stage containing all synchronization operations performed in order to switch between the buffersThis cycle is repeated every frame while the application is running.
    主循环 。当UNIGINE进入主循环时,其所有动作可分为三个阶段,每个阶段一个周期地执行:
    1. Update stage containing all logic of your application that is performed every frame Update 阶段包含每帧执行的应用程序的所有逻辑
    2. Rendering stage containing all rendering-related operations, physics simulation calculations, and pathfinding 渲染阶段,包含所有与渲染相关的操作,物理模拟计算和寻路
    3. 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.在应用程序运行时每帧重复此循环。

  3. Shutdown. When UNIGINE stops execution of the application, it performs operations related to the application shutdown and resource cleanup. 关闭 。当UNIGINE停止执行应用程序时,它将执行与应用程序关闭和资源清除相关的操作。

Read this article to know where to put your logic code.阅读本文以了解将逻辑代码放在何处。

Also, read the Execution Sequence and Logic System articles to know the detailed workflow of the Unigine engine.另外,请阅读执行顺序 Logic System 文章,以了解Unigine引擎的详细工作流程。

Applying Logic to Objects将逻辑应用于对象#

为了将对象方便地集成到应用程序逻辑中,使用了 属性 。属性指定一组用户定义的参数以及对象的行为方式以及与其他对象和场景环境交互的方式。将属性分配给节点(或属性,如果该属性是从surface_base继承的),则它指定将应用于此对象的逻辑。

作为应用程序逻辑的“材料”的属性表示一组与逻辑相关的 参数 。例如,可以使用属性来指定角色的健康点或可以在物理交互中使用的表面材质参数。

在相应的 通过属性访问节点和文件 文章中了解如何访问在属性的参数字段中指定的节点和资产。

组件系统

通过使用 组件系统 扩展节点的功能,可以集成属性和与其关联的逻辑。

属性代表逻辑标记并提供一组用户定义的参数,而逻辑 component 则集成了节点,包含逻辑实现的C ++类和属性。

基本工作流程如下:

  1. ComponentBase 类继承一个表示您的组件的新类。
  2. 在头文件中,确定并声明此组件将使用的参数列表。所有这些参数及其默认值(如果已指定)将存储在专用属性文件中。
  3. 在某些方法(init(), update(), render()等)内实现组件逻辑,这些逻辑将由引擎的主循环的相应功能调用。
  4. 将创建的属性分配给节点以赋予其所需的功能。


请参见 使用C ++组件系统 文章中的用法示例。

Intersections交叉口#

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.对象之间的交互可以使用 交叉点 处理。交叉点是定义的区域(或线)和对象的共享点。 Unigine有多种检测交叉点的方法。

There are three main types of intersections:有三种主要的相交类型:

Usage Examples使用范例#

There are three sections with usage example samples:有三个带有用法示例示例的部分:

The programming code is the same for all supported platforms, the difference is in compiling.所有受支持平台的编程代码都是相同的,不同之处在于编译。

For all of these samples we create new projects by using Project Generator. Project Generator creates a new world with the World Light source and the plane mesh.对于所有这些示例,我们使用 Project Generator 创建新项目。 Project Generator使用 World Light 源和平面网格创建一个新世界。

最新更新: 2021-03-05