AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
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

rcHeightfield * heightfield {nullptr}
 
rcCompactHeightfield * compactHeightfield {nullptr}
 
rcContourSet * contours {nullptr}
 
rcPolyMesh * polyMesh {nullptr}
 
rcPolyMeshDetail * polyMeshDetail {nullptr}
 

Detailed Description

Constructor & Destructor Documentation

◆ IntermediateValues()

MMAP::IntermediateValues::IntermediateValues ( )
inline
37{}

◆ ~IntermediateValues()

MMAP::IntermediateValues::~IntermediateValues ( )
23 {
24 rcFreeCompactHeightfield(compactHeightfield);
25 rcFreeHeightField(heightfield);
26 rcFreeContourSet(contours);
27 rcFreePolyMesh(polyMesh);
28 rcFreePolyMeshDetail(polyMeshDetail);
29 }
rcCompactHeightfield * compactHeightfield
Definition: IntermediateValues.h:32
rcHeightfield * heightfield
Definition: IntermediateValues.h:31
rcContourSet * contours
Definition: IntermediateValues.h:33
rcPolyMeshDetail * polyMeshDetail
Definition: IntermediateValues.h:35
rcPolyMesh * polyMesh
Definition: IntermediateValues.h:34

References compactHeightfield, contours, heightfield, polyMesh, and polyMeshDetail.

Member Function Documentation

◆ debugWrite() [1/5]

void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcCompactHeightfield *  chf 
)
110 {
111 if (!file | !chf)
112 return;
113
114 fwrite(&(chf->width), sizeof(chf->width), 1, file);
115 fwrite(&(chf->height), sizeof(chf->height), 1, file);
116 fwrite(&(chf->spanCount), sizeof(chf->spanCount), 1, file);
117
118 fwrite(&(chf->walkableHeight), sizeof(chf->walkableHeight), 1, file);
119 fwrite(&(chf->walkableClimb), sizeof(chf->walkableClimb), 1, file);
120
121 fwrite(&(chf->maxDistance), sizeof(chf->maxDistance), 1, file);
122 fwrite(&(chf->maxRegions), sizeof(chf->maxRegions), 1, file);
123
124 fwrite(chf->bmin, sizeof(chf->bmin), 1, file);
125 fwrite(chf->bmax, sizeof(chf->bmax), 1, file);
126
127 fwrite(&(chf->cs), sizeof(chf->cs), 1, file);
128 fwrite(&(chf->ch), sizeof(chf->ch), 1, file);
129
130 int tmp = 0;
131 if (chf->cells) tmp |= 1;
132 if (chf->spans) tmp |= 2;
133 if (chf->dist) tmp |= 4;
134 if (chf->areas) tmp |= 8;
135
136 fwrite(&tmp, sizeof(tmp), 1, file);
137
138 if (chf->cells)
139 fwrite(chf->cells, sizeof(rcCompactCell), chf->width * chf->height, file);
140 if (chf->spans)
141 fwrite(chf->spans, sizeof(rcCompactSpan), chf->spanCount, file);
142 if (chf->dist)
143 fwrite(chf->dist, sizeof(unsigned short), chf->spanCount, file);
144 if (chf->areas)
145 fwrite(chf->areas, sizeof(unsigned char), chf->spanCount, file);
146 }

◆ debugWrite() [2/5]

void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcContourSet *  cs 
)
149 {
150 if (!file || !cs)
151 return;
152
153 fwrite(&(cs->cs), sizeof(float), 1, file);
154 fwrite(&(cs->ch), sizeof(float), 1, file);
155 fwrite(cs->bmin, sizeof(float), 3, file);
156 fwrite(cs->bmax, sizeof(float), 3, file);
157 fwrite(&(cs->nconts), sizeof(int), 1, file);
158 for (int i = 0; i < cs->nconts; ++i)
159 {
160 fwrite(&cs->conts[i].area, sizeof(unsigned char), 1, file);
161 fwrite(&cs->conts[i].reg, sizeof(unsigned short), 1, file);
162 fwrite(&cs->conts[i].nverts, sizeof(int), 1, file);
163 fwrite(cs->conts[i].verts, sizeof(int), cs->conts[i].nverts * 4, file);
164 fwrite(&cs->conts[i].nrverts, sizeof(int), 1, file);
165 fwrite(cs->conts[i].rverts, sizeof(int), cs->conts[i].nrverts * 4, file);
166 }
167 }

