This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
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
Учебные материалы

Основные виды перемещения объектов

After adding an object to UNIGINE, you can control its transformations with your control devices. This article shows how to control basic object movements and combine different transformations.После добавления объекта в UNIGINE вы можете управлять его трансформациями с помощью своих устройств управления. В этой статье показано, как управлять основными перемещениями объекта и комбинировать различные трансформации.

See Also
Смотрите также:#

Direction Vector
Вектор направления#

The direction vector is an important concept of mesh transformation. To move the node forward, you should know where the forward direction of the mesh is. When the mesh is exported from a 3D editor, it saves the information about the forward direction. And when you add the mesh to UNIGINE, it has the same orientation it had in a 3D editor. Вектор направления - важная концепция трансформации меша. Чтобы переместить ноду вперед, вы должны знать, где находится направление меша вперед. Когда меш экспортируется из 3D-редактора, он сохраняет информацию о направлении вперед. И когда вы добавляете меш в UNIGINE, он имеет ту же ориентацию, что и в 3D-редакторе.

A mesh in MayaМеш в Maya
The same mesh in UNIGINEЭтот же меш в UNIGINE

In the images above, the direction vector has the positive Y direction. To move this mesh forward, you should get the direction of the mesh by using the Y component (the second column) of the world transformation matrix of the mesh.На изображениях выше вектор направления имеет положительное направление Y. Чтобы переместить этот меш вперед, вы должны получить направление меша, используя компонент Y (второй столбец) глобальной матрицы трансформаций меша.

The point is that content creators and programmers should make an arrangement for the direction vector.Дело в том, что создатели контента и программисты должны согласовать вектор направления.

Basic Movements
Основные виды перемещений#

Prearrangement
Предварительная подготовка#

We are going to make a component that allows moving and rotating an object. To make the explanation unobstructed, we give supplementary parts of code and additional links here. The complete code is provided at the bottom of this article.Мы собираемся создать компонент, который позволяет перемещать и вращать объект. Чтобы упростить объяснение, мы приводим здесь дополнительные фрагменты кода и ссылки. Полный код приведен в в конце этой статьи.

To use the component system, we need to initialize it. This is done in AppSystemLogic.cpp as follows:Чтобы использовать систему компонентов, нам необходимо инициализировать ее. Это делается в AppSystemLogic.cpp следующим образом:

Исходный код (C++)
#include "AppSystemLogic.h"

int AppSystemLogic::init()
{
	Unigine::ComponentSystem::get()->initialize();
	return 1;
}

We need the camera to observe the scene and an object that we are going to manipulate. We define these two nodes in AppWorldLogic.h and add all related logic in AppWorldLogic.cpp:Нам нужна камера для наблюдения за сценой и объектом, которым мы собираемся манипулировать. Мы определяем эти две ноды в AppWorldLogic.h и добавляем всю необходимую логику в AppWorldLogic.cpp:

Исходный код (C++)
#include <UnigineLogic.h>
#include <UnigineStreams.h>
#include <UnigineObjects.h>
#include <UniginePlayers.h>

using namespace Unigine;

class AppWorldLogic : public Unigine::WorldLogic
{

public:
	AppWorldLogic();
	virtual ~AppWorldLogic();

	int init() override;

	int update() override;
	int postUpdate() override;
	int updatePhysics() override;

	int shutdown() override;

	int save(const Unigine::StreamPtr &stream) override;
	int restore(const Unigine::StreamPtr &stream) override;

private:
	// define the ObjectMeshStatic instance
	// so that it will be deleted with the AppWorldLogic instance
	Unigine::ObjectMeshStaticPtr mesh;

	//define the player camera
	Unigine::PlayerPtr player;
};
Исходный код (C++)
#include "AppWorldLogic.h"
#include <UnigineMathLib.h>
#include <UnigineGame.h>
#include <UnigineMesh.h>

using namespace Math;

AppWorldLogic::AppWorldLogic(){}

