-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpmxLoader.hpp
110 lines (96 loc) · 2.03 KB
/
pmxLoader.hpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include <vector>
#include <string>
namespace kazakami
{
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
struct PMXVertex
{
float pos[3];
float normal[3];
float UV[2];
unsigned char weightType;
int boneIndex1, boneIndex2, boneIndex3, boneIndex4;
float weight1, weight2, weight3, weight4;
float C[3];
float R0[3];
float R1[3];
float edge;
};
struct PMXMaterial
{
std::string name;
std::string nameEng;
float diffuse[4];
float specular[3];
float shininess;
float ambient[3];
uchar drawFlag;
float edgeColor[4];
float edgeSize;
int normalTexture;
int sphereTexture;
uchar sphereMode;
uchar sharedToonFlag;
int toonTexture;
uchar sharedToonTexture;
std::string memo;
int vertexNum;
};
struct IKLink
{
int linkBoneIndex;
uchar angleLimit;
float lowerLimit[3];
float upperLimit[3];
};
struct PMXBone
{
std::string name;
std::string nameEng;
float pos[3];
int parentBoneIndex;
int transformHierarchy;
ushort boneFlag;
float posOffset[3];
int connectedBoneIndex;
int grantParentBoneIndex;
float grantRatio;
float axisDirectVector[3];
float xAxisDirectVector[3];
float zAxisDirectVector[3];
int keyValue;
int IKTargetBoneIndex;
int IKLoopNum;
float IKLimitAngle;
int IKLinkNum;
std::vector<IKLink> IKLinks;
};
class PMXLoader
{
std::string readTextBuf(std::ifstream * ifs) const;
PMXVertex readPMDVertex(std::ifstream * ifs) const;
PMXMaterial readMaterial(std::ifstream * ifs) const;
PMXBone readBone(std::ifstream * ifs) const;
int readNumber(std::ifstream * ifs, uint length) const;
int textureIndexSize;
int boneIndexSize;
int vertexIndexSize;
public:
int vertexNum;
int faceNum;
int texNum;
int mtrNum;
int boneNum;
int morphNum;
std::vector<PMXVertex> vertexes;
std::vector<int> faceIndex;
std::vector<std::string> textureNames;
std::vector<PMXMaterial> materials;
std::vector<PMXBone> bones;
int readPMX(const char * filename);
int readPMX(const std::string & filename);
};
}