◆ debugWrite() [3/5]

void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcHeightfield *  mesh 
)
72 {
73 if (!file || !mesh)
74 return;
75
76 fwrite(&(mesh->cs), sizeof(float), 1, file);
77 fwrite(&(mesh->ch), sizeof(float), 1, file);
78 fwrite(&(mesh->width), sizeof(int), 1, file);
79 fwrite(&(mesh->height), sizeof(int), 1, file);
80 fwrite(mesh->bmin, sizeof(float), 3, file);
81 fwrite(mesh->bmax, sizeof(float), 3, file);
82
83 for (int y = 0; y < mesh->height; ++y)
84 for (int x = 0; x < mesh->width; ++x)
85 {
86 rcSpan* span = mesh->spans[x + y * mesh->width];
87
88 // first, count the number of spans
89 int spanCount = 0;
90 while (span)
91 {
92 spanCount++;
93 span = span->next;
94 }
95
96 // write the span count
97 fwrite(&spanCount, sizeof(int), 1, file);
98
99 // write the spans
100 span = mesh->spans[x + y * mesh->width];
101 while (span)
102 {
103 fwrite(span, sizeof(rcSpan), 1, file);
104 span = span->next;
105 }
106 }
107 }

◆ debugWrite() [4/5]

void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcPolyMesh *  mesh 
)
170 {
171 if (!file || !mesh)
172 return;
173
174 fwrite(&(mesh->cs), sizeof(float), 1, file);
175 fwrite(&(mesh->ch), sizeof(float), 1, file);
176 fwrite(&(mesh->nvp), sizeof(int), 1, file);
177 fwrite(mesh->bmin, sizeof(float), 3, file);
178 fwrite(mesh->bmax, sizeof(float), 3, file);
179 fwrite(&(mesh->nverts), sizeof(int), 1, file);
180 fwrite(mesh->verts, sizeof(unsigned short), mesh->nverts * 3, file);
181 fwrite(&(mesh->npolys), sizeof(int), 1, file);
182 fwrite(mesh->polys, sizeof(unsigned short), mesh->npolys * mesh->nvp * 2, file);
183 fwrite(mesh->flags, sizeof(unsigned short), mesh->npolys, file);
184 fwrite(mesh->areas, sizeof(unsigned char), mesh->npolys, file);
185 fwrite(mesh->regs, sizeof(unsigned short), mesh->npolys, file);
186 }

◆ debugWrite() [5/5]

void MMAP::IntermediateValues::debugWrite ( FILE *  file,
const rcPolyMeshDetail *  mesh 
)
189 {
190 if (!file || !mesh)
191 return;
192
193 fwrite(&(mesh->nverts), sizeof(int), 1, file);
194 fwrite(mesh->verts, sizeof(float), mesh->nverts * 3, file);
195 fwrite(&(mesh->ntris), sizeof(int), 1, file);
196 fwrite(mesh->tris, sizeof(char), mesh->ntris * 4, file);
197 fwrite(&(mesh->nmeshes), sizeof(int), 1, file);
198 fwrite(mesh->meshes, sizeof(int), mesh->nmeshes * 4, file);
199 }

◆ generateObjFile()