AppWorldLogic::~AppWorldLogic(){}
int AppWorldLogic::init()
{
	// get the current game camera
	player = Game::getPlayer();

	// set the camera position and direction to look at the object
	player->setPosition(Vec3(4.0f, -3.401f, 1.5f));
	player->setDirection(vec3(0.0f, 1.0f, -0.4f), player->getUp());

	// create the ObjectMeshStatic by using the new mesh
	mesh = ObjectMeshStatic::create("core/meshes/box.mesh");

	// set the mesh position
	mesh->setPosition(Vec3(4.0f, 0.0f, 1.0f));
	return 1;
}

Creating and Adding the Property
Создание и добавление свойства#

We are going to write the code that controls the object's movements as a separate component to make it reusable. Create a new C++ class (the header and *.cpp files) in the project. Let's name this component MovementControls. You can also check this article for more details about adding components.Мы напишем код, который управляет перемещениями объекта, в виде отдельного компонента, чтобы его можно было переиспользовать. Создайте новый класс C++ (файлы заголовка и *.cpp) в проекте. Давайте назовем этот компонент MovementControls. Вы также можете ознакомиться с этой статьей для получения более подробной информации о добавлении компонентов.

Исходный код (C++)
#pragma once

#include <UnigineComponentSystem.h>
#include <UnigineLogic.h>
#include <UnigineStreams.h>

class MovementControls : public Unigine::ComponentBase
{
public:
	COMPONENT_DEFINE(MovementControls, Unigine::ComponentBase);

	COMPONENT_INIT(init);
	COMPONENT_UPDATE(update);

	void init();
	void update();
};
Исходный код (C++)
#include "MovementControls.h"
#include <UnigineControls.h>
#include <UnigineEditor.h>
#include <UnigineMathLib.h>
#include <UnigineGame.h>
#include <UnigineVisualizer.h>

REGISTER_COMPONENT(MovementControls);

using namespace Unigine;
using namespace Math;

void MovementControls::init() {

}

void MovementControls::update() {

}

And to assign this property to the mesh we want to move, we add the following line in the init() method in AppWorldLogic.cpp:И чтобы присвоить назначить это свойство на меш, который мы хотим перемещать, мы добавляем следующую строку в методе init() в AppWorldLogic.cpp:

Исходный код (C++)
int AppWorldLogic::init()
{
	/* ... */
	// assign the movement controlling property to the mesh
	mesh->addProperty("MovementControls");
	return 1;
}

Moving Forward
Движение вперед#

This section demonstrates how to set the forward movement of the mesh.В этом разделе показано, как задать перемещение меша вперед.

In this example, we use the "p" key pressing to move the mesh forward. The direction vector is visualized for clarity.В этом примере мы используем нажатие клавиши "p" для перемещения меша вперед. Вектор направления визуализирован для наглядности.

In MovementControls.h, we add the property parameters to access them via Editor and set their initial values:В MovementControls.h мы добавляем параметры свойства, чтобы получить к ним доступ через редактор, и устанавливаем их начальные значения:

Исходный код (C++)
#pragma once

#include <UnigineComponentSystem.h>
#include <UnigineLogic.h>
#include <UnigineStreams.h>

class MovementControls : public Unigine::ComponentBase
{
public:
	COMPONENT_DEFINE(MovementControls, Unigine::ComponentBase);
	// define the property parameters that can be adjusted via the Editor as well
	PROP_PARAM(Node, moving_node);
	// define the movement speed
	PROP_PARAM(Float, movement_speed, 5.0f);

	COMPONENT_INIT(init);
	COMPONENT_UPDATE(update);

	void init();
	void update();
};

In MovementControls.cpp, we add the movement-related logic:В MovementControls.cpp мы добавляем логику, связанную с перемещением:

Исходный код (C++)
#include "MovementControls.h"
#include <UnigineControls.h>
#include <UnigineEditor.h>
#include <UnigineMathLib.h>
#include <UnigineGame.h>
#include <UnigineVisualizer.h>

REGISTER_COMPONENT(MovementControls);

using namespace Unigine;
using namespace Math;

void MovementControls::init() {

	// enable visualizer
	Visualizer::setEnabled(1);

	// check if the key is pressed and update the state of the specified control

	ControlsApp::setStateKey(Controls::STATE_AUX_0, 'p');

}

