TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MMAP::IntermediateValues Struct Reference

#include <IntermediateValues.h>

Public Member Functions

 IntermediateValues ()
 
 ~IntermediateValues ()
 
void writeIV (uint32 mapID, uint32 tileX, uint32 tileY)
 
void debugWrite (FILE *file, const rcHeightfield *mesh)
 
void debugWrite (FILE *file, const rcCompactHeightfield *chf)
 
void debugWrite (FILE *file, const rcContourSet *cs)
 
void debugWrite (FILE *file, const rcPolyMesh *mesh)
 
void debugWrite (FILE *file, const rcPolyMeshDetail *mesh)
 
void generateObjFile (uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData)
 

Public Attributes

rcHeightfieldheightfield
 
rcCompactHeightfieldcompactHeightfield
 
rcContourSetcontours
 
rcPolyMeshpolyMesh
 
rcPolyMeshDetailpolyMeshDetail
 

Constructor & Destructor Documentation

MMAP::IntermediateValues::IntermediateValues ( )
inline
rcPolyMesh * polyMesh
Definition: IntermediateValues.h:35
rcPolyMeshDetail * polyMeshDetail
Definition: IntermediateValues.h:36
rcContourSet * contours
Definition: IntermediateValues.h:34
arena_t NULL
Definition: jemalloc_internal.h:624
rcCompactHeightfield * compactHeightfield
Definition: IntermediateValues.h:33
rcHeightfield * heightfield
Definition: IntermediateValues.h:32
MMAP::IntermediateValues::~IntermediateValues ( )
24  {
30  }
void rcFreeCompactHeightfield(rcCompactHeightfield *chf)
Definition: Recast.cpp:102
rcPolyMesh * polyMesh
Definition: IntermediateValues.h:35
rcPolyMeshDetail * polyMeshDetail
Definition: IntermediateValues.h:36
rcContourSet * contours
Definition: IntermediateValues.h:34
void rcFreeHeightField(rcHeightfield *hf)
Definition: Recast.cpp:80
void rcFreePolyMeshDetail(rcPolyMeshDetail *dmesh)
Definition: Recast.cpp:178
rcCompactHeightfield * compactHeightfield
Definition: IntermediateValues.h:33
rcHeightfield * heightfield
Definition: IntermediateValues.h:32
void rcFreePolyMesh(rcPolyMesh *pmesh)
Definition: Recast.cpp:160
void rcFreeContourSet(rcContourSet *cset)
Definition: Recast.cpp:141

+ Here is the call graph for this function:

Member Function Documentation

