-
Notifications
You must be signed in to change notification settings - Fork 0
/
fo3d.h
66 lines (55 loc) · 1.18 KB
/
fo3d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//FoUnbaker3D - fo3d.h: the header of FOnline Engine's 3D models parser.
//Copyright (C) 2024, APAMk2
#pragma once
#include "ByteReader.hpp"
#include <string>
#include <vector>
#define BONES_PER_VERTEX ( 4 )
struct Matrix {
float a1, a2, a3, a4;
float b1, b2, b3, b4;
float c1, c2, c3, c4;
float d1, d2, d3, d4;
};
struct Vertex3D
{
float position[3];
float normal[3];
float texCoord[2];
float texCoordBase[2];
float tangent[3];
float bitangent[3];
float blendWeights[BONES_PER_VERTEX];
float blendIndices[BONES_PER_VERTEX];
};
class Mesh_t
{
public:
std::vector<Vertex3D> vertices;
std::vector<uint32_t> indices;
std::string diffuseTexture;
std::vector<uint32_t> skinBoneNameHashes;
std::vector<Matrix> skinBoneOffsets;
void read(ByteReader* reader);
};
class Bone_t
{
public:
uint32_t nameHash;
float transformationMatrix[16];
float globalTransformationMatrix[16];
Mesh_t mesh;
std::vector<Bone_t> childBones;
void read(ByteReader* reader);
};
class file_t
{
public:
Bone_t skeleton;
void read(ByteReader* reader);
};
union float2bytes
{
float value;
uint8_t bytes[sizeof(float)];
};