AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
MapObject Namespace Reference

Functions

void Extract (ADT::MODF const &mapObjDef, char const *WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
 

Function Documentation

◆ Extract()

void MapObject::Extract ( ADT::MODF const &  mapObjDef,
char const *  WmoInstName,
uint32  mapID,
uint32  tileX,
uint32  tileY,
FILE *  pDirfile 
)
511{
512 // destructible wmo, do not dump. we can handle the vmap for these
513 // in dynamic tree (gameobject vmaps)
514 if ((mapObjDef.Flags & 0x1) != 0)
515 return;
516
517 //-----------add_in _dir_file----------------
518
519 char tempname[1036];
520 sprintf(tempname, "%s/%s", szWorkDirWmo, WmoInstName);
521 FILE* input;
522 input = fopen(tempname, "r+b");
523
524 if (!input)
525 {
526 printf("WMOInstance::WMOInstance: couldn't open %s\n", tempname);
527 return;
528 }
529
530 fseek(input, 8, SEEK_SET); // get the correct no of vertices
531 int nVertices;
532 int count = fread(&nVertices, sizeof (int), 1, input);
533 fclose(input);
534
535 if (count != 1 || nVertices == 0)
536 return;
537
538 Vec3D position = mapObjDef.Position;
539
540 float x, z;
541 x = position.x;
542 z = position.z;
543 if (x == 0 && z == 0)
544 {
545 position.x = 533.33333f * 32;
546 position.z = 533.33333f * 32;
547 }
548 position = fixCoords(position);
549 AaBox3D bounds;
550 bounds.min = fixCoords(mapObjDef.Bounds.min);
551 bounds.max = fixCoords(mapObjDef.Bounds.max);
552
553 float scale = 1.0f;
554 uint32 uniqueId = GenerateUniqueObjectId(mapObjDef.UniqueId, 0);
555 uint32 flags = MOD_HAS_BOUND;
556 if (tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
557 //write mapID, tileX, tileY, Flags, NameSet, UniqueId, Pos, Rot, Scale, Bound_lo, Bound_hi, name
558 fwrite(&mapID, sizeof(uint32), 1, pDirfile);
559 fwrite(&tileX, sizeof(uint32), 1, pDirfile);
560 fwrite(&tileY, sizeof(uint32), 1, pDirfile);
561 fwrite(&flags, sizeof(uint32), 1, pDirfile);
562 fwrite(&mapObjDef.NameSet, sizeof(uint16), 1, pDirfile);
563 fwrite(&uniqueId, sizeof(uint32), 1, pDirfile);
564 fwrite(&position, sizeof(Vec3D), 1, pDirfile);
565 fwrite(&mapObjDef.Rotation, sizeof(Vec3D), 1, pDirfile);
566 fwrite(&scale, sizeof(float), 1, pDirfile);
567 fwrite(&bounds, sizeof(AaBox3D), 1, pDirfile);
568 uint32 nlen = strlen(WmoInstName);
569 fwrite(&nlen, sizeof(uint32), 1, pDirfile);
570 fwrite(WmoInstName, sizeof(char), nlen, pDirfile);
571
572}
std::uint32_t uint32
Definition: Define.h:108
std::uint16_t uint16
Definition: Define.h:109
uint32 GenerateUniqueObjectId(uint32 clientId, uint16 clientDoodadId)
Definition: vmapexport.cpp:72
char const * szWorkDirWmo
Definition: vmapexport.cpp:68
@ MOD_WORLDSPAWN
Definition: vmapexport.h:34
@ MOD_HAS_BOUND
Definition: vmapexport.h:35
static Vec3D fixCoords(const Vec3D &v)
Definition: wmo.h:68
Definition: vec3d.h:25
float x
Definition: vec3d.h:27
float z
Definition: vec3d.h:27
Definition: vec3d.h:141
Vec3D max
Definition: vec3d.h:144
Vec3D min
Definition: vec3d.h:143

References ADT::MODF::Bounds, fixCoords(), ADT::MODF::Flags, GenerateUniqueObjectId(), AaBox3D::max, AaBox3D::min, MOD_HAS_BOUND, MOD_WORLDSPAWN, ADT::MODF::NameSet, ADT::MODF::Position, ADT::MODF::Rotation, szWorkDirWmo, ADT::MODF::UniqueId, Vec3D::x, and Vec3D::z.

Referenced by ADTFile::init(), and WDTFile::init().