void MMAP::IntermediateValues::generateObjFile ( uint32  mapID,
uint32  tileX,
uint32  tileY,
MeshData meshData 
)
202 {
203 char objFileName[255];
204 sprintf(objFileName, "meshes/map%03u%02u%02u.obj", mapID, tileY, tileX);
205
206 FILE* objFile = fopen(objFileName, "wb");
207 if (!objFile)
208 {
209 char message[1024];
210 sprintf(message, "Failed to open %s for writing!\n", objFileName);
211 perror(message);
212 return;
213 }
214
215 G3D::Array<float> allVerts;
216 G3D::Array<int> allTris;
217
218 allTris.append(meshData.liquidTris);
219 allVerts.append(meshData.liquidVerts);
220 TerrainBuilder::copyIndices(meshData.solidTris, allTris, allVerts.size() / 3);
221 allVerts.append(meshData.solidVerts);
222
223 float* verts = allVerts.getCArray();
224 int vertCount = allVerts.size() / 3;
225 int* tris = allTris.getCArray();
226 int triCount = allTris.size() / 3;
227
228 for (int i = 0; i < allVerts.size() / 3; i++)
229 fprintf(objFile, "v %f %f %f\n", verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2]);
230
231 for (int i = 0; i < allTris.size() / 3; i++)
232 fprintf(objFile, "f %i %i %i\n", tris[i * 3] + 1, tris[i * 3 + 1] + 1, tris[i * 3 + 2] + 1);
233
234 fclose(objFile);
235
236 char tileString[25];
237 sprintf(tileString, "[%02u,%02u]: ", tileY, tileX);
238 printf("%sWriting debug output... \r", tileString);
239
240 sprintf(objFileName, "meshes/%03u.map", mapID);
241
242 objFile = fopen(objFileName, "wb");
243 if (!objFile)
244 {
245 char message[1024];
246 sprintf(message, "Failed to open %s for writing!\n", objFileName);
247 perror(message);
248 return;
249 }
250
251 char b = '\0';
252 fwrite(&b, sizeof(char), 1, objFile);
253 fclose(objFile);
254
255 sprintf(objFileName, "meshes/%03u%02u%02u.mesh", mapID, tileY, tileX);
256 objFile = fopen(objFileName, "wb");
257 if (!objFile)
258 {
259 char message[1024];
260 sprintf(message, "Failed to open %s for writing!\n", objFileName);
261 perror(message);
262 return;
263 }
264
265 fwrite(&vertCount, sizeof(int), 1, objFile);
266 fwrite(verts, sizeof(float), vertCount * 3, objFile);
267 fflush(objFile);
268
269 fwrite(&triCount, sizeof(int), 1, objFile);
270 fwrite(tris, sizeof(int), triCount * 3, objFile);
271 fflush(objFile);
272
273 fclose(objFile);
274 }
static void copyIndices(std::vector< VMAP::MeshTriangle > &source, G3D::Array< int > &dest, int offest, bool flip)
Definition: TerrainBuilder.cpp:850

References MMAP::TerrainBuilder::copyIndices(), MMAP::MeshData::liquidTris, MMAP::MeshData::liquidVerts, MMAP::MeshData::solidTris, and MMAP::MeshData::solidVerts.

Referenced by MMAP::TileBuilder::buildMoveMapTile().

◆ writeIV()

void MMAP::IntermediateValues::writeIV ( uint32  mapID,
uint32  tileX,
uint32  tileY 
)
32 {
33 char fileName[255];
34 char tileString[25];
35 sprintf(tileString, "[%02u,%02u]: ", tileX, tileY);
36
37 printf("%sWriting debug output... \r", tileString);
38
39 std::string name("meshes/%03u%02i%02i.");
40
41#define DEBUG_WRITE(fileExtension,data) \
42 do { \
43 sprintf(fileName, (name + fileExtension).c_str(), mapID, tileY, tileX); \
44 FILE* file = fopen(fileName, "wb"); \
45 if (!file) \
46 { \
47 char message[1024]; \
48 sprintf(message, "%sFailed to open %s for writing!\n", tileString, fileName); \
49 perror(message); \
50 } \
51 else \
52 debugWrite(file, data); \
53 if (file) fclose(file); \
54 printf("%sWriting debug output... \r", tileString); \
55 } while (false)
56
57 if (heightfield)
61 if (contours)
62 DEBUG_WRITE("cs", contours);
63 if (polyMesh)
64 DEBUG_WRITE("pmesh", polyMesh);
67
68#undef DEBUG_WRITE
69 }
#define DEBUG_WRITE(fileExtension, data)

References compactHeightfield, contours, DEBUG_WRITE, heightfield, polyMesh, and polyMeshDetail.

Referenced by MMAP::TileBuilder::buildMoveMapTile().

Member Data Documentation

◆ compactHeightfield

rcCompactHeightfield* MMAP::IntermediateValues::compactHeightfield {nullptr}

Referenced by writeIV(), and ~IntermediateValues().

◆ contours

rcContourSet* MMAP::IntermediateValues::contours {nullptr}

Referenced by writeIV(), and ~IntermediateValues().

◆ heightfield

rcHeightfield* MMAP::IntermediateValues::heightfield {nullptr}

Referenced by writeIV(), and ~IntermediateValues().

◆ polyMesh

rcPolyMesh* MMAP::IntermediateValues::polyMesh {nullptr}

◆ polyMeshDetail

rcPolyMeshDetail* MMAP::IntermediateValues::polyMeshDetail {nullptr}