This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
VR Development
双精度坐标
应用程序接口
Animations-Related Classes
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
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

在应用程序中运行轨道

After the track-based animations were created in UnigineEditor, they need to be played in the application. To add this functionality to your project, add the following code to the world script:在 UnigineEditor 中创建基于轨道的动画后,需要在应用程序中播放它们。要将此功能添加到您的项目中,请将以下代码添加到 world 脚本中:

源代码 (UnigineScript)
#include <core/systems/tracker/tracker.h>

Unigine::Tracker::TrackerTrack track;
float time, min_time, max_time, unit_time;

int init() {

	// use the Tracker namespace
	using Unigine::Tracker;

	// create a Tracker instance that will play the tracks
	Tracker tracker = new Tracker();
	// load the required tracks from a file
	track = tracker.loadTrack("samples/tracker/tracks/render_00.track");
	
	// get the start time of the track (in units)
	min_time = track.getMinTime();
	// get the end time of the track (in units)
	max_time = track.getMaxTime();
	// get the duration of the track unit (in seconds)
	unit_time = track.getUnitTime();
	
	// set the initial time to play the tracks
	time = track.getMinTime();

	return 1;
}

int update() {
	
	if(track == NULL) return 1;
	
	// update the tracks animation time
	time += engine.game.getIFps() / unit_time;
	time = min_time + ((time - min_time)) % (max_time - min_time);
	
	// set animation time for tracks (time values outside the [mintime, maxtime] range are clamped automatically)
	if(engine.game.isEnabled()) track.set(time);
	
	return 1;
}
注意
Time values outside the [MinTime, MaxTime] range are clamped automatically.[MinTime, MaxTime] 范围之外的时间值会被自动限制。
最新更新: 2023-12-19
Build: ()