76 FILE* output = fopen(outfilename,
"wb");
79 printf(
"Can't create the output file '%s'\n", outfilename);
84 fwrite(&nVertices,
sizeof(
int), 1, output);
86 fwrite(&nofgroups,
sizeof(
uint32), 1, output);
87 fwrite(N, 4 * 3, 1, output);
88 fwrite(N,
sizeof(
float), 3 * 2, output);
89 fwrite(N, 4, 1, output);
90 fwrite(
"GRP ", 4, 1, output);
93 wsize =
sizeof(branches) +
sizeof(
uint32) * branches;
94 fwrite(&wsize,
sizeof(
int), 1, output);
95 fwrite(&branches,
sizeof(branches), 1, output);
97 fwrite(&nIndexes,
sizeof(
uint32), 1, output);
98 fwrite(
"INDX", 4, 1, output);
99 wsize =
sizeof(
uint32) +
sizeof(
unsigned short) * nIndexes;
100 fwrite(&wsize,
sizeof(
int), 1, output);
101 fwrite(&nIndexes,
sizeof(
uint32), 1, output);
104 for (
uint32 i = 0; i < nIndexes; ++i)
106 if ((i % 3) - 1 == 0 && i + 1 < nIndexes)
113 fwrite(
indices,
sizeof(
unsigned short), nIndexes, output);
116 fwrite(
"VERT", 4, 1, output);
117 wsize =
sizeof(int) +
sizeof(
float) * 3 * nVertices;
118 fwrite(&wsize,
sizeof(
int), 1, output);
119 fwrite(&nVertices,
sizeof(
int), 1, output);
122 for (
uint32 vpos = 0; vpos < nVertices; ++vpos)
129 fwrite(
vertices,
sizeof(
float) * 3, nVertices, output);
145 FILE* input = fopen(tempname.c_str(),
"r+b");
150 fseek(input, 8, SEEK_SET);
152 int count = fread(&nVertices,
sizeof(
int), 1, input);
155 if (count != 1 || nVertices == 0)
159 float sc = doodadDef.
Scale / 1024.0f;
166 if (tileX == 65 && tileY == 65)
170 fwrite(&mapID,
sizeof(
uint32), 1, pDirfile);
171 fwrite(&tileX,
sizeof(
uint32), 1, pDirfile);
172 fwrite(&tileY,
sizeof(
uint32), 1, pDirfile);
173 fwrite(&tcflags,
sizeof(
uint32), 1, pDirfile);
174 fwrite(&nameSet,
sizeof(
uint16), 1, pDirfile);
175 fwrite(&uniqueId,
sizeof(
uint32), 1, pDirfile);
176 fwrite(&position,
sizeof(
Vec3D), 1, pDirfile);
178 fwrite(&sc,
sizeof(
float), 1, pDirfile);
179 uint32 nlen = strlen(ModelInstName);
180 fwrite(&nlen,
sizeof(
uint32), 1, pDirfile);
181 fwrite(ModelInstName,
sizeof(
char), nlen, pDirfile);
190 G3D::Matrix3 wmoRotation = G3D::Matrix3::fromEulerAnglesZYX(G3D::toRadians(wmo.
Rotation.
y), G3D::toRadians(wmo.
Rotation.
x), G3D::toRadians(wmo.
Rotation.
z));
203 uint32 nlen = ModelInstName.length();
206 if (ModelInstName.ends_with(
".mdx") || ModelInstName.ends_with(
".mdl"))
208 ModelInstName.replace(ModelInstName.length() - 2, 2,
"2");
209 nlen = ModelInstName.length();
213 FILE* input = fopen(tempname.c_str(),
"r+b");
217 fseek(input, 8, SEEK_SET);
219 int count = fread(&nVertices,
sizeof(
int), 1, input);
222 if (count != 1 || nVertices == 0)
225 ASSERT(doodadId < std::numeric_limits<uint16>::max());
232 .toRotationMatrix() * wmoRotation)
233 .toEulerAnglesXYZ(rotation.z, rotation.x, rotation.y);
235 rotation.
z = G3D::toDegrees(rotation.z);
236 rotation.x = G3D::toDegrees(rotation.x);
237 rotation.y = G3D::toDegrees(rotation.y);
242 if (tileX == 65 && tileY == 65)
246 fwrite(&mapID,
sizeof(
uint32), 1, pDirfile);
247 fwrite(&tileX,
sizeof(
uint32), 1, pDirfile);
248 fwrite(&tileY,
sizeof(
uint32), 1, pDirfile);
249 fwrite(&tcflags,
sizeof(
uint32), 1, pDirfile);
250 fwrite(&nameSet,
sizeof(
uint16), 1, pDirfile);
251 fwrite(&uniqueId,
sizeof(
uint32), 1, pDirfile);
252 fwrite(&position,
sizeof(
Vec3D), 1, pDirfile);
253 fwrite(&rotation,
sizeof(
Vec3D), 1, pDirfile);
254 fwrite(&doodad.
Scale,
sizeof(
float), 1, pDirfile);
255 fwrite(&nlen,
sizeof(
uint32), 1, pDirfile);
256 fwrite(ModelInstName.c_str(),
sizeof(
char), nlen, pDirfile);
void Extract(ADT::MDDF const &doodadDef, char const *ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
void ExtractSet(WMODoodadData const &doodadData, ADT::MODF const &wmo, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)