void MovementControls::update() {

	// get the frame duration
	float ifps = Game::getIFps();

	// get the current world transformation matrix of the node this property is assigned to
	Mat4 transform = node->getWorldTransform();

	// get the direction vector of the node from the second column of the transformation matrix
	Vec3 direction = transform.getColumn3(1);

	// render the direction vector for visual clarity
	Visualizer::renderDirection(node->getWorldPosition(), vec3(direction), vec4(1.0f, 0.0f, 0.0f, 1.0f), 0.1f, 0);

	// check if the control key is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_0)) {

		// calculate the delta of movement
		Vec3 delta_movement = direction * movement_speed * ifps;

		// set a new position to the node
		node->setWorldPosition(node->getWorldPosition() + delta_movement);
	}

}

Другой способ настройки позиции меша

The new position can be also set by setting the WorldTransform variable. The following examples contain the code from the Update() function of the AppWorldLogic class. The part of controls initialization is the same for this method, the difference is in the Update() function only.Новую позицию также можно задать через переменную WorldTransform. Следующие примеры содержат код из функции Update() класса AppWorldLogic. Инициализация элементов управления для этого метода такая же, разница только в функции Update().

Исходный код (C++)
// check if the control key is pressed
if (ControlsApp::getState(Controls::STATE_AUX_0)) {

	// calculate the delta of movement
	Vec3 delta_movement = direction * movement_speed * ifps;

	// set a new position to the node
	node->setWorldTransform(translate(delta_movement) * transform);
}

Or you can change the translation column of the world transformation matrix (see the Matrix Transformations article) to move the node:Или же можно изменить столбец translation глобальной матрицы трансформации (смотрите статью Matrix Transformations), чтобы переместить ноду:

Исходный код (C++)
// check if the control key is pressed.
if (ControlsApp::getState(Controls::STATE_AUX_0)) {

	// calculate the delta of movement
	Vec3 delta_movement = direction * movement_speed * ifps;

	// set a new position
	// here, you can also use transform.setColumn3(3, transform.getColumn3(3) + delta_movement);
	transform.setColumn(3, transform.getColumn(3) + Vec4(delta_movement, 1.0f));

	// set a new world transform matrix to the mesh
	node->setWorldTransform(transform);
}

Rotation
Вращение#

This section contains implementation of the mesh rotation.Этот раздел содержит реализацию поворота меша.

You can rotate the mesh in two ways, by changing the transformation matrix represented by the WorldTransform variable (recommended way) or via the SetWorldRotation() function. The following example uses the second one:Вы можете повернуть меш двумя способами: изменив матрицу трансформаций, представленную переменной WorldTransform (рекомендуемый способ), или с помощью функции SetWorldRotation(). В следующем примере используется второй способ:

Исходный код (C++)
#pragma once

#include <UnigineComponentSystem.h>
#include <UnigineLogic.h>
#include <UnigineStreams.h>

class MovementControls : public Unigine::ComponentBase
{
public:
	COMPONENT_DEFINE(MovementControls, Unigine::ComponentBase);
	// define the property parameters that can be adjusted via the Editor as well
	PROP_PARAM(Node, moving_node);
	// define the rotation speed
	PROP_PARAM(Float, rotation_speed, 30.0f);

	COMPONENT_INIT(init);
	COMPONENT_UPDATE(update);

	void init();
	void update();
};
Исходный код (C++)
#include "MovementControls.h"
#include <UnigineControls.h>
#include <UnigineEditor.h>
#include <UnigineMathLib.h>
#include <UnigineGame.h>
#include <UnigineVisualizer.h>

REGISTER_COMPONENT(MovementControls);

using namespace Unigine;
using namespace Math;

void MovementControls::init() {

	// enable visualizer
	Visualizer::setEnabled(1);

	// check if the key is pressed and update the state of the specified control

	ControlsApp::setStateKey(Controls::STATE_AUX_1, 'o');

}

void MovementControls::update() {

	// get the frame duration
	float ifps = Game::getIFps();

	// check if the control key is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_1)) {

		// set the node rotation along the Z axis assuming node's scale equal to 1
		node->setWorldRotation(node->getWorldRotation() * quat(rotateZ(rotation_speed * ifps)), 1);
	}
}

