97 lines
2.1 KiB
C++
97 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "common.h"
|
|
|
|
#define MAX_CUBES 20
|
|
#define MAX_ANIMS 40
|
|
#define MAX_KEYS 256
|
|
|
|
struct CubeFace
|
|
{
|
|
Vector2 uv[4] {{32, 32}, {32, 0}, {0, 0}, {0, 32}};
|
|
char rot {0};
|
|
bool selected {false};
|
|
|
|
void Clear();
|
|
void Rotate();
|
|
void FlipH();
|
|
void FlipV();
|
|
};
|
|
|
|
struct Cube
|
|
{
|
|
char name[10] {""};
|
|
CubeFace faces[6];
|
|
Vector3 position {0, 0, 0};
|
|
Vector3 pivot {0, 0, 0};
|
|
Vector3 size {8, 8, 8};
|
|
int8_t parent {-1};
|
|
bool selected {false};
|
|
};
|
|
|
|
struct AnimKey
|
|
{
|
|
enum class Type { Position, Rotation, Scale };
|
|
|
|
float t {0.0f};
|
|
uint8_t cube {0};
|
|
Type type {Type::Rotation};
|
|
Vector3 value {0, 0, 0};
|
|
};
|
|
|
|
struct Anim
|
|
{
|
|
char name[10] {""};
|
|
uint8_t numKeys {0};
|
|
AnimKey keys[MAX_KEYS];
|
|
};
|
|
|
|
struct Model
|
|
{
|
|
uint8_t numCubes {1};
|
|
Cube cubes[MAX_CUBES];
|
|
uint8_t numAnims {1};
|
|
Anim anims[MAX_ANIMS];
|
|
|
|
Matrix4 localMatrix[MAX_CUBES];
|
|
Matrix4 finalMatrix[MAX_CUBES];
|
|
|
|
void Save(const char* filename);
|
|
void Load(const char* filename);
|
|
void Calculate();
|
|
void DrawSolid();
|
|
void DrawWire();
|
|
void DrawUV();
|
|
Color Pick(const float x, const float y);
|
|
Color PickPaint(const float x, const float y);
|
|
Color PickPixel(const float x, const float y);
|
|
|
|
int GetSelectedCube();
|
|
void SelectCube(const uint8_t index, const bool inclusive);
|
|
void SelectAllCubes(const bool select = true);
|
|
void NewCube();
|
|
void DeleteCube();
|
|
void DupCube();
|
|
void GrabCubes(const float x, const float y, const float z);
|
|
void ScaleCubes(const float x, const float y, const float z);
|
|
|
|
ivec2 GetSelectedFace();
|
|
void SelectFace(const uint8_t index, const uint8_t face, const bool inclusive);
|
|
void SelectAllFaces(const bool select = true);
|
|
void ClearFaces();
|
|
void RotateFaces();
|
|
void FlipHFaces();
|
|
void FlipVFaces();
|
|
void GrabFaces(const float x, const float y);
|
|
void ScaleFaces(const float x, const float y);
|
|
|
|
void DeleteKey(const int anim, const int key);
|
|
|
|
private:
|
|
|
|
const Vector3 GetCurrentValue(const int& cube, const AnimKey::Type& type);
|
|
void GetCurrentTransformation(const int& cube, Vector3& position, Vector3& rotation, Vector3& scale);
|
|
};
|
|
|
|
extern Model model;
|