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

#include <model.h>

Public Member Functions

 ModelInstance ()
 
 ModelInstance (MPQFile &f, char const *ModelInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile)
 

Public Attributes

uint32 id
 
Vec3D pos
 
Vec3D rot
 
uint16 scale
 
uint16 flags
 
float sc
 

Constructor & Destructor Documentation

ModelInstance::ModelInstance ( )
inline
61 : id(0), scale(0), flags(0), sc(0.0f) {}
uint32 id
Definition: model.h:56
uint16 flags
Definition: model.h:58
float sc
Definition: model.h:59
uint16 scale
Definition: model.h:58
ModelInstance::ModelInstance ( MPQFile f,
char const ModelInstName,
uint32  mapID,
uint32  tileX,
uint32  tileY,
FILE *  pDirfile 
)
148  : id(0), scale(0), flags(0)
149 {
150  float ff[3];
151  f.read(&id, 4);
152  f.read(ff, 12);
153  pos = fixCoords(Vec3D(ff[0], ff[1], ff[2]));
154  f.read(ff, 12);
155  rot = Vec3D(ff[0], ff[1], ff[2]);
156  f.read(&scale, 2);
157  f.read(&flags, 2);
158  // scale factor - divide by 1024. blizzard devs must be on crack, why not just use a float?
159  sc = scale / 1024.0f;
160 
161  char tempname[512];
162  sprintf(tempname, "%s/%s", szWorkDirWmo, ModelInstName);
163  FILE* input = fopen(tempname, "r+b");
164 
165  if (!input)
166  {
167  //printf("ModelInstance::ModelInstance couldn't open %s\n", tempname);
168  return;
169  }
170 
171  fseek(input, 8, SEEK_SET); // get the correct no of vertices
172  int nVertices;
173  int count = fread(&nVertices, sizeof (int), 1, input);
174  fclose(input);
175 
176  if (count != 1 || nVertices == 0)
177  return;
178 
179  uint16 adtId = 0;// not used for models
180  uint32 flags = MOD_M2;
181  if (tileX == 65 && tileY == 65)
182  flags |= MOD_WORLDSPAWN;
183 
184  //write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name
185  fwrite(&mapID, sizeof(uint32), 1, pDirfile);
186  fwrite(&tileX, sizeof(uint32), 1, pDirfile);
187  fwrite(&tileY, sizeof(uint32), 1, pDirfile);
188  fwrite(&flags, sizeof(uint32), 1, pDirfile);
189  fwrite(&adtId, sizeof(uint16), 1, pDirfile);
190  fwrite(&id, sizeof(uint32), 1, pDirfile);
191  fwrite(&pos, sizeof(float), 3, pDirfile);
192  fwrite(&rot, sizeof(float), 3, pDirfile);
193  fwrite(&sc, sizeof(float), 1, pDirfile);
194  uint32 nlen=strlen(ModelInstName);
195  fwrite(&nlen, sizeof(uint32), 1, pDirfile);
196  fwrite(ModelInstName, sizeof(char), nlen, pDirfile);
197 
198  /* int realx1 = (int) ((float) pos.x / 533.333333f);
199  int realy1 = (int) ((float) pos.z / 533.333333f);
200  int realx2 = (int) ((float) pos.x / 533.333333f);
201  int realy2 = (int) ((float) pos.z / 533.333333f);
202 
203  fprintf(pDirfile,"%s/%s %f,%f,%f_%f,%f,%f %f %d %d %d,%d %d\n",
204  MapName,
205  ModelInstName,
206  (float) pos.x, (float) pos.y, (float) pos.z,
207  (float) rot.x, (float) rot.y, (float) rot.z,
208  sc,
209  nVertices,
210  realx1, realy1,
211  realx2, realy2
212  ); */
213 }
Definition: vmapexport.h:26
static Vec3D fixCoords(const Vec3D &v)
Definition: wmo.h:43
Vec3D pos
Definition: model.h:57
uint32 id
Definition: model.h:56
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
Vec3D rot
Definition: model.h:57
#define input
Definition: wire_format_lite.h:242
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
uint16 flags
Definition: model.h:58
float sc
Definition: model.h:59
#define SEEK_SET
Definition: zconf.h:475
size_t read(void *dest, size_t bytes)
Definition: mpqfile.cpp:52
Definition: vec3d.h:25
const char * szWorkDirWmo
Definition: vmapexport.cpp:81
uint16 scale
Definition: model.h:58
Definition: vmapexport.h:27

+ Here is the call graph for this function:

Member Data Documentation

uint16 ModelInstance::flags
uint32 ModelInstance::id
Vec3D ModelInstance::pos
Vec3D ModelInstance::rot
float ModelInstance::sc
uint16 ModelInstance::scale

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