void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcHeightfield mesh 
)
73  {
74  if (!file || !mesh)
75  return;
76 
77  fwrite(&(mesh->cs), sizeof(float), 1, file);
78  fwrite(&(mesh->ch), sizeof(float), 1, file);
79  fwrite(&(mesh->width), sizeof(int), 1, file);
80  fwrite(&(mesh->height), sizeof(int), 1, file);
81  fwrite(mesh->bmin, sizeof(float), 3, file);
82  fwrite(mesh->bmax, sizeof(float), 3, file);
83 
84  for (int y = 0; y < mesh->height; ++y)
85  for (int x = 0; x < mesh->width; ++x)
86  {
87  rcSpan* span = mesh->spans[x+y*mesh->width];
88 
89  // first, count the number of spans
90  int spanCount = 0;
91  while (span)
92  {
93  spanCount++;
94  span = span->next;
95  }
96 
97  // write the span count
98  fwrite(&spanCount, sizeof(int), 1, file);
99 
100  // write the spans
101  span = mesh->spans[x+y*mesh->width];
102  while (span)
103  {
104  fwrite(span, sizeof(rcSpan), 1, file);
105  span = span->next;
106  }
107  }
108  }
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:276
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:281
Definition: Recast.h:256
float bmax[3]
The maximum bounds in world space. [(x, y, z)].
Definition: Recast.h:279
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:280
G3D::int16 y
Definition: Vector2int16.h:38
rcSpan * next
The next span higher up in column.
Definition: Recast.h:261
float bmin[3]
The minimum bounds in world space. [(x, y, z)].
Definition: Recast.h:278
G3D::int16 x
Definition: Vector2int16.h:37
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:277
rcSpan ** spans
Heightfield of spans (width*height).
Definition: Recast.h:282
void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcCompactHeightfield chf 
)
111  {
112  if (!file | !chf)
113  return;
114 
115  fwrite(&(chf->width), sizeof(chf->width), 1, file);
116  fwrite(&(chf->height), sizeof(chf->height), 1, file);
117  fwrite(&(chf->spanCount), sizeof(chf->spanCount), 1, file);
118 
119  fwrite(&(chf->walkableHeight), sizeof(chf->walkableHeight), 1, file);
120  fwrite(&(chf->walkableClimb), sizeof(chf->walkableClimb), 1, file);
121 
122  fwrite(&(chf->maxDistance), sizeof(chf->maxDistance), 1, file);
123  fwrite(&(chf->maxRegions), sizeof(chf->maxRegions), 1, file);
124 
125  fwrite(chf->bmin, sizeof(chf->bmin), 1, file);
126  fwrite(chf->bmax, sizeof(chf->bmax), 1, file);
127 
128  fwrite(&(chf->cs), sizeof(chf->cs), 1, file);
129  fwrite(&(chf->ch), sizeof(chf->ch), 1, file);
130 
131  int tmp = 0;
132  if (chf->cells) tmp |= 1;
133  if (chf->spans) tmp |= 2;
134  if (chf->dist) tmp |= 4;
135  if (chf->areas) tmp |= 8;
136 
137  fwrite(&tmp, sizeof(tmp), 1, file);
138 
139  if (chf->cells)
140  fwrite(chf->cells, sizeof(rcCompactCell), chf->width*chf->height, file);
141  if (chf->spans)
142  fwrite(chf->spans, sizeof(rcCompactSpan), chf->spanCount, file);
143  if (chf->dist)
144  fwrite(chf->dist, sizeof(unsigned short), chf->spanCount, file);
145  if (chf->areas)
146  fwrite(chf->areas, sizeof(unsigned char), chf->spanCount, file);
147  }
int height
The height of the heightfield. (Along the z-axis in cell units.)
Definition: Recast.h:308
unsigned short maxRegions
The maximum region id of any span within the field.
Definition: Recast.h:314
Represents a span of unobstructed space within a compact heightfield.
Definition: Recast.h:295
unsigned short * dist
Array containing border distance data. [Size: spanCount].
Definition: Recast.h:321
rcCompactCell * cells
Array of cells. [Size: width*height].
Definition: Recast.h:319
rcCompactSpan * spans
Array of spans. [Size: spanCount].
Definition: Recast.h:320
Provides information on the content of a cell column in a compact heightfield.
Definition: Recast.h:288
unsigned char * areas
Array containing area id data. [Size: spanCount].
Definition: Recast.h:322
float bmax[3]
The maximum bounds in world space. [(x, y, z)].
Definition: Recast.h:316
int width
The width of the heightfield. (Along the x-axis in cell units.)
Definition: Recast.h:307
int spanCount
The number of spans in the heightfield.
Definition: Recast.h:309
int walkableHeight
The walkable height used during the build of the field. (See: rcConfig::walkableHeight) ...
Definition: Recast.h:310
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:317
unsigned short maxDistance
The maximum distance value of any span within the field.
Definition: Recast.h:313
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:318
int walkableClimb
The walkable climb used during the build of the field. (See: rcConfig::walkableClimb) ...
Definition: Recast.h:311
float bmin[3]
The minimum bounds in world space. [(x, y, z)].
Definition: Recast.h:315
void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcContourSet cs 
)
150  {
151  if (!file || !cs)
152  return;
153 
154  fwrite(&(cs->cs), sizeof(float), 1, file);
155  fwrite(&(cs->ch), sizeof(float), 1, file);
156  fwrite(cs->bmin, sizeof(float), 3, file);
157  fwrite(cs->bmax, sizeof(float), 3, file);
158  fwrite(&(cs->nconts), sizeof(int), 1, file);
159  for (int i = 0; i < cs->nconts; ++i)
160  {
161  fwrite(&cs->conts[i].area, sizeof(unsigned char), 1, file);
162  fwrite(&cs->conts[i].reg, sizeof(unsigned short), 1, file);
163  fwrite(&cs->conts[i].nverts, sizeof(int), 1, file);
164  fwrite(cs->conts[i].verts, sizeof(int), cs->conts[i].nverts*4, file);
165  fwrite(&cs->conts[i].nrverts, sizeof(int), 1, file);
166  fwrite(cs->conts[i].rverts, sizeof(int), cs->conts[i].nrverts*4, file);
167  }
168  }
float bmin[3]
The minimum bounds in world space. [(x, y, z)].
Definition: Recast.h:372
int nrverts
The number of vertices in the raw contour.
Definition: Recast.h:361
int nverts
The number of vertices in the simplified contour.
Definition: Recast.h:359
int * rverts
Raw contour vertex and connection data. [Size: 4 * nrverts].
Definition: Recast.h:360
rcContour * conts
An array of the contours in the set. [Size: nconts].
Definition: Recast.h:370
int nconts
The number of contours in the set.
Definition: Recast.h:371
int * verts
Simplified contour vertex and connection data. [Size: 4 * nverts].
Definition: Recast.h:358
unsigned char area
The area id of the contour.
Definition: Recast.h:363
float bmax[3]
The maximum bounds in world space. [(x, y, z)].
Definition: Recast.h:373
unsigned short reg
The region id of the contour.
Definition: Recast.h:362
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:374
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:375
void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcPolyMesh mesh 
)
171  {
172  if (!file || !mesh)
173  return;
174 
175  fwrite(&(mesh->cs), sizeof(float), 1, file);
176  fwrite(&(mesh->ch), sizeof(float), 1, file);
177  fwrite(&(mesh->nvp), sizeof(int), 1, file);
178  fwrite(mesh->bmin, sizeof(float), 3, file);
179  fwrite(mesh->bmax, sizeof(float), 3, file);
180  fwrite(&(mesh->nverts), sizeof(int), 1, file);
181  fwrite(mesh->verts, sizeof(unsigned short), mesh->nverts*3, file);
182  fwrite(&(mesh->npolys), sizeof(int), 1, file);
183  fwrite(mesh->polys, sizeof(unsigned short), mesh->npolys*mesh->nvp*2, file);
184  fwrite(mesh->flags, sizeof(unsigned short), mesh->npolys, file);
185  fwrite(mesh->areas, sizeof(unsigned char), mesh->npolys, file);
186  fwrite(mesh->regs, sizeof(unsigned short), mesh->npolys, file);
187  }
unsigned char * areas
The area id assigned to each polygon. [Length: maxpolys].
Definition: Recast.h:389
int nverts
The number of vertices.
Definition: Recast.h:390
unsigned short * verts
The mesh vertices. [Form: (x, y, z) * nverts].
Definition: Recast.h:385
float ch
The height of each cell. (The minimum increment along the y-axis.)
Definition: Recast.h:397
float bmax[3]
The maximum bounds in world space. [(x, y, z)].
Definition: Recast.h:395
float cs
The size of each cell. (On the xz-plane.)
Definition: Recast.h:396
unsigned short * flags
The user defined flags for each polygon. [Length: maxpolys].
Definition: Recast.h:388
int npolys
The number of polygons.
Definition: Recast.h:391
unsigned short * regs
The region id assigned to each polygon. [Length: maxpolys].
Definition: Recast.h:387
float bmin[3]
The minimum bounds in world space. [(x, y, z)].
Definition: Recast.h:394
int nvp
The maximum number of vertices per polygon.
Definition: Recast.h:393
unsigned short * polys
Polygon and neighbor data. [Length: maxpolys * 2 * nvp].
Definition: Recast.h:386
void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcPolyMeshDetail mesh 
)
190  {
191  if (!file || !mesh)
192  return;
193 
194  fwrite(&(mesh->nverts), sizeof(int), 1, file);
195  fwrite(mesh->verts, sizeof(float), mesh->nverts*3, file);
196  fwrite(&(mesh->ntris), sizeof(int), 1, file);
197  fwrite(mesh->tris, sizeof(char), mesh->ntris*4, file);
198  fwrite(&(mesh->nmeshes), sizeof(int), 1, file);
199  fwrite(mesh->meshes, sizeof(int), mesh->nmeshes*4, file);
200  }
int ntris
The number of triangles in tris.
Definition: Recast.h:411
float * verts
The mesh vertices. [Size: 3*nverts].
Definition: Recast.h:407
int nmeshes
The number of sub-meshes defined by meshes.
Definition: Recast.h:409
unsigned char * tris
The mesh triangles. [Size: 4*ntris].
Definition: Recast.h:408
unsigned int * meshes
The sub-mesh data. [Size: 4*nmeshes].
Definition: Recast.h:406
int nverts
The number of vertices in verts.
Definition: Recast.h:410
void MMAP::IntermediateValues::generateObjFile ( uint32  mapID,
uint32  tileX,
uint32  tileY,
MeshData meshData 
)
203  {
204  char objFileName[255];
205  sprintf(objFileName, "meshes/map%03u%02u%02u.obj", mapID, tileY, tileX);
206 
207  FILE* objFile = fopen(objFileName, "wb");
208  if (!objFile)
209  {
210  char message[1024];
211  sprintf(message, "Failed to open %s for writing!\n", objFileName);
212  perror(message);
213  return;
214  }
215 
216  G3D::Array<float> allVerts;
217  G3D::Array<int> allTris;
218 
219  allTris.append(meshData.liquidTris);
220  allVerts.append(meshData.liquidVerts);
221  TerrainBuilder::copyIndices(meshData.solidTris, allTris, allVerts.size() / 3);
222  allVerts.append(meshData.solidVerts);
223 
224  float* verts = allVerts.getCArray();
225  int vertCount = allVerts.size() / 3;
226  int* tris = allTris.getCArray();
227  int triCount = allTris.size() / 3;
228 
229  for (int i = 0; i < allVerts.size() / 3; i++)
230  fprintf(objFile, "v %f %f %f\n", verts[i*3], verts[i*3 + 1], verts[i*3 + 2]);
231 
232  for (int i = 0; i < allTris.size() / 3; i++)
233  fprintf(objFile, "f %i %i %i\n", tris[i*3] + 1, tris[i*3 + 1] + 1, tris[i*3 + 2] + 1);
234 
235  fclose(objFile);
236 
237 
238  char tileString[25];
239  sprintf(tileString, "[%02u,%02u]: ", tileY, tileX);
240  printf("%sWriting debug output... \r", tileString);
241 
242  sprintf(objFileName, "meshes/%03u.map", mapID);
243 
244  objFile = fopen(objFileName, "wb");
245  if (!objFile)
246  {
247  char message[1024];
248  sprintf(message, "Failed to open %s for writing!\n", objFileName);
249  perror(message);
250  return;
251  }
252 
253  char b = '\0';
254  fwrite(&b, sizeof(char), 1, objFile);
255  fclose(objFile);
256 
257  sprintf(objFileName, "meshes/%03u%02u%02u.mesh", mapID, tileY, tileX);
258  objFile = fopen(objFileName, "wb");
259  if (!objFile)
260  {
261  char message[1024];
262  sprintf(message, "Failed to open %s for writing!\n", objFileName);
263  perror(message);
264  return;
265  }
266 
267  fwrite(&vertCount, sizeof(int), 1, objFile);
268  fwrite(verts, sizeof(float), vertCount*3, objFile);
269  fflush(objFile);
270 
271  fwrite(&triCount, sizeof(int), 1, objFile);
272  fwrite(tris, sizeof(int), triCount*3, objFile);
273  fflush(objFile);
274 
275  fclose(objFile);
276  }
FMT_API int fprintf(std::FILE *f, CStringRef format, ArgList args)
T * getCArray()
Definition: Array.h:256
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
int size() const
Definition: Array.h:430
void append(const T &value)
Definition: Array.h:583
static void copyIndices(std::vector< VMAP::MeshTriangle > &source, G3D::Array< int > &dest, int offest, bool flip)
Definition: TerrainBuilder.cpp:807
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083

