1 | /* ==========================================================================
|
---|
2 | * (C) 2005 Universitat Jaume I
|
---|
3 | * ==========================================================================
|
---|
4 | * PROYECT: GAME TOOLS
|
---|
5 | * ==========================================================================*/
|
---|
6 | /** CONTENT:
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * @file GeoLodStripsLibrary.cpp
|
---|
10 | /*===========================================================================*/
|
---|
11 |
|
---|
12 | #include "GeoLodStripsLibrary.h"
|
---|
13 |
|
---|
14 | using namespace Geometry;
|
---|
15 |
|
---|
16 | //-----------------------------------------------------------------------------
|
---|
17 | // Constructors.
|
---|
18 | //-----------------------------------------------------------------------------
|
---|
19 | LodStripsLibrary::LodStripsLibrary( std::string name,
|
---|
20 | Mesh *geomesh)
|
---|
21 | {
|
---|
22 | const char *name_of_file;
|
---|
23 |
|
---|
24 | // Sets the current lod.
|
---|
25 | mCurrentLod = 0;
|
---|
26 |
|
---|
27 | // Converts a String to const char *.
|
---|
28 | name_of_file = name.data();
|
---|
29 |
|
---|
30 | // Sets the global mesh.
|
---|
31 | mGeoMesh = geomesh;
|
---|
32 |
|
---|
33 | // Loads the Level Of Detail file.
|
---|
34 | LodStripsLibrary::LoadStripMesh((char*)name_of_file,mGeoMesh);
|
---|
35 | }
|
---|
36 |
|
---|
37 | //-----------------------------------------------------------------------------
|
---|
38 | // Destroyer.
|
---|
39 | //-----------------------------------------------------------------------------
|
---|
40 | LodStripsLibrary::~LodStripsLibrary()
|
---|
41 | {
|
---|
42 | delete[] mStrips;
|
---|
43 | }
|
---|
44 |
|
---|
45 | //-----------------------------------------------------------------------------
|
---|
46 | // Public.
|
---|
47 | //-----------------------------------------------------------------------------
|
---|
48 |
|
---|
49 | /*
|
---|
50 | Go to the level of detail.
|
---|
51 | */
|
---|
52 | uint32 LodStripsLibrary::GoToLod(uint32 newLOD)
|
---|
53 | {
|
---|
54 | register int j;
|
---|
55 | register int offset;
|
---|
56 | long int i;
|
---|
57 | long int k;
|
---|
58 | long int b_change_ok = 1;
|
---|
59 | unsigned long int lod;
|
---|
60 | long int t;
|
---|
61 | long int r;
|
---|
62 | long int sig;
|
---|
63 | long int el1;
|
---|
64 | long int el2;
|
---|
65 | long int total_changes;
|
---|
66 | long int totalR;
|
---|
67 | SmallIntVector *strip;
|
---|
68 | SmallIntVector::iterator start;
|
---|
69 | uint32 return_value;
|
---|
70 |
|
---|
71 | // Initialize the return value to the current LOD.
|
---|
72 | return_value = mCurrentLod;
|
---|
73 |
|
---|
74 | if (newLOD != mCurrentLod)
|
---|
75 | {
|
---|
76 | if (newLOD > mCurrentLod)
|
---|
77 | {
|
---|
78 | //HACIA ADELANTE
|
---|
79 | //CurrentRegLOD
|
---|
80 | //Incrementamos el LOD -> Calcular siguientes
|
---|
81 | for (lod = mCurrentLod; lod < newLOD; lod++)
|
---|
82 | {
|
---|
83 | sig = mVertex[lod];
|
---|
84 | total_changes = mPChanges[lod];
|
---|
85 |
|
---|
86 | for (i = 0; i < total_changes; i++)
|
---|
87 | {
|
---|
88 | // Strip q Cambia.
|
---|
89 | t = mCurrentRegLOD->strip;
|
---|
90 | strip = &(mStrips[t]);
|
---|
91 | start = strip->begin();
|
---|
92 |
|
---|
93 | // Position.
|
---|
94 | totalR = mCurrentRegLOD->position;
|
---|
95 |
|
---|
96 | for (j = totalR - 1; j >= 0; j--)
|
---|
97 | {
|
---|
98 | start[*mCurrentData] = sig;
|
---|
99 |
|
---|
100 | ++mCurrentData;
|
---|
101 | }
|
---|
102 |
|
---|
103 | // L1.
|
---|
104 | totalR = mCurrentRegLOD->vertexRepetition;
|
---|
105 |
|
---|
106 | for (j = totalR - 1; j >= 0; j--)
|
---|
107 | {
|
---|
108 | offset = *mCurrentData + 1;
|
---|
109 |
|
---|
110 | strip->erase( start + offset,
|
---|
111 | start
|
---|
112 | +
|
---|
113 | offset
|
---|
114 | +
|
---|
115 | (*(mCurrentData + 1)));
|
---|
116 |
|
---|
117 | ++mCurrentData;
|
---|
118 | ++mCurrentData;
|
---|
119 | }
|
---|
120 |
|
---|
121 | // L2
|
---|
122 | totalR = mCurrentRegLOD->edgeRepetition;
|
---|
123 |
|
---|
124 | for (j = totalR - 1; j >= 0; j--)
|
---|
125 | {
|
---|
126 | offset = *mCurrentData + 2;
|
---|
127 | strip->erase( start + offset,
|
---|
128 | start
|
---|
129 | +
|
---|
130 | offset
|
---|
131 | +
|
---|
132 | 2*(*(mCurrentData + 1)));
|
---|
133 |
|
---|
134 | ++mCurrentData;
|
---|
135 | ++mCurrentData;
|
---|
136 | }
|
---|
137 |
|
---|
138 | ++mCurrentRegLOD;
|
---|
139 |
|
---|
140 | mStripsChanges[t] = 1;
|
---|
141 |
|
---|
142 | }
|
---|
143 |
|
---|
144 | mCurrentLod = lod + 1;
|
---|
145 | }
|
---|
146 |
|
---|
147 | }
|
---|
148 | // Si el nuevo LOD es menos que el actual.
|
---|
149 | else
|
---|
150 | {
|
---|
151 | --mCurrentRegLOD;
|
---|
152 | --mCurrentData;
|
---|
153 |
|
---|
154 | // Decrementamos el LOD -> Calcular anteriores.
|
---|
155 | for (lod = mCurrentLod; lod > newLOD; lod--)
|
---|
156 | {
|
---|
157 | total_changes = mPChanges[lod - 1];
|
---|
158 |
|
---|
159 | for (i = 0; i < total_changes; i++)
|
---|
160 | {
|
---|
161 | t = mCurrentRegLOD->strip;
|
---|
162 | strip = &(mStrips[t]);
|
---|
163 | start = mStrips[t].begin();
|
---|
164 |
|
---|
165 | // L2.
|
---|
166 | totalR = mCurrentRegLOD->edgeRepetition;
|
---|
167 |
|
---|
168 | for (j = 0; j < totalR; j++)
|
---|
169 | {
|
---|
170 | el1 = (*strip)[*(mCurrentData - 1)];
|
---|
171 | el2 = (*strip)[*(mCurrentData - 1) + 1];
|
---|
172 | r = *(mCurrentData);
|
---|
173 |
|
---|
174 | for (k = 0; k < r; k++)
|
---|
175 | {
|
---|
176 | (*strip).insert(start+*(mCurrentData - 1),el2);
|
---|
177 | (*strip).insert(start+*(mCurrentData - 1),el1);
|
---|
178 | }
|
---|
179 |
|
---|
180 | --mCurrentData;
|
---|
181 | --mCurrentData;
|
---|
182 | }
|
---|
183 |
|
---|
184 | // Vertex Repetition.
|
---|
185 | totalR = mCurrentRegLOD->vertexRepetition;
|
---|
186 |
|
---|
187 | for (j = 0; j < totalR; j++)
|
---|
188 | {
|
---|
189 | el1 = (*strip)[*(mCurrentData-1)];
|
---|
190 | r = *(mCurrentData);
|
---|
191 |
|
---|
192 | for (k = 0; k < r; k++)
|
---|
193 | {
|
---|
194 | (*strip).insert(start+*(mCurrentData-1),el1);
|
---|
195 | }
|
---|
196 |
|
---|
197 | --mCurrentData;
|
---|
198 | --mCurrentData;
|
---|
199 | }
|
---|
200 |
|
---|
201 | // POS.
|
---|
202 | totalR = mCurrentRegLOD->position;
|
---|
203 |
|
---|
204 | for (j = 0; j < totalR; j++)
|
---|
205 | {
|
---|
206 | (*strip)[*mCurrentData] = lod - 1;
|
---|
207 | --mCurrentData;
|
---|
208 | }
|
---|
209 |
|
---|
210 | --mCurrentRegLOD;
|
---|
211 | mStripsChanges[t] = 1;
|
---|
212 | }
|
---|
213 |
|
---|
214 | // Actualizar LOD.
|
---|
215 | mCurrentLod = lod - 1;
|
---|
216 | }
|
---|
217 |
|
---|
218 | ++mCurrentData;
|
---|
219 | ++mCurrentRegLOD;
|
---|
220 | }
|
---|
221 |
|
---|
222 | }
|
---|
223 |
|
---|
224 | /*
|
---|
225 | // Visualizar.
|
---|
226 | k = 0;
|
---|
227 |
|
---|
228 | for (uint32 i = 0; i < mTotalStrips; i++)
|
---|
229 | {
|
---|
230 | l = mStrips[i].size();
|
---|
231 |
|
---|
232 | // Los dos degenerados.
|
---|
233 | k = k + l + 2;
|
---|
234 |
|
---|
235 | // If is not the first strip.
|
---|
236 | if (i != 0)
|
---|
237 | {
|
---|
238 | start = mStrips[i].begin();
|
---|
239 |
|
---|
240 | // Degenerado.
|
---|
241 | mStrips[i].insert(start,mStrips[i][0]);
|
---|
242 | }
|
---|
243 |
|
---|
244 | // If is not the last strip.
|
---|
245 | if (i != (mTotalStrips - 1))
|
---|
246 | {
|
---|
247 | // Degenerado.
|
---|
248 | mStrips[i].push_back(mStrips[i][mStrips[i].size() - 1]);
|
---|
249 | }
|
---|
250 |
|
---|
251 | }
|
---|
252 | */
|
---|
253 |
|
---|
254 | /*
|
---|
255 | * Write in the hardware buffer.
|
---|
256 | *
|
---|
257 | int contTira = 0;
|
---|
258 |
|
---|
259 | // Vuelca los datos en el buffer de pantalla.
|
---|
260 | //Ogre::HardwareIndexBufferSharedPtr ibuf;
|
---|
261 | for(unsigned int j = 0; j < mGeoMesh->mSubMeshCount; j++)
|
---|
262 | {
|
---|
263 | k = 0;
|
---|
264 | for(unsigned int s = 0; s < mGeoMesh->mSubMesh[j].mStripCount; s++)
|
---|
265 | {
|
---|
266 | l = mStrips[contTira].size();
|
---|
267 |
|
---|
268 | mIndexBuffer[j]->writeData(k*sizeof(unsigned long),
|
---|
269 | l*sizeof(unsigned long),
|
---|
270 | &mStrips[contTira][0]);
|
---|
271 |
|
---|
272 | k = k + l;
|
---|
273 |
|
---|
274 | contTira++;
|
---|
275 | }
|
---|
276 |
|
---|
277 | indexes[j]->indexCount = k;
|
---|
278 | }
|
---|
279 | */
|
---|
280 |
|
---|
281 | /*
|
---|
282 | // Para el bunny.
|
---|
283 | start = mStrips[0].begin();
|
---|
284 | mStrips[0].erase(start);
|
---|
285 | */
|
---|
286 | /*
|
---|
287 | for (uint32 i = 0; i < mTotalStrips; i++)
|
---|
288 | {
|
---|
289 | start = mStrips[i].begin();
|
---|
290 |
|
---|
291 | // If is not the first strip.
|
---|
292 | if (i != 0)
|
---|
293 | {
|
---|
294 | mStrips[i].erase(start);
|
---|
295 | }
|
---|
296 |
|
---|
297 | // If is not the last strip.
|
---|
298 | if (i != (mTotalStrips - 1))
|
---|
299 | {
|
---|
300 | mStrips[i].pop_back();
|
---|
301 | }
|
---|
302 |
|
---|
303 | }
|
---|
304 | */
|
---|
305 |
|
---|
306 | return return_value;
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | /*
|
---|
311 | Gets the maximum level of detail.
|
---|
312 | */
|
---|
313 | uint32 LodStripsLibrary::MaxLod()
|
---|
314 | {
|
---|
315 | return mMaxLod;
|
---|
316 | }
|
---|
317 |
|
---|
318 | /*
|
---|
319 | Gets the minimum level of detail.
|
---|
320 | */
|
---|
321 | uint32 LodStripsLibrary::MinLod()
|
---|
322 | {
|
---|
323 | return mMinLod;
|
---|
324 | }
|
---|
325 |
|
---|
326 | /// Returns the number of vertices of the highest LOD.
|
---|
327 | uint32 LodStripsLibrary::MaxVertices()
|
---|
328 | {
|
---|
329 | return mMaxVerticesLOD;
|
---|
330 | }
|
---|
331 |
|
---|
332 | /// Returns the number of vertices of the lowest LOD.
|
---|
333 | uint32 LodStripsLibrary::MinVertices()
|
---|
334 | {
|
---|
335 | uint32 number_of_vertices;
|
---|
336 |
|
---|
337 | // Total vertices less total lod.
|
---|
338 | number_of_vertices = mMaxVerticesLOD - (mMinLod + 1);
|
---|
339 |
|
---|
340 | return number_of_vertices;
|
---|
341 | }
|
---|
342 |
|
---|
343 | /// Returns the number of triangles of the highest LOD.
|
---|
344 | uint32 LodStripsLibrary::MaxFaces()
|
---|
345 | {
|
---|
346 | uint32 number_of_faces;
|
---|
347 |
|
---|
348 | uint32 current_lod;
|
---|
349 |
|
---|
350 | current_lod = GoToLod(MaxLod());
|
---|
351 |
|
---|
352 | // Initialize number of faces count.
|
---|
353 | number_of_faces = 0;
|
---|
354 |
|
---|
355 | // For each strip.
|
---|
356 | for (unsigned int strip = 0; strip < mTotalStrips; strip++)
|
---|
357 | {
|
---|
358 | number_of_faces += int(mStrips[strip].size() - 2);
|
---|
359 | }
|
---|
360 |
|
---|
361 | GoToLod(current_lod);
|
---|
362 |
|
---|
363 | return number_of_faces;
|
---|
364 | }
|
---|
365 |
|
---|
366 | /// Returns the number of triangles of the lowest LOD.
|
---|
367 | uint32 LodStripsLibrary::MinFaces()
|
---|
368 | {
|
---|
369 | uint32 current_lod;
|
---|
370 | uint32 number_of_faces;
|
---|
371 |
|
---|
372 | current_lod = GoToLod(MinLod());
|
---|
373 |
|
---|
374 | // Initialize number of faces count.
|
---|
375 | number_of_faces = 0;
|
---|
376 |
|
---|
377 | // For each strip.
|
---|
378 | for (unsigned int strip = 0; strip < mTotalStrips; strip++)
|
---|
379 | {
|
---|
380 | number_of_faces += int(mStrips[strip].size() - 2);
|
---|
381 | }
|
---|
382 |
|
---|
383 | GoToLod(current_lod);
|
---|
384 |
|
---|
385 | return number_of_faces;
|
---|
386 | }
|
---|
387 |
|
---|
388 | /// Establishes the new LOD range.
|
---|
389 | /// Only the LODs in that range are stored and used.
|
---|
390 | void LodStripsLibrary::TrimByLod(uint32 minLod, uint32 maxLod)
|
---|
391 | {
|
---|
392 | // Refresh number of vercies of the max lod.
|
---|
393 | mMaxVerticesLOD += mMaxLod - maxLod;
|
---|
394 |
|
---|
395 | mMinLod = minLod;
|
---|
396 | mMaxLod = maxLod;
|
---|
397 | }
|
---|
398 |
|
---|
399 | uint32 LodStripsLibrary::GetStripCount() const
|
---|
400 | {
|
---|
401 | return (uint32) mTotalStrips;
|
---|
402 | }
|
---|
403 |
|
---|
404 | uint32 LodStripsLibrary::GetIndexCountByStrip(uint32 istrip) const
|
---|
405 | {
|
---|
406 | return (uint32) mStrips[istrip].size();
|
---|
407 | }
|
---|
408 |
|
---|
409 | //-----------------------------------------------------------------------------
|
---|
410 | // Private.
|
---|
411 | //-----------------------------------------------------------------------------
|
---|
412 |
|
---|
413 | /*
|
---|
414 | Copy a STL vector to a C array.
|
---|
415 | */
|
---|
416 | void LodStripsLibrary::CopyVectors2Arrays()
|
---|
417 | {
|
---|
418 | unsigned int i;
|
---|
419 | unsigned int j;
|
---|
420 | SmallInt max;
|
---|
421 | SmallInt t;
|
---|
422 | SmallInt *data_array;
|
---|
423 | SmallIntVector tira;
|
---|
424 | LODRegisterType *changes_array;
|
---|
425 | LODRegisterVector list_changes;
|
---|
426 |
|
---|
427 | mTotalStrips = int(mFileStrips.size());
|
---|
428 | mVertex = new SmallInt[mTotalVertices];
|
---|
429 | mStripsChanges = new SmallInt[mTotalChanges];
|
---|
430 | mStrips = new SmallIntVector[mTotalStrips];
|
---|
431 | data_array = new SmallInt[mData.size()];
|
---|
432 |
|
---|
433 | //Calcular el tamaño maximo de tira y el numero de caras total
|
---|
434 | max = 0;
|
---|
435 | mTotalFaces = 0;
|
---|
436 |
|
---|
437 | for (i = 0; i < mFileStrips.size(); i++)
|
---|
438 | {
|
---|
439 | t = int(mFileStrips[i].size());
|
---|
440 |
|
---|
441 | if (t>max)
|
---|
442 | {
|
---|
443 | max = t;
|
---|
444 | }
|
---|
445 |
|
---|
446 | mTotalFaces += t - 2;
|
---|
447 | }
|
---|
448 |
|
---|
449 | //Nueva version de ALLOCATE.
|
---|
450 | changes_array = new LODRegisterType[mFileChangesLOD.size()];
|
---|
451 |
|
---|
452 | //Rellenar vChanges
|
---|
453 | for (i = 0; i < mFileChangesLOD.size(); ++i)
|
---|
454 | {
|
---|
455 | changes_array[i] = mFileChangesLOD[i];
|
---|
456 | }
|
---|
457 |
|
---|
458 | mCurrentRegLOD = changes_array;
|
---|
459 |
|
---|
460 | //COPY----------------------------------
|
---|
461 | //Copiar las tiras
|
---|
462 | for (i = 0; i < mFileStrips.size(); i++)
|
---|
463 | {
|
---|
464 | for (j = 0; j < mFileStrips[i].size(); j++)
|
---|
465 | {
|
---|
466 | //Rellenar el vVector
|
---|
467 | mStrips[i].push_back(mFileStrips[i][j]);
|
---|
468 | }
|
---|
469 |
|
---|
470 | //Poner a 0 los flags de modificados.
|
---|
471 | mStripsChanges[i] = 0;
|
---|
472 | }
|
---|
473 |
|
---|
474 | for (i = 0; i < mData.size(); i++)
|
---|
475 | {
|
---|
476 | data_array[i] = mData[i];
|
---|
477 | }
|
---|
478 |
|
---|
479 | mCurrentData = data_array;
|
---|
480 |
|
---|
481 | //Meter los vertices en mVertex
|
---|
482 | for(i = 0; i < mFileVertices.size(); i++)
|
---|
483 | {
|
---|
484 | mVertex[i] = mFileVertices[i];
|
---|
485 | }
|
---|
486 | }
|
---|
487 |
|
---|
488 | //-----------------------------------------------------------------------------
|
---|
489 | // LoadStripMesh
|
---|
490 | //-----------------------------------------------------------------------------
|
---|
491 | void LodStripsLibrary::LoadStripMesh(char *name, Mesh *geomesh)
|
---|
492 | {
|
---|
493 | FILE *fp;
|
---|
494 | SmallIntVector strip_aux;
|
---|
495 | LODRegisterType lod_register;
|
---|
496 | std::vector <LODRegisterType> list_pos;
|
---|
497 | std::vector <unsigned int> p_changes;
|
---|
498 | int value;
|
---|
499 | int v = 0;
|
---|
500 | int t = -1;
|
---|
501 | int s = 0;
|
---|
502 | int sig = 0;
|
---|
503 | int c = -1;
|
---|
504 | char buff[80];
|
---|
505 | Index *index;
|
---|
506 | Index *indexBegin;
|
---|
507 | Index *indexEnd;
|
---|
508 | SubMesh *geoSubMesh;
|
---|
509 |
|
---|
510 | // For each one of the submeshes.
|
---|
511 | for (unsigned int submesh = 0; submesh < geomesh->mSubMeshCount; submesh++)
|
---|
512 | {
|
---|
513 | geoSubMesh = &geomesh->mSubMesh[submesh];
|
---|
514 |
|
---|
515 | // For each one of the strips.
|
---|
516 | for (unsigned int strip = 0; strip < geoSubMesh->mStripCount; strip++)
|
---|
517 | {
|
---|
518 | // Insert an empty strip.
|
---|
519 | t++;
|
---|
520 | strip_aux.clear();
|
---|
521 | mFileStrips.push_back(strip_aux);
|
---|
522 |
|
---|
523 | // First index of the strip.
|
---|
524 | indexBegin = geoSubMesh->mStrip[strip];
|
---|
525 |
|
---|
526 | // If the strips is not the first.
|
---|
527 | /*
|
---|
528 | if (strip != 0)
|
---|
529 | {
|
---|
530 | indexBegin++;
|
---|
531 | }
|
---|
532 | */
|
---|
533 |
|
---|
534 | // If is the final strip
|
---|
535 | if (strip == (geoSubMesh->mStripCount - 1))
|
---|
536 | {
|
---|
537 | // The end of the index array.
|
---|
538 | indexEnd = &geoSubMesh->mIndex[geoSubMesh->mIndexCount];
|
---|
539 | }
|
---|
540 | else
|
---|
541 | {
|
---|
542 | // The beginning of the next strip.
|
---|
543 | indexEnd = geoSubMesh->mStrip[strip + 1];
|
---|
544 |
|
---|
545 | // Remove degenerated
|
---|
546 | //indexEnd--;
|
---|
547 | }
|
---|
548 |
|
---|
549 | int i;
|
---|
550 | i = 0;
|
---|
551 | // For each index of the strip.
|
---|
552 | for (index = indexBegin; index < indexEnd; index++)
|
---|
553 | {
|
---|
554 | mFileStrips[t].push_back(indexBegin[i]);
|
---|
555 | i++;
|
---|
556 | }
|
---|
557 | }
|
---|
558 | }
|
---|
559 |
|
---|
560 | // Open the LOD file.
|
---|
561 | if ((fp = fopen (name, "r")) == NULL)
|
---|
562 | {
|
---|
563 | // Error in open.
|
---|
564 | }
|
---|
565 | else
|
---|
566 | {
|
---|
567 | mTotalChanges = 0;
|
---|
568 |
|
---|
569 |
|
---|
570 | while (!feof (fp))
|
---|
571 | {
|
---|
572 | fgets (buff, 80, fp);
|
---|
573 |
|
---|
574 | if (*buff == 'v')
|
---|
575 | {
|
---|
576 | //VERTICES
|
---|
577 | sscanf (buff+2,"%d",&value);
|
---|
578 |
|
---|
579 | mFileVertices.push_back(value);
|
---|
580 | v++;
|
---|
581 | }
|
---|
582 | else if ( (*buff == 'c') || (*buff == 'd'))
|
---|
583 | {
|
---|
584 | if (*buff == 'c')
|
---|
585 | {
|
---|
586 | // c indica que empieza un nuevo cambio
|
---|
587 | c++;
|
---|
588 | }
|
---|
589 | else
|
---|
590 | {
|
---|
591 | unsigned int a;
|
---|
592 | unsigned int b;
|
---|
593 | unsigned int c;
|
---|
594 | unsigned int d;
|
---|
595 |
|
---|
596 | sscanf (buff+2,"%u %u %u %u\n",&a,&b,&c,&d);
|
---|
597 | lod_register.strip = a;
|
---|
598 | lod_register.position = b;
|
---|
599 | lod_register.vertexRepetition = c;
|
---|
600 | lod_register.edgeRepetition = d;
|
---|
601 |
|
---|
602 | mFileChangesLOD.push_back(lod_register);
|
---|
603 | }
|
---|
604 | }
|
---|
605 | else if (*buff=='b')
|
---|
606 | {
|
---|
607 | sscanf(buff+2,"%u",&value);
|
---|
608 | mData.push_back(value);
|
---|
609 | }
|
---|
610 | else if (*buff=='p')
|
---|
611 | {
|
---|
612 | sscanf (buff+2,"%u",&value);
|
---|
613 | p_changes.push_back(value);
|
---|
614 | }//Fin ElseIf
|
---|
615 |
|
---|
616 | } // End WhileEOF
|
---|
617 |
|
---|
618 | fclose(fp);
|
---|
619 |
|
---|
620 | // Max / Min values for LOD.
|
---|
621 | mLods = int(p_changes.size());
|
---|
622 | mMaxLod = 0;
|
---|
623 | mMinLod = mLods;
|
---|
624 |
|
---|
625 | //// CHAPUZA PROVISIONAL: EL ULTIMO ELEMENTO SE REPITE 2 VECES V.v
|
---|
626 | mPChanges = new SmallInt[mLods];
|
---|
627 |
|
---|
628 | for (unsigned int i = 0; i < mLods; i++)
|
---|
629 | {
|
---|
630 | mPChanges[i] = p_changes[i];
|
---|
631 | }
|
---|
632 |
|
---|
633 | mTotalVertices = int(mFileVertices.size());
|
---|
634 | mMaxVerticesLOD = mTotalVertices;
|
---|
635 | mTotalStrips = int(mFileStrips.size());
|
---|
636 | mTotalChanges = int(mFileChangesLOD.size());
|
---|
637 |
|
---|
638 | //Copy the data to the structure we will use
|
---|
639 | CopyVectors2Arrays();
|
---|
640 | }
|
---|
641 | }
|
---|
642 |
|
---|