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 (const std::string &dataPath, 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 (const std::string &dataPath, 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
35{}

◆ ~IntermediateValues()

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

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

Member Function Documentation

◆ debugWrite() [1/5]

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

◆ debugWrite() [2/5]

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

◆ debugWrite() [3/5]

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

◆ debugWrite() [4/5]

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

◆ debugWrite() [5/5]

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

◆ generateObjFile()

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

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

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

◆ writeIV()

void MMAP::IntermediateValues::writeIV ( const std::string &  dataPath,
uint32  mapID,
uint32  tileX,
uint32  tileY 
)
34 {
35 char fileName[512];
36 char tileString[25];
37 sprintf(tileString, "[%02u,%02u]: ", tileX, tileY);
38
39 printf("%sWriting debug output... \r", tileString);
40
41 std::string name(dataPath+"/meshes/%03u%02i%02i.");
42
43#define DEBUG_WRITE(fileExtension,data) \
44 do { \
45 sprintf(fileName, (name + fileExtension).c_str(), mapID, tileY, tileX); \
46 FILE* file = fopen(fileName, "wb"); \
47 if (!file) \
48 { \
49 char message[1024]; \
50 sprintf(message, "%sFailed to open %s for writing!\n", tileString, fileName); \
51 perror(message); \
52 } \
53 else \
54 debugWrite(file, data); \
55 if (file) fclose(file); \
56 printf("%sWriting debug output... \r", tileString); \
57 } while (false)
58
59 if (heightfield)
63 if (contours)
64 DEBUG_WRITE("cs", contours);
65 if (polyMesh)
66 DEBUG_WRITE("pmesh", polyMesh);
69
70#undef DEBUG_WRITE
71 }
#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}
30{nullptr};

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

◆ contours

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

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

◆ heightfield

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

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

◆ polyMesh

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

◆ polyMeshDetail

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

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