+ Here is the call graph for this function:

void MMAP::IntermediateValues::writeIV ( uint32  mapID,
uint32  tileX,
uint32  tileY 
)
33  {
34  char fileName[255];
35  char tileString[25];
36  sprintf(tileString, "[%02u,%02u]: ", tileX, tileY);
37 
38  printf("%sWriting debug output... \r", tileString);
39 
40  std::string name("meshes/%03u%02i%02i.");
41 
42 #define DEBUG_WRITE(fileExtension,data) \
43  do { \
44  sprintf(fileName, (name + fileExtension).c_str(), mapID, tileY, tileX); \
45  FILE* file = fopen(fileName, "wb"); \
46  if (!file) \
47  { \
48  char message[1024]; \
49  sprintf(message, "%sFailed to open %s for writing!\n", tileString, fileName); \
50  perror(message); \
51  } \
52  else \
53  debugWrite(file, data); \
54  if (file) fclose(file); \
55  printf("%sWriting debug output... \r", tileString); \
56  } while (false)
57 
58  if (heightfield)
59  DEBUG_WRITE("hf", heightfield);
62  if (contours)
63  DEBUG_WRITE("cs", contours);
64  if (polyMesh)
65  DEBUG_WRITE("pmesh", polyMesh);
66  if (polyMeshDetail)
67  DEBUG_WRITE("dmesh", polyMeshDetail);
68 
69 #undef DEBUG_WRITE
70  }
rcPolyMesh * polyMesh
Definition: IntermediateValues.h:35
rcPolyMeshDetail * polyMeshDetail
Definition: IntermediateValues.h:36
rcContourSet * contours
Definition: IntermediateValues.h:34
#define DEBUG_WRITE(fileExtension, data)
std::string sprintf(CStringRef format, ArgList args)
Definition: format.h:3096
rcCompactHeightfield * compactHeightfield
Definition: IntermediateValues.h:33
rcHeightfield * heightfield
Definition: IntermediateValues.h:32
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: format.h:3083

+ Here is the call graph for this function:

Member Data Documentation

rcCompactHeightfield* MMAP::IntermediateValues::compactHeightfield
rcContourSet* MMAP::IntermediateValues::contours
rcHeightfield* MMAP::IntermediateValues::heightfield
rcPolyMesh* MMAP::IntermediateValues::polyMesh
rcPolyMeshDetail* MMAP::IntermediateValues::polyMeshDetail

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