2021-06-29 05:28:17 +02:00
|
|
|
#include "framework.h"
|
|
|
|
#include "GameScriptRotation.h"
|
2021-09-08 18:31:35 +03:00
|
|
|
#include "Specific\phd_global.h"
|
2021-06-29 05:28:17 +02:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/*** Represents a rotation.
|
|
|
|
Rotations are specifed as a combination of individual
|
2021-07-20 17:49:14 +01:00
|
|
|
angles, in degrees, about each axis.
|
|
|
|
All values will be clamped to [-32768, 32767].
|
2021-08-23 19:16:24 +01:00
|
|
|
@miscclass Rotation
|
2021-07-20 17:49:14 +01:00
|
|
|
@pragma nostrip
|
|
|
|
*/
|
|
|
|
|
2021-07-01 19:25:44 +01:00
|
|
|
void GameScriptRotation::Register(sol::state* state)
|
|
|
|
{
|
|
|
|
state->new_usertype<GameScriptRotation>("Rotation",
|
|
|
|
sol::constructors<GameScriptRotation(int, int, int)>(),
|
2021-11-03 20:18:09 +00:00
|
|
|
sol::meta_function::to_string, &GameScriptRotation::ToString,
|
2021-07-20 17:49:14 +01:00
|
|
|
|
|
|
|
/// (int) rotation about x axis
|
2021-07-23 02:06:50 +01:00
|
|
|
//@mem x
|
|
|
|
"x", &GameScriptRotation::x,
|
2021-07-20 17:49:14 +01:00
|
|
|
|
|
|
|
/// (int) rotation about x axis
|
2021-07-23 02:06:50 +01:00
|
|
|
//@mem y
|
|
|
|
"y", &GameScriptRotation::y,
|
2021-07-20 17:49:14 +01:00
|
|
|
|
|
|
|
/// (int) rotation about x axis
|
2021-07-23 02:06:50 +01:00
|
|
|
//@mem z
|
|
|
|
"z", &GameScriptRotation::z
|
2021-07-03 23:07:21 +01:00
|
|
|
);
|
2021-07-01 19:25:44 +01:00
|
|
|
}
|
|
|
|
|
2021-07-20 17:49:14 +01:00
|
|
|
/***
|
|
|
|
@int X rotation about x axis
|
|
|
|
@int Y rotation about y axis
|
|
|
|
@int Z rotation about z axis
|
|
|
|
@return A Rotation object.
|
|
|
|
@function Rotation.new
|
|
|
|
*/
|
2021-07-03 23:07:21 +01:00
|
|
|
GameScriptRotation::GameScriptRotation(int aX, int aY, int aZ)
|
2021-06-29 05:28:17 +02:00
|
|
|
{
|
2021-07-03 23:07:21 +01:00
|
|
|
x = aX;
|
|
|
|
y = aY;
|
|
|
|
z = aZ;
|
2021-06-29 05:28:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 23:07:21 +01:00
|
|
|
void GameScriptRotation::StoreInPHDPos(PHD_3DPOS& pos) const
|
2021-07-01 19:25:44 +01:00
|
|
|
{
|
2021-07-03 23:07:21 +01:00
|
|
|
pos.xRot = x;
|
|
|
|
pos.yRot = y;
|
|
|
|
pos.zRot = z;
|
2021-07-01 19:25:44 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 23:07:21 +01:00
|
|
|
GameScriptRotation::GameScriptRotation(PHD_3DPOS const & pos)
|
2021-06-29 05:28:17 +02:00
|
|
|
{
|
2021-07-03 23:07:21 +01:00
|
|
|
x = pos.xRot;
|
|
|
|
y = pos.yRot;
|
|
|
|
z = pos.zRot;
|
2021-06-29 05:28:17 +02:00
|
|
|
}
|
2021-07-23 02:06:50 +01:00
|
|
|
|
|
|
|
/***
|
|
|
|
@tparam Rotation rotation this rotation
|
|
|
|
@treturn string A string showing the x, y, and z values of the rotation
|
|
|
|
@function __tostring
|
|
|
|
*/
|
|
|
|
std::string GameScriptRotation::ToString() const
|
|
|
|
{
|
|
|
|
return "{" + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + "}";
|
|
|
|
}
|
|
|
|
|