In the example above, the node is rotated to the left by pressing the "o" keyboard key.В приведенном выше примере нода поворачивается влево нажатием клавиши "o" на клавиатуре.

Примечание
  • It is recommended to set the second argument of the SetWorldRotation() function to 1 for all non-scaled nodes to improve performance and accuracy.Рекомендуется присвоить второму аргументу функции SetWorldRotation() значение 1 для всех немасштабируемых нод, чтобы повысить производительность и точность.
  • Scaling of nodes should be avoided whenever possible, as it requires addidional calculations and may lead to error accumulation. По возможности следует избегать масштабирования нод, так как это требует дополнительных вычислений и может привести к накоплению ошибок.

To rotate the object by via the WorldTransform variable, you should replace the line containing the SetWorldRotation() function in the example above with the following one:Чтобы повернуть объект с помощью переменной WorldTransform, вы должны заменить строку, содержащую функцию SetWorldRotation() в приведенном выше примере, на следующую:

Исходный код (C++)
node->setWorldTransform(node->getWorldTransform() * Mat4(rotateZ(rotation_speed * ifps)));

This way is preferred, especially in case of complex transformations, as it allows composing the transformation matrix and setting it only once.Этот способ является предпочтительным, особенно в случае сложных трансформаций , поскольку он позволяет составить матрицу трансформаций и задать ее только один раз.

Combining Movements
Комбинируем движения#

Combining different movement controls is not more difficult than adding only one movement control.Комбинировать различные элементы управления движением не сложнее, чем добавить только один элемент управления движением.

The following code is an example that adds a mesh to the world and assigns a component on it that allows controlling its movements. You can rotate the mesh by using the "o", "[" keyboard keys and move forward by using the "p" key.Следующий код является примером, который добавляет меш в мир и назначает на него компонент, позволяющий управлять его перемещениями. Вы можете вращать меш, используя клавиши клавиатуры "o", "[", и двигаться вперед, используя клавишу "p".

Исходный код (C++)
#include "AppSystemLogic.h"
#include <UnigineComponentSystem.h>

using namespace Unigine;

AppSystemLogic::AppSystemLogic(){}

AppSystemLogic::~AppSystemLogic(){}
int AppSystemLogic::init()
{
	Unigine::ComponentSystem::get()->initialize();
	return 1;
}
////////////////////////////////////////////////////////////////////////////////
// start of the main loop
////////////////////////////////////////////////////////////////////////////////

int AppSystemLogic::update()
{
	// Write here code to be called before updating each render frame.
	return 1;
}

int AppSystemLogic::postUpdate()
{
	// Write here code to be called after updating each render frame.
	return 1;
}

////////////////////////////////////////////////////////////////////////////////
// end of the main loop
////////////////////////////////////////////////////////////////////////////////

int AppSystemLogic::shutdown()
{
	// Write here code to be called on engine shutdown.
	return 1;
}
Исходный код (C++)
#ifndef __APP_WORLD_LOGIC_H__
#define __APP_WORLD_LOGIC_H__

 #include <UnigineLogic.h>
#include <UnigineStreams.h>
#include <UnigineObjects.h>
#include <UniginePlayers.h>

using namespace Unigine;

class AppWorldLogic : public Unigine::WorldLogic
{

public:
	AppWorldLogic();
	virtual ~AppWorldLogic();

	int init() override;

	int update() override;
	int postUpdate() override;
	int updatePhysics() override;

	int shutdown() override;

	int save(const Unigine::StreamPtr &stream) override;
	int restore(const Unigine::StreamPtr &stream) override;

private:
	// define the ObjectMeshStatic instance
	// so that it will be deleted with the AppWorldLogic instance
	Unigine::ObjectMeshStaticPtr mesh;

	//define the player camera
	Unigine::PlayerPtr player;
};
#endif // __APP_WORLD_LOGIC_H__
Исходный код (C++)
#include "AppWorldLogic.h"
#include <UnigineMathLib.h>
#include <UnigineGame.h>
#include <UnigineMesh.h>

