-
Notifications
You must be signed in to change notification settings - Fork 0
/
w-bmd.bt
228 lines (181 loc) · 4.98 KB
/
w-bmd.bt
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//------------------------------------------------
//--- 010 Editor v11.0.1 Binary Template
//
// File: Bmd File
// Authors: Hollyland
// Version: 0.0.1
// Purpose: Reader Bmd Model File
// Category:
// File Mask: MOXB
// ID Bytes: 4D4F5842
// History:
//------------------------------------------------
typedef DWORD A3DCOLOR; // Color
struct A3DVECTOR3 {
float x, y, z;
};
struct A3DLVERTEX
{
FLOAT x, y, z;
DWORD diffuse;
DWORD specular;
FLOAT tu, tv;
};
struct A3DLMVERTEX_WITHOUTNORMAL {
A3DVECTOR3 pos;
A3DCOLOR diffuse;
float u;
float v;
};
struct A3DAABB {
A3DVECTOR3 Center;
A3DVECTOR3 Extents;
A3DVECTOR3 Mins;
A3DVECTOR3 Maxs;
};
struct MeshV2 {
char szName[64];
char szTextureMap[256];
int nVertCount, nFaceCount;
A3DLVERTEX pVerts[nVertCount];
WORD m_pIndices[nFaceCount * 3];
A3DVECTOR3 m_pNormals[nVertCount];
A3DAABB m_aabb;
};
struct MeshV3 {
char szName[64];
char szTextureMap[256];
int nVertCount, nFaceCount;
A3DLVERTEX pVerts[nVertCount];
WORD m_pIndices[nFaceCount * 3];
A3DVECTOR3 m_pNormals[nVertCount];
A3DCOLOR m_pDayColors[nVertCount];
A3DCOLOR m_pNightColors[nVertCount];
A3DAABB m_aabb;
};
struct MeshV4 {
char szName[64];
char szTextureMap[256];
int nVertCount, nFaceCount;
A3DLMVERTEX_WITHOUTNORMAL pVerts[nVertCount];
WORD m_pIndices[nFaceCount * 3];
A3DVECTOR3 m_pNormals[nVertCount];
A3DCOLOR m_pDayColors[nVertCount];
A3DCOLOR m_pNightColors[nVertCount];
A3DAABB m_aabb;
};
struct A3DCOLORVALUE {
float r, g, b, a;
};
struct A3DMATERIALPARAM
{
A3DCOLORVALUE Diffuse;
A3DCOLORVALUE Ambient;
A3DCOLORVALUE Specular;
A3DCOLORVALUE Emissive;
FLOAT Power;
byte m_b2Sided;
};
struct MeshV5 {
char szName[64];
char szTextureMap[256];
int nVertCount, nFaceCount;
A3DLMVERTEX_WITHOUTNORMAL pVerts[nVertCount];
WORD m_pIndices[nFaceCount * 3];
A3DVECTOR3 m_pNormals[nVertCount];
A3DCOLOR m_pDayColors[nVertCount];
A3DCOLOR m_pNightColors[nVertCount];
A3DAABB m_aabb;
A3DMATERIALPARAM m_Material;
};
struct MeshV6 {
char szName[64];
char szTextureMap[256];
int nVertCount, nFaceCount;
byte m_bHasExtraColors;
A3DLMVERTEX_WITHOUTNORMAL pVerts[nVertCount];
WORD m_pIndices[nFaceCount * 3];
A3DVECTOR3 m_pNormals[nVertCount];
A3DCOLOR m_pDayColors[nVertCount];
A3DCOLOR m_pNightColors[nVertCount];
if(m_bHasExtraColors > 0) {
A3DCOLOR m_pDayColorsExtra[nVertCount];
A3DCOLOR m_pNightColorsExtra[nVertCount];
}
A3DAABB m_aabb;
A3DMATERIALPARAM m_Material;
};
struct A3DLIGHTMAPCOORD {
float u, v;
};
struct MeshV100 {
char szName[64];
char szTextureMap[256];
int nVertCount, nFaceCount;
A3DLMVERTEX_WITHOUTNORMAL pVerts[nVertCount];
WORD m_pIndices[nFaceCount * 3];
A3DVECTOR3 m_pNormals[nVertCount];
A3DCOLOR m_pDayColors[nVertCount];
A3DCOLOR m_pNightColors[nVertCount];
A3DAABB m_aabb;
A3DMATERIALPARAM m_Material;
A3DLIGHTMAPCOORD m_pLMCoords[nVertCount];
};
int dwHeader;
int version<format=hex>;
//int dwVersion<format=hex>;
if (version == 0x80000001) {
byte bCollideOnly;
int dwVersion;
}
else {
local int dwVersion = version;
}
// then output some basic information of this model
A3DVECTOR3 m_vecScale;
A3DVECTOR3 m_vecDir;
A3DVECTOR3 m_vecUp;
A3DVECTOR3 m_vecPos;
// now read the number of meshes in this model
int nNumMeshes<fgcolor=0xffffff, bgcolor=0x0000FF,comment="文件中包含模型数量">;
local int i;
for(i = 0; i < nNumMeshes; i++) {
DWORD dmVersion <format=hex,optimize=false>;
if( dmVersion[i] == 0x10000002 )
MeshV2 v2 <optimize=false>;
if( dmVersion[i] == 0x10000003 )
MeshV3 v3 <optimize=false>;
if( dmVersion[i] == 0x10000004 )
MeshV4 v4 <optimize=false>;
if( dmVersion[i] == 0x10000005 )
MeshV5 v5 <optimize=false>;
if( dmVersion[i] == 0x10000006 )
MeshV6 v6 <optimize=false>;
if( dmVersion[i] == 0x10000100 ) {
MeshV100 v100 <optimize=false>;
}
}
if( dwVersion == 0x10000100 ) {
char m_szLightMap[256];
}
if( dwVersion == 0x10000101 ) {
char m_szLightMap[260];
char m_szNightLightMap[260];
}
struct MESHLIST {
int nNumMesh;
int meshList[nNumMesh];
};
struct CCDSide {
A3DVECTOR3 vNormal;
float fDist;
byte bBevel;
};
int m_nNumHull;
if ( m_nNumHull > 0) {
MESHLIST meshList[m_nNumHull+8];
A3DAABB m_aabb;
DWORD m_dwReserved;
int m_nSides;
CCDSide side[m_nSides];
}