32 : filename(filename), color(0), nTextures(0), nGroups(0), nPortals(0), nLights(0),
33 nDoodadNames(0), nDoodadDefs(0), nDoodadSets(0), RootWMOID(0),
flags(0)
44 printf(
"No such file.\n");
59 size_t nextpos = f.
getPos() + size;
61 if (!strcmp(fourcc,
"MOHD"))
76 else if (!strcmp(fourcc,
"MODS"))
81 else if (!strcmp(fourcc,
"MODN"))
84 char* end = ptr + size;
89 std::string path = ptr;
96 ptr += path.length() + 1;
102 else if (!strcmp(fourcc,
"MODD"))
107 else if (!strcmp(fourcc,
"MOGN"))
141 f.
seek((
int)nextpos);
152 unsigned int nVectors = 0;
153 fwrite(&nVectors,
sizeof(nVectors), 1, pOutfile);
154 fwrite(&
nGroups, 4, 1, pOutfile);
160 filename(filename), MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0),
161 hlq(0), LiquEx(0), LiquBytes(0), groupName(0), descGroupName(0), mogpFlags(0),
162 moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), nBatchC(0), fogIdx(0),
163 groupLiquid(0), groupWMOID(0), mopy_size(0), moba_size(0), LiquEx_size(0),
164 nVertices(0), nTriangles(0), liquflags(0)
175 printf(
"No such file.\n");
185 if (!strcmp(fourcc,
"MOGP"))
190 size_t nextpos = f.
getPos() + size;
191 if (!strcmp(fourcc,
"MOGP"))
208 if (rootWMO->
flags & 4)
218 else if (!strcmp(fourcc,
"MOPY"))
220 MOPY =
new char[size];
225 else if (!strcmp(fourcc,
"MOVI"))
230 else if (!strcmp(fourcc,
"MOVT"))
232 MOVT =
new float[size/4];
236 else if (!strcmp(fourcc,
"MONR"))
239 else if (!strcmp(fourcc,
"MOTV"))
242 else if (!strcmp(fourcc,
"MOBA"))
248 else if (!strcmp(fourcc,
"MODR"))
253 else if (!strcmp(fourcc,
"MLIQ"))
285 f.
seek((
int)nextpos);
296 fwrite(
bbcorn1,
sizeof(
float), 3, output);
297 fwrite(
bbcorn2,
sizeof(
float), 3, output);
299 int nColTriangles = 0;
303 fwrite(GRP,1,4,output);
307 MobaEx =
new int[moba_batch*4];
312 int moba_size_grp = moba_batch*4+4;
313 fwrite(&moba_size_grp,4,1,output);
314 fwrite(&moba_batch,4,1,output);
315 fwrite(
MobaEx,4,k,output);
320 if(fwrite(
"INDX",4, 1, output) != 1)
322 printf(
"Error while writing file nbraches ID");
325 int wsize =
sizeof(
uint32) +
sizeof(
unsigned short) * nIdexes;
326 if(fwrite(&wsize,
sizeof(
int), 1, output) != 1)
328 printf(
"Error while writing file wsize");
331 if(fwrite(&nIdexes,
sizeof(
uint32), 1, output) != 1)
333 printf(
"Error while writing file nIndexes");
338 if(fwrite(
MOVI,
sizeof(
unsigned short), nIdexes, output) != nIdexes)
340 printf(
"Error while writing file indexarray");
345 if(fwrite(
"VERT",4, 1, output) != 1)
347 printf(
"Error while writing file nbraches ID");
350 wsize =
sizeof(int) +
sizeof(
float) * 3 *
nVertices;
351 if(fwrite(&wsize,
sizeof(
int), 1, output) != 1)
353 printf(
"Error while writing file wsize");
356 if(fwrite(&
nVertices,
sizeof(
int), 1, output) != 1)
358 printf(
"Error while writing file nVertices");
365 printf(
"Error while writing file vectors");
375 fwrite(GRP,1,4,output);
378 MobaEx =
new int[moba_batch*4];
384 int moba_size_grp = moba_batch*4+4;
385 fwrite(&moba_size_grp,4,1,output);
386 fwrite(&moba_batch,4,1,output);
387 fwrite(
MobaEx,4,k,output);
394 memset(IndexRenum, 0xFF,
nVertices*
sizeof(
int));
404 for (
int j=0; j<3; ++j)
406 IndexRenum[
MOVI[3*i + j]] = 1;
413 int nColVertices = 0;
416 if (IndexRenum[i] == 1)
418 IndexRenum[i] = nColVertices;
424 for (
int i=0; i<3*nColTriangles; ++i)
431 int INDX[] = {0x58444E49, nColTriangles*6+4, nColTriangles*3};
432 fwrite(INDX,4,3,output);
433 fwrite(
MoviEx,2,nColTriangles*3,output);
436 int VERT[] = {0x54524556, nColVertices*3*
static_cast<int>(
sizeof(float))+4, nColVertices};
437 int check = 3*nColVertices;
438 fwrite(VERT,4,3,output);
440 if(IndexRenum[i] >= 0)
441 check -= fwrite(
MOVT+3*i,
sizeof(
float), 3, output);
446 delete [] IndexRenum;
452 int LIQU_totalSize =
sizeof(
uint32);
459 int LIQU_h[] = { 0x5551494C, LIQU_totalSize };
460 fwrite(LIQU_h, 4, 2, output);
473 fwrite(&
LiquEx[i].height,
sizeof(
float), 1, output);
479 return nColTriangles;
484 if (liquidTypeId < 21 && liquidTypeId)
486 switch (((
static_cast<uint8>(liquidTypeId) - 1) & 3))
488 case 0:
return ((
mogpFlags & 0x80000) != 0) + 13;
529 if ((mapObjDef.
Flags & 0x1) != 0)
535 FILE* input = fopen(tempname.c_str(),
"r+b");
539 printf(
"WMOInstance::WMOInstance: couldn't open %s\n", tempname.c_str());
543 fseek(input, 8, SEEK_SET);
545 int count = fread(&nVertices,
sizeof(
int), 1, input);
548 if (count != 1 || nVertices == 0)
556 if (x == 0 && z == 0)
558 position.
x = 533.33333f * 32;
559 position.
z = 533.33333f * 32;
571 fwrite(&mapID,
sizeof(
uint32), 1, pDirfile);
572 fwrite(&tileX,
sizeof(
uint32), 1, pDirfile);
573 fwrite(&tileY,
sizeof(
uint32), 1, pDirfile);
576 fwrite(&uniqueId,
sizeof(
uint32), 1, pDirfile);
577 fwrite(&position,
sizeof(
Vec3D), 1, pDirfile);
579 fwrite(&scale,
sizeof(
float), 1, pDirfile);
580 fwrite(&bounds,
sizeof(
AaBox3D), 1, pDirfile);
581 uint32 nlen = strlen(WmoInstName);
582 fwrite(&nlen,
sizeof(
uint32), 1, pDirfile);
583 fwrite(WmoInstName,
sizeof(
char), nlen, pDirfile);
char const * GetPlainName(char const *FileName)
void FixNameCase(char *name, size_t len)
void FixNameSpaces(char *name, size_t len)
size_t read(void *dest, size_t bytes)
WMOGroup(std::string const &filename)
std::vector< uint16 > DoodadReferences
bool open(WMORoot *rootWMO)
uint32 GetLiquidTypeId(uint32 liquidTypeId)
int ConvertToVMAPGroupWmo(FILE *output, bool preciseVectorData)
bool ShouldSkip(WMORoot const *root) const
std::vector< char > GroupNames
std::unordered_set< uint32 > ValidDoodadNames
bool ConvertToVMAPRootWmo(FILE *output)
WMORoot(std::string const &filename)
void Extract(ADT::MODF const &mapObjDef, char const *WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
const char RAW_VMAP_MAGIC[]
std::vector< WMO::MODS > Sets
std::vector< WMO::MODD > Spawns
std::unique_ptr< char[]> Paths
uint32 GenerateUniqueObjectId(uint32 clientId, uint16 clientDoodadId)
char const * szWorkDirWmo
static Vec3D fixCoords(Vec3D const &v)