TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WMOInstance Class Reference

#include <wmo.h>

Public Member Functions

 WMOInstance (MPQFile &f, char const *WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
 

Static Public Member Functions

static void reset ()
 

Public Attributes

std::string MapName
 
int currx
 
int curry
 
WMOGroupwmo
 
int doodadset
 
Vec3D pos
 
Vec3D pos2
 
Vec3D pos3
 
Vec3D rot
 
uint32 indx
 
uint32 id
 
uint32 d2
 
uint32 d3
 

Static Private Attributes

static std::set< int > ids
 

Constructor & Destructor Documentation

WMOInstance::WMOInstance ( MPQFile f,
char const WmoInstName,
uint32  mapID,
uint32  tileX,
uint32  tileY,
FILE *  pDirfile 
)
489  : currx(0), curry(0), wmo(NULL), doodadset(0), pos(), indx(0), id(0), d2(0), d3(0)
490 {
491  float ff[3];
492  f.read(&id, 4);
493  f.read(ff,12);
494  pos = Vec3D(ff[0],ff[1],ff[2]);
495  f.read(ff,12);
496  rot = Vec3D(ff[0],ff[1],ff[2]);
497  f.read(ff,12);
498  pos2 = Vec3D(ff[0],ff[1],ff[2]);
499  f.read(ff,12);
500  pos3 = Vec3D(ff[0],ff[1],ff[2]);
501  f.read(&d2,4);
502 
503  uint16 trash,adtId;
504  f.read(&adtId,2);
505  f.read(&trash,2);
506 
507  //-----------add_in _dir_file----------------
508 
509  char tempname[512];
510  sprintf(tempname, "%s/%s", szWorkDirWmo, WmoInstName);
511  FILE *input;
512  input = fopen(tempname, "r+b");
513 
514  if(!input)
515  {
516  printf("WMOInstance::WMOInstance: couldn't open %s\n", tempname);
517  return;
518  }
519 
520  fseek(input, 8, SEEK_SET); // get the correct no of vertices
521  int nVertices;
522  int count = fread(&nVertices, sizeof (int), 1, input);
523  fclose(input);
524 
525  if (count != 1 || nVertices == 0)
526  return;
527 
528  float x,z;
529  x = pos.x;
530  z = pos.z;
531  if(x==0 && z == 0)
532  {
533  pos.x = 533.33333f*32;
534  pos.z = 533.33333f*32;
535  }
536  pos = fixCoords(pos);
537  pos2 = fixCoords(pos2);
538  pos3 = fixCoords(pos3);
539 
540  float scale = 1.0f;
542  if(tileX == 65 && tileY == 65) flags |= MOD_WORLDSPAWN;
543  //write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
544  fwrite(&mapID, sizeof(uint32), 1, pDirfile);
545  fwrite(&tileX, sizeof(uint32), 1, pDirfile);
546  fwrite(&tileY, sizeof(uint32), 1, pDirfile);
547  fwrite(&flags, sizeof(uint32), 1, pDirfile);
548  fwrite(&adtId, sizeof(uint16), 1, pDirfile);
549  fwrite(&id, sizeof(uint32), 1, pDirfile);
550  fwrite(&pos, sizeof(float), 3, pDirfile);
551  fwrite(&rot, sizeof(float), 3, pDirfile);
552  fwrite(&scale, sizeof(float), 1, pDirfile);
553  fwrite(&pos2, sizeof(float), 3, pDirfile);
554  fwrite(&pos3, sizeof(float), 3, pDirfile);
555  uint32 nlen=strlen(WmoInstName);
556  fwrite(&nlen, sizeof(uint32), 1, pDirfile);
557  fwrite(WmoInstName, sizeof(char), nlen, pDirfile);
558 
559  /* fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f 1.0 %d %d %d,%d %d\n",
560  MapName,
561  WmoInstName,
562  (float) x, (float) pos.y, (float) z,
563  (float) rot.x, (float) rot.y, (float) rot.z,
564  nVertices,
565  realx1, realy1,
566  realx2, realy2
567  ); */
568 
569  // fclose(dirfile);
570 }
float x
Definition: vec3d.h:28
uint32 indx
Definition: wmo.h:131
int currx
Definition: wmo.h:125
arena_t NULL
Definition: jemalloc_internal.h:624
Vec3D pos2
Definition: wmo.h:130
uint32 d3
Definition: wmo.h:131
static Vec3D fixCoords(const Vec3D &v)
Definition: wmo.h:43
uint32 d2
Definition: wmo.h:131
WMOGroup * wmo
Definition: wmo.h:127
uint32 id
Definition: wmo.h:131
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
int curry
Definition: wmo.h:126
G3D::int16 z
Definition: Vector3int16.h:46
#define input
Definition: wire_format_lite.h:242
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
int doodadset
Definition: wmo.h:128
#define SEEK_SET
Definition: zconf.h:475
float z
Definition: vec3d.h:28
size_t read(void *dest, size_t bytes)
Definition: mpqfile.cpp:52
Vec3D pos3
Definition: wmo.h:130
Vec3D pos
Definition: wmo.h:129
Definition: vmapexport.h:28
Definition: vec3d.h:25
uint8 flags
Definition: DisableMgr.cpp:44
G3D::int16 x
Definition: Vector2int16.h:37
const char * szWorkDirWmo
Definition: vmapexport.cpp:81
Vec3D rot
Definition: wmo.h:130
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083
Definition: vmapexport.h:27

+ Here is the call graph for this function:

Member Function Documentation

static void WMOInstance::reset ( )
static

Member Data Documentation

int WMOInstance::currx
int WMOInstance::curry
uint32 WMOInstance::d2
uint32 WMOInstance::d3
int WMOInstance::doodadset
uint32 WMOInstance::id
std::set<int> WMOInstance::ids
staticprivate
uint32 WMOInstance::indx
std::string WMOInstance::MapName
Vec3D WMOInstance::pos
Vec3D WMOInstance::pos2
Vec3D WMOInstance::pos3
Vec3D WMOInstance::rot
WMOGroup* WMOInstance::wmo

The documentation for this class was generated from the following files: