Files
Collage/include/types/model.h
2024-05-05 10:46:01 -04:00

45 lines
1.2 KiB
C++

#pragma once
#include <vector>
#include <sstream>
#include <fstream>
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra/Vector3.h>
#include<J3ML/Geometry.h>
#include <types/textureInfo.h>
typedef Vector3 Vertex;
enum struct ModelType : uint8_t {
WAVEFRONT_OBJ = 0,
ANIMATED_WAVEFRONT_OBJ = 1,
FBX = 2, //More complicated.
COLLADA = 3, //*Very* complicated.
};
class SkeletalVertex : public Vertex {
int8_t joints[3]; //The index of 4 bones that can effect the vertex. 0 represents an empty slot. -1 represents the root bone.
Vector4 weights; //The 4 weights must total to 1.0
};
class Model {
protected:
std::vector<Vertex> vertices;
std::vector<uint> indices;
std::vector<TextureInformation> textureInfo;
void load(const std::string& file);
void load(const std::string& file, const ModelType& type);
public:
ModelType type;
const std::vector<Vertex>& getVertices();
const std::vector<uint>& getIndices();
const std::vector<TextureInformation>& getTextureInformation();
Model() = default;
Model(const std::string& file);
};
class SkeletalModel : public Model {
protected:
std::vector<SkeletalVertex> vertices;
public:
std::vector<SkeletalVertex>& getSkeletalertices();
};