using namespace Math;

AppWorldLogic::AppWorldLogic(){}

AppWorldLogic::~AppWorldLogic(){}
int AppWorldLogic::init()
{
	// get the current game camera
	player = Game::getPlayer();

	// set the camera position and direction to look at the object
	player->setPosition(Vec3(4.0f, -3.401f, 1.5f));
	player->setDirection(vec3(0.0f, 1.0f, -0.4f), player->getUp());

	// create the ObjectMeshStatic by using the new mesh
	mesh = ObjectMeshStatic::create("core/meshes/box.mesh");

	// set the mesh position
	mesh->setPosition(Vec3(4.0f, 0.0f, 1.0f));
	// assign the movement controlling property to the mesh
	mesh->addProperty("MovementControls");
	return 1;
}

////////////////////////////////////////////////////////////////////////////////
// start of the main loop
////////////////////////////////////////////////////////////////////////////////

int AppWorldLogic::update()
{
	// Write here code to be called before updating each render frame: specify all graphics-related functions you want to be called every frame while your application executes.
	return 1;
}

int AppWorldLogic::postUpdate()
{
	// The engine calls this function after updating each render frame: correct behavior after the state of the node has been updated.
	return 1;
}

int AppWorldLogic::updatePhysics()
{
	// Write here code to be called before updating each physics frame: control physics in your application and put non-rendering calculations.
	// The engine calls updatePhysics() with the fixed rate (60 times per second by default) regardless of the FPS value.
	// WARNING: do not create, delete or change transformations of nodes here, because rendering is already in progress.
	return 1;
}

////////////////////////////////////////////////////////////////////////////////
// end of the main loop
////////////////////////////////////////////////////////////////////////////////

int AppWorldLogic::shutdown()
{
	// Write here code to be called on world shutdown: delete resources that were created during world script execution to avoid memory leaks.
	return 1;
}

int AppWorldLogic::save(const Unigine::StreamPtr &stream)
{
	// Write here code to be called when the world is saving its state (i.e. state_save is called): save custom user data to a file.
	UNIGINE_UNUSED(stream);
	return 1;
}

int AppWorldLogic::restore(const Unigine::StreamPtr &stream)
{
	// Write here code to be called when the world is restoring its state (i.e. state_restore is called): restore custom user data to a file here.
	UNIGINE_UNUSED(stream);
	return 1;
}
Исходный код (C++)
#pragma once

#include <UnigineComponentSystem.h>
#include <UnigineLogic.h>
#include <UnigineStreams.h>

class MovementControls : public Unigine::ComponentBase
{
public:
	COMPONENT_DEFINE(MovementControls, Unigine::ComponentBase);
	// define the property parameters that can be adjusted via the Editor as well
	PROP_PARAM(Node, moving_node);
	// define the movement speed
	PROP_PARAM(Float, movement_speed, 5.0f);
	// define the rotation speed
	PROP_PARAM(Float, rotation_speed, 30.0f);

	COMPONENT_INIT(init);
	COMPONENT_UPDATE(update);

	void init();
	void update();
};
Исходный код (C++)
#include "MovementControls.h"
#include <UnigineControls.h>
#include <UnigineEditor.h>
#include <UnigineMathLib.h>
#include <UnigineGame.h>
#include <UnigineVisualizer.h>

REGISTER_COMPONENT(MovementControls);

using namespace Unigine;
using namespace Math;

void MovementControls::init() {
	// enable visualizer
	Visualizer::setEnabled(1);

	// check if the key is pressed and update the state of the specified control
	// you can use both 'p', 'o', '[' or ASCII codes (112, 111, 113)
	ControlsApp::setStateKey(Controls::STATE_AUX_0, 'p');
	ControlsApp::setStateKey(Controls::STATE_AUX_1, 'o');
	ControlsApp::setStateKey(Controls::STATE_AUX_2, '[');
}

