3d movement
This commit is contained in:
@@ -1,53 +1,6 @@
|
||||
#pragma once
|
||||
#include <bx/math.h>
|
||||
#include <cstdint>
|
||||
|
||||
struct SharedData;
|
||||
|
||||
struct IVec2
|
||||
{
|
||||
int32_t X = 0;
|
||||
int32_t Y = 0;
|
||||
};
|
||||
|
||||
struct IVec3
|
||||
{
|
||||
int32_t X = 0;
|
||||
int32_t Y = 0;
|
||||
};
|
||||
|
||||
struct Vec2
|
||||
{
|
||||
float X = 0.0f;
|
||||
float Y = 0.0f;
|
||||
|
||||
void Normalize();
|
||||
};
|
||||
|
||||
struct Vec3
|
||||
{
|
||||
float X = 0.0f;
|
||||
float Y = 0.0f;
|
||||
float Z = 0.0f;
|
||||
|
||||
bx::Vec3 ToBX()
|
||||
{
|
||||
return {X, Y, Z};
|
||||
};
|
||||
|
||||
void Normalize();
|
||||
};
|
||||
|
||||
struct Quat
|
||||
{
|
||||
float X = 0.0f;
|
||||
float Y = 0.0f;
|
||||
float Z = 0.0f;
|
||||
float W = 1.0f;
|
||||
|
||||
static Quat FromEuler(float x, float y, float z);
|
||||
static Quat FromEuler(Vec3 rot);
|
||||
};
|
||||
#include "bx/math.h"
|
||||
|
||||
struct Mat4
|
||||
{
|
||||
@@ -69,15 +22,30 @@ struct Mat4
|
||||
0.0,
|
||||
1.0,
|
||||
};
|
||||
|
||||
static void CreateTransform(float* out, Vec3 pos, Quat rot = {}, Vec3 scale = {1.0f, 1.0f, 1.0f});
|
||||
void TranslateLocal(Vec3 offset);
|
||||
void Rotate(Vec3 rotation);
|
||||
Vec3 Right();
|
||||
Vec3 Up();
|
||||
Vec3 Forward();
|
||||
};
|
||||
|
||||
struct Transform
|
||||
{
|
||||
Mat4 M;
|
||||
Mat4 MI;
|
||||
bx::Vec3 Position{0.0f, 0.0f, 0.0f};
|
||||
Mat4 Rotation;
|
||||
bx::Vec3 Scale{1.0f, 1.0f, 1.0f};
|
||||
|
||||
static void CreateTransform(float* out, bx::Vec3 pos, bx::Quaternion rot, bx::Vec3 scale);
|
||||
void Translate(bx::Vec3 offset);
|
||||
void TranslateLocal(bx::Vec3 offset);
|
||||
void Rotate(bx::Vec3 rotation);
|
||||
void RotateLocal(bx::Vec3 rotation);
|
||||
bx::Vec3 Right() const;
|
||||
bx::Vec3 Up() const;
|
||||
bx::Vec3 Forward() const;
|
||||
const float* GetPtr();
|
||||
void UpdateMatrix();
|
||||
};
|
||||
|
||||
struct SharedData;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
struct GameInstance;
|
||||
|
||||
Reference in New Issue
Block a user