void MovementControls::update() {

	// get the frame duration
	float ifps = Game::getIFps();

	// get the current world transformation matrix of the node this property is assigned to
	Mat4 transform = node->getWorldTransform();

	// get the direction vector of the node from the second column of the transformation matrix
	Vec3 direction = transform.getColumn3(1);

	// initialize the update flag and declare rotation and movement
	int update_transform = 0;
	Mat4 rotation;
	Vec3 delta_movement;

	// render the direction vector for visual clarity
	Visualizer::renderDirection(node->getWorldPosition(), vec3(direction), vec4(1.0f, 0.0f, 0.0f, 1.0f), 0.1f, 0);

	// check if the control key for movement is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_0))
	{
		// calculate the delta of movement
		delta_movement = direction * movement_speed * ifps;

		update_transform = 1;
	}

	// check if the control key for left rotation is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_1))
	{
		// set the node left rotation along the Z axis
		rotation.setRotateZ(rotation_speed * ifps);
		update_transform = 1;
	}
	// check if the control key for right rotation is pressed
	else if (ControlsApp::getState(Controls::STATE_AUX_2))
	{
		// set the node right rotation along the Z axis
		rotation.setRotateZ(-rotation_speed * ifps);
		update_transform = 1;
	}

	// update transformation if necessary
	if (update_transform)
	{
		// combine transformations: movement + rotation
		transform = transform * rotation;
		transform.setColumn3(3, transform.getColumn3(3) + delta_movement);

		// set the resulting transformation
		node->setWorldTransform(transform);
	}
	
}
void MovementControls::forward() {
	// get the frame duration
	float ifps = Game::getIFps();

	// get the current world transformation matrix of the node this property is assigned to
	Mat4 transform = node->getWorldTransform();

	// get the direction vector of the node from the second column of the transformation matrix
	Vec3 direction = transform.getColumn3(1);

	// render the direction vector for visual clarity
	Visualizer::renderDirection(node->getWorldPosition(), vec3(direction), vec4(1.0f, 0.0f, 0.0f, 1.0f), 0.1f, 0);

	// check if the control key is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_0)) {

		// calculate the delta of movement
		Vec3 delta_movement = direction * movement_speed * ifps;

		// set a new position to the node
		node->setWorldPosition(node->getWorldPosition() + delta_movement);
	}

}
void MovementControls::position_var_1() {
	// get the frame duration
	float ifps = Game::getIFps();
	// get the current world transformation matrix of the mesh
	Mat4 transform = node->getWorldTransform();
	Vec3 direction = transform.getColumn3(1);

	// check if the control key is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_0)) {

		// calculate the delta of movement
		Vec3 delta_movement = direction * movement_speed * ifps;

		// set a new position to the node
		node->setWorldTransform(translate(delta_movement) * transform);
	}
	
}
void MovementControls::position_var_2() {
	// get the frame duration
	float ifps = Game::getIFps();
	// get the current world transformation matrix of the mesh
	Mat4 transform = node->getWorldTransform();
	Vec3 direction = transform.getColumn3(1);

	// check if the control key is pressed.
	if (ControlsApp::getState(Controls::STATE_AUX_0)) {

		// calculate the delta of movement
		Vec3 delta_movement = direction * movement_speed * ifps;

		// set a new position
		// here, you can also use transform.setColumn3(3, transform.getColumn3(3) + delta_movement);
		transform.setColumn(3, transform.getColumn(3) + Vec4(delta_movement, 1.0f));

		// set a new world transform matrix to the mesh
		node->setWorldTransform(transform);
	}
}

void MovementControls::rotation_var_1() {
	// get the frame duration
	float ifps = Game::getIFps();

	// check if the control key is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_1)) {

		// set the node rotation along the Z axis assuming node's scale equal to 1
		node->setWorldRotation(node->getWorldRotation() * quat(rotateZ(rotation_speed * ifps)), 1);
	}
}
void MovementControls::rotation_var_2() {
	// get the frame duration
	float ifps = Game::getIFps();

	// check if the control key is pressed
	if (ControlsApp::getState(Controls::STATE_AUX_1)) {

		// set the node rotation along the Z axis assuming node's scale equal to 1
		node->setWorldTransform(node->getWorldTransform() * Mat4(rotateZ(rotation_speed * ifps)));
	}
}
Последнее обновление: 07.06.2024
Build: ()