#include <iomanip>#include "3dschunk.h"#include "3dsmodel.h"#include "3dsread.h"#include <celutil/bytes.h>#include <celutil/debug.h>Include dependency graph for 3dsread.cpp:

Go to the source code of this file.
Typedefs | |
| typedef bool(* | ProcessChunkFunc )(ifstream &in, unsigned short chunkType, int contentSize, void *) |
Functions | |
| void | indent () |
| void | logChunk (uint16 chunkType, int chunkSize) |
| bool | processColorChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| bool | processFaceArrayChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| bool | processMaterialChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| bool | processModelChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| static bool | processPercentageChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| bool | processSceneChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| static bool | processTexmapChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| bool | processTopLevelChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| bool | processTriMeshChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
| static int | read3DSChunk (ifstream &in, ProcessChunkFunc chunkFunc, void *obj) |
| int | read3DSChunks (ifstream &in, int nBytes, ProcessChunkFunc chunkFunc, void *obj) |
| M3DScene * | Read3DSFile (const string &filename) |
| M3DScene * | Read3DSFile (ifstream &in) |
| static char | readChar (ifstream &in) |
| M3DColor | readColor (ifstream &in, int nBytes) |
| void | readFaceArray (ifstream &in, M3DTriangleMesh *triMesh, int contentSize) |
| static float | readFloat (ifstream &in) |
| M3DColor | readFloatColor (ifstream &in, int nBytes) |
| static int32 | readInt (ifstream &in) |
| Mat4f | readMeshMatrix (ifstream &in, int nBytes) |
| void | readPointArray (ifstream &in, M3DTriangleMesh *triMesh) |
| static int16 | readShort (ifstream &in) |
| static string | readString (ifstream &in) |
| void | readTextureCoordArray (ifstream &in, M3DTriangleMesh *triMesh) |
| static uint16 | readUshort (ifstream &in) |
| static void | skipBytes (ifstream &in, int count) |
| bool | stubProcessChunk (ifstream &in, unsigned short chunkType, int contentSize, void *obj) |
Variables | |
| static int | logIndent = 0 |
|
|
Definition at line 20 of file 3dsread.cpp. |
|
|
Definition at line 112 of file 3dsread.cpp. References logIndent. Referenced by logChunk(). 00113 {
00114 for (int i = 0; i < logIndent; i++)
00115 cout << " ";
00116 }
|
|
||||||||||||
|
Definition at line 118 of file 3dsread.cpp. References indent(), M3DCHUNK_BACKGROUND_COLOR, M3DCHUNK_COLOR_24, M3DCHUNK_COLOR_FLOAT, M3DCHUNK_FACE_ARRAY, M3DCHUNK_FLOAT_PERCENTAGE, M3DCHUNK_INT_PERCENTAGE, M3DCHUNK_KFDATA, M3DCHUNK_LIN_COLOR_F, M3DCHUNK_MAGIC, M3DCHUNK_MASTER_SCALE, M3DCHUNK_MATERIAL_AMBIENT, M3DCHUNK_MATERIAL_DIFFUSE, M3DCHUNK_MATERIAL_ENTRY, M3DCHUNK_MATERIAL_MAPNAME, M3DCHUNK_MATERIAL_NAME, M3DCHUNK_MATERIAL_REFBLUR, M3DCHUNK_MATERIAL_SHIN2PCT, M3DCHUNK_MATERIAL_SHININESS, M3DCHUNK_MATERIAL_SPECULAR, M3DCHUNK_MATERIAL_TEXMAP, M3DCHUNK_MATERIAL_TRANSPARENCY, M3DCHUNK_MATERIAL_XPFALL, M3DCHUNK_MESH_MATERIAL_GROUP, M3DCHUNK_MESH_MATRIX, M3DCHUNK_MESH_SMOOTH_GROUP, M3DCHUNK_MESH_TEXTURE_COORDS, M3DCHUNK_MESH_VERSION, M3DCHUNK_MESHDATA, M3DCHUNK_NAMED_OBJECT, M3DCHUNK_NULL, M3DCHUNK_POINT_ARRAY, M3DCHUNK_POINT_FLAG_ARRAY, M3DCHUNK_TRIANGLE_MESH, and M3DCHUNK_VERSION. Referenced by read3DSChunk(). 00119 {
00120 const char* name = NULL;
00121
00122 switch (chunkType)
00123 {
00124 case M3DCHUNK_NULL:
00125 name = "M3DCHUNK_NULL"; break;
00126 case M3DCHUNK_VERSION:
00127 name = "M3DCHUNK_VERSION"; break;
00128 case M3DCHUNK_COLOR_FLOAT:
00129 name = "M3DCHUNK_COLOR_FLOAT"; break;
00130 case M3DCHUNK_COLOR_24:
00131 name = "M3DCHUNK_COLOR_24"; break;
00132 case M3DCHUNK_LIN_COLOR_F:
00133 name = "M3DCHUNK_LIN_COLOR_F"; break;
00134 case M3DCHUNK_INT_PERCENTAGE:
00135 name = "M3DCHUNK_INT_PERCENTAGE"; break;
00136 case M3DCHUNK_FLOAT_PERCENTAGE:
00137 name = "M3DCHUNK_FLOAT_PERCENTAGE"; break;
00138 case M3DCHUNK_MASTER_SCALE:
00139 name = "M3DCHUNK_MASTER_SCALE"; break;
00140 case M3DCHUNK_BACKGROUND_COLOR:
00141 name = "M3DCHUNK_BACKGROUND_COLOR"; break;
00142 case M3DCHUNK_MESHDATA:
00143 name = "M3DCHUNK_MESHDATA"; break;
00144 case M3DCHUNK_MESH_VERSION:
00145 name = "M3DCHUNK_MESHVERSION"; break;
00146 case M3DCHUNK_NAMED_OBJECT:
00147 name = "M3DCHUNK_NAMED_OBJECT"; break;
00148 case M3DCHUNK_TRIANGLE_MESH:
00149 name = "M3DCHUNK_TRIANGLE_MESH"; break;
00150 case M3DCHUNK_POINT_ARRAY:
00151 name = "M3DCHUNK_POINT_ARRAY"; break;
00152 case M3DCHUNK_POINT_FLAG_ARRAY:
00153 name = "M3DCHUNK_POINT_FLAG_ARRAY"; break;
00154 case M3DCHUNK_FACE_ARRAY:
00155 name = "M3DCHUNK_FACE_ARRAY"; break;
00156 case M3DCHUNK_MESH_MATERIAL_GROUP:
00157 name = "M3DCHUNK_MESH_MATERIAL_GROUP"; break;
00158 case M3DCHUNK_MESH_TEXTURE_COORDS:
00159 name = "M3DCHUNK_MESH_TEXTURE_COORDS"; break;
00160 case M3DCHUNK_MESH_SMOOTH_GROUP:
00161 name = "M3DCHUNK_MESH_SMOOTH_GROUP"; break;
00162 case M3DCHUNK_MESH_MATRIX:
00163 name = "M3DCHUNK_MESH_MATRIX"; break;
00164 case M3DCHUNK_MAGIC:
00165 name = "M3DCHUNK_MAGIC"; break;
00166 case M3DCHUNK_MATERIAL_NAME:
00167 name = "M3DCHUNK_MATERIAL_NAME"; break;
00168 case M3DCHUNK_MATERIAL_AMBIENT:
00169 name = "M3DCHUNK_MATERIAL_AMBIENT"; break;
00170 case M3DCHUNK_MATERIAL_DIFFUSE:
00171 name = "M3DCHUNK_MATERIAL_DIFFUSE"; break;
00172 case M3DCHUNK_MATERIAL_SPECULAR:
00173 name = "M3DCHUNK_MATERIAL_SPECULAR"; break;
00174 case M3DCHUNK_MATERIAL_SHININESS:
00175 name = "M3DCHUNK_MATERIAL_SHININESS"; break;
00176 case M3DCHUNK_MATERIAL_SHIN2PCT:
00177 name = "M3DCHUNK_MATERIAL_SHIN2PCT"; break;
00178 case M3DCHUNK_MATERIAL_TRANSPARENCY:
00179 name = "M3DCHUNK_MATERIAL_TRANSPARENCY"; break;
00180 case M3DCHUNK_MATERIAL_XPFALL:
00181 name = "M3DCHUNK_MATERIAL_XPFALL"; break;
00182 case M3DCHUNK_MATERIAL_REFBLUR:
00183 name = "M3DCHUNK_MATERIAL_REFBLUR"; break;
00184 case M3DCHUNK_MATERIAL_TEXMAP:
00185 name = "M3DCHUNK_MATERIAL_TEXMAP"; break;
00186 case M3DCHUNK_MATERIAL_MAPNAME:
00187 name = "M3DCHUNK_MATERIAL_MAPNAME"; break;
00188 case M3DCHUNK_MATERIAL_ENTRY:
00189 name = "M3DCHUNK_MATERIAL_ENTRY"; break;
00190 case M3DCHUNK_KFDATA:
00191 name = "M3DCHUNK_KFDATA";
00192 default:
00193 break;
00194 }
00195 #if 0
00196 indent();
00197
00198 if (name == NULL)
00199 {
00200 cout << "Chunk ID " << setw(4) << hex << setfill('0') << chunkType;
00201 cout << setw(0) << dec << ", size = " << chunkSize << '\n';
00202 }
00203 else
00204 {
00205 cout << name << ", size = " << chunkSize << '\n';
00206 }
00207
00208 cout.flush();
00209 #endif
00210 }
|
|
||||||||||||||||||||
|
Definition at line 462 of file 3dsread.cpp. References M3DCHUNK_COLOR_24, M3DCHUNK_COLOR_FLOAT, readColor(), and readFloatColor(). Referenced by processMaterialChunk(), and processSceneChunk(). 00466 {
00467 M3DColor* color = (M3DColor*) obj;
00468
00469 if (chunkType == M3DCHUNK_COLOR_24)
00470 {
00471 *color = readColor(in, contentSize);
00472 return true;
00473 }
00474 else if (chunkType == (M3DCHUNK_COLOR_FLOAT))
00475 {
00476 *color = readFloatColor(in, contentSize);
00477 return true;
00478 }
00479 else
00480 {
00481 return false;
00482 }
00483 }
|
|
||||||||||||||||||||
|
Definition at line 340 of file 3dsread.cpp. References M3DTriangleMesh::addSmoothingGroups(), M3DTriangleMesh::getFaceCount(), M3DCHUNK_MESH_MATERIAL_GROUP, M3DCHUNK_MESH_SMOOTH_GROUP, readInt(), readString(), readUshort(), and M3DTriangleMesh::setMaterialName(). Referenced by readFaceArray(). 00344 {
00345 M3DTriangleMesh* triMesh = (M3DTriangleMesh*) obj;
00346
00347 if (chunkType == M3DCHUNK_MESH_MATERIAL_GROUP)
00348 {
00349 // For now, we just assume that there is only one material group
00350 // per triangle mesh, and that the material applies to all faces in
00351 // the mesh.
00352 string materialName = readString(in);
00353 uint16 nFaces = readUshort(in);
00354
00355 for (uint16 i = 0; i < nFaces; i++)
00356 {
00357 readUshort(in);
00358 }
00359
00360 triMesh->setMaterialName(materialName);
00361
00362 return true;
00363 }
00364 else if (chunkType == M3DCHUNK_MESH_SMOOTH_GROUP)
00365 {
00366 uint16 nFaces = triMesh->getFaceCount();
00367
00368 for (uint16 i = 0; i < nFaces; i++)
00369 {
00370 uint32 groups = (uint32) readInt(in);
00371 // cout << setw(8) << hex << setfill('0') << groups << dec << setw(0) << '\n';
00372 triMesh->addSmoothingGroups(groups);
00373 }
00374 return true;
00375 }
00376 else
00377 {
00378 return false;
00379 }
00380 }
|
|
||||||||||||||||||||
|
Definition at line 530 of file 3dsread.cpp. References M3DCHUNK_MATERIAL_AMBIENT, M3DCHUNK_MATERIAL_DIFFUSE, M3DCHUNK_MATERIAL_NAME, M3DCHUNK_MATERIAL_SHININESS, M3DCHUNK_MATERIAL_SPECULAR, M3DCHUNK_MATERIAL_TEXMAP, M3DCHUNK_MATERIAL_TRANSPARENCY, processColorChunk(), processPercentageChunk(), processTexmapChunk(), read3DSChunks(), readString(), M3DMaterial::setAmbientColor(), M3DMaterial::setDiffuseColor(), M3DMaterial::setName(), M3DMaterial::setOpacity(), M3DMaterial::setShininess(), and M3DMaterial::setSpecularColor(). Referenced by processSceneChunk(). 00534 {
00535 M3DMaterial* material = (M3DMaterial*) obj;
00536
00537 if (chunkType == M3DCHUNK_MATERIAL_NAME)
00538 {
00539 string name = readString(in);
00540 material->setName(name);
00541 return true;
00542 }
00543 else if (chunkType == M3DCHUNK_MATERIAL_AMBIENT)
00544 {
00545 M3DColor ambient;
00546 read3DSChunks(in, contentSize, processColorChunk, (void*) &ambient);
00547 material->setAmbientColor(ambient);
00548 return true;
00549 }
00550 else if (chunkType == M3DCHUNK_MATERIAL_DIFFUSE)
00551 {
00552 M3DColor diffuse;
00553 read3DSChunks(in, contentSize, processColorChunk, (void*) &diffuse);
00554 material->setDiffuseColor(diffuse);
00555 return true;
00556 }
00557 else if (chunkType == M3DCHUNK_MATERIAL_SPECULAR)
00558 {
00559 M3DColor specular;
00560 read3DSChunks(in, contentSize, processColorChunk, (void*) &specular);
00561 material->setSpecularColor(specular);
00562 return true;
00563 }
00564 else if (chunkType == M3DCHUNK_MATERIAL_SHININESS)
00565 {
00566 float shininess;
00567 read3DSChunks(in, contentSize, processPercentageChunk,
00568 (void*) &shininess);
00569 material->setShininess(shininess);
00570 return true;
00571 }
00572 else if (chunkType == M3DCHUNK_MATERIAL_TRANSPARENCY)
00573 {
00574 float transparency;
00575 read3DSChunks(in, contentSize, processPercentageChunk,
00576 (void*) &transparency);
00577 material->setOpacity(1.0f - transparency / 100.0f);
00578 return true;
00579 }
00580
00581 else if (chunkType == M3DCHUNK_MATERIAL_TEXMAP)
00582 {
00583 read3DSChunks(in, contentSize, processTexmapChunk, (void*) material);
00584 return true;
00585 }
00586 else
00587 {
00588 return false;
00589 }
00590 }
|
|
||||||||||||||||||||
|
Definition at line 441 of file 3dsread.cpp. References M3DModel::addTriMesh(), M3DCHUNK_TRIANGLE_MESH, processTriMeshChunk(), and read3DSChunks(). Referenced by processSceneChunk(). 00445 {
00446 M3DModel* model = (M3DModel*) obj;
00447
00448 if (chunkType == M3DCHUNK_TRIANGLE_MESH)
00449 {
00450 M3DTriangleMesh* triMesh = new M3DTriangleMesh();
00451 read3DSChunks(in, contentSize, processTriMeshChunk, (void*) triMesh);
00452 model->addTriMesh(triMesh);
00453 return true;
00454 }
00455 else
00456 {
00457 return false;
00458 }
00459 }
|
|
||||||||||||||||||||
|
Definition at line 486 of file 3dsread.cpp. References M3DCHUNK_FLOAT_PERCENTAGE, M3DCHUNK_INT_PERCENTAGE, readFloat(), and readShort(). Referenced by processMaterialChunk(). 00490 {
00491 float* percent = (float*) obj;
00492
00493 if (chunkType == M3DCHUNK_INT_PERCENTAGE)
00494 {
00495 *percent = readShort(in);
00496 return true;
00497 }
00498 else if (chunkType == M3DCHUNK_FLOAT_PERCENTAGE)
00499 {
00500 *percent = readFloat(in);
00501 return true;
00502 }
00503 else
00504 {
00505 return false;
00506 }
00507 }
|
|
||||||||||||||||||||
|
Definition at line 593 of file 3dsread.cpp. References M3DScene::addMaterial(), M3DScene::addModel(), M3DCHUNK_BACKGROUND_COLOR, M3DCHUNK_MATERIAL_ENTRY, M3DCHUNK_NAMED_OBJECT, processColorChunk(), processMaterialChunk(), processModelChunk(), read3DSChunks(), readString(), M3DScene::setBackgroundColor(), and M3DModel::setName(). Referenced by processTopLevelChunk(). 00597 {
00598 M3DScene* scene = (M3DScene*) obj;
00599
00600 if (chunkType == M3DCHUNK_NAMED_OBJECT)
00601 {
00602 string name = readString(in);
00603
00604 M3DModel* model = new M3DModel();
00605 model->setName(name);
00606 // indent(); cout << " [" << name << "]\n";
00607 read3DSChunks(in,
00608 contentSize - (name.length() + 1),
00609 processModelChunk,
00610 (void*) model);
00611 scene->addModel(model);
00612
00613 return true;
00614 }
00615 else if (chunkType == M3DCHUNK_MATERIAL_ENTRY)
00616 {
00617 M3DMaterial* material = new M3DMaterial();
00618 read3DSChunks(in,
00619 contentSize,
00620 processMaterialChunk,
00621 (void*) material);
00622 scene->addMaterial(material);
00623
00624 return true;
00625 }
00626 else if (chunkType == M3DCHUNK_BACKGROUND_COLOR)
00627 {
00628 M3DColor color;
00629 read3DSChunks(in, contentSize, processColorChunk, (void*) &color);
00630 scene->setBackgroundColor(color);
00631 return true;
00632 }
00633 else
00634 {
00635 return false;
00636 }
00637 }
|
|
||||||||||||||||||||
|
Definition at line 510 of file 3dsread.cpp. References M3DCHUNK_MATERIAL_MAPNAME, readString(), and M3DMaterial::setTextureMap(). Referenced by processMaterialChunk(). 00514 {
00515 M3DMaterial* material = (M3DMaterial*) obj;
00516
00517 if (chunkType == M3DCHUNK_MATERIAL_MAPNAME)
00518 {
00519 string name = readString(in);
00520 material->setTextureMap(name);
00521 return true;
00522 }
00523 else
00524 {
00525 return false;
00526 }
00527 }
|
|
||||||||||||||||||||
|
Definition at line 640 of file 3dsread.cpp. References M3DCHUNK_MESHDATA, processSceneChunk(), and read3DSChunks(). Referenced by Read3DSFile(). 00644 {
00645 M3DScene* scene = (M3DScene*) obj;
00646
00647 if (chunkType == M3DCHUNK_MESHDATA)
00648 {
00649 read3DSChunks(in, contentSize, processSceneChunk, (void*) scene);
00650 return true;
00651 }
00652 else
00653 {
00654 return false;
00655 }
00656 }
|
|
||||||||||||||||||||
|
Definition at line 407 of file 3dsread.cpp. References M3DCHUNK_FACE_ARRAY, M3DCHUNK_MESH_MATRIX, M3DCHUNK_MESH_TEXTURE_COORDS, M3DCHUNK_POINT_ARRAY, readFaceArray(), readMeshMatrix(), readPointArray(), readTextureCoordArray(), and M3DTriangleMesh::setMatrix(). Referenced by processModelChunk(). 00411 {
00412 M3DTriangleMesh* triMesh = (M3DTriangleMesh*) obj;
00413
00414 if (chunkType == M3DCHUNK_POINT_ARRAY)
00415 {
00416 readPointArray(in, triMesh);
00417 return true;
00418 }
00419 else if (chunkType == M3DCHUNK_MESH_TEXTURE_COORDS)
00420 {
00421 readTextureCoordArray(in, triMesh);
00422 return true;
00423 }
00424 else if (chunkType == M3DCHUNK_FACE_ARRAY)
00425 {
00426 readFaceArray(in, triMesh, contentSize);
00427 return true;
00428 }
00429 else if (chunkType == M3DCHUNK_MESH_MATRIX)
00430 {
00431 triMesh->setMatrix(readMeshMatrix(in, contentSize));
00432 return true;
00433 }
00434 else
00435 {
00436 return false;
00437 }
00438 }
|
|
||||||||||||||||
|
Definition at line 213 of file 3dsread.cpp. References logChunk(), readInt(), readUshort(), and skipBytes(). Referenced by read3DSChunks(). 00216 {
00217 unsigned short chunkType = readUshort(in);
00218 int32 chunkSize = readInt(in);
00219 int contentSize = chunkSize - 6;
00220
00221 logChunk(chunkType, chunkSize);
00222 bool chunkWasRead = chunkFunc(in, chunkType, contentSize, obj);
00223
00224 if (!chunkWasRead)
00225 {
00226 skipBytes(in, contentSize);
00227 }
00228
00229 return chunkSize;
00230 }
|
|
||||||||||||||||||||
|
Definition at line 233 of file 3dsread.cpp. References logIndent, and read3DSChunk(). Referenced by processMaterialChunk(), processModelChunk(), processSceneChunk(), processTopLevelChunk(), Read3DSFile(), and readFaceArray(). 00237 {
00238 int bytesRead = 0;
00239
00240 logIndent++;
00241 while (bytesRead < nBytes)
00242 bytesRead += read3DSChunk(in, chunkFunc, obj);
00243 logIndent--;
00244
00245 if (bytesRead != nBytes)
00246 cout << "Expected " << nBytes << " bytes but read " << bytesRead << '\n';
00247 return bytesRead;
00248 }
|
|
|
Definition at line 686 of file 3dsread.cpp. References DPRINTF, and Read3DSFile(). 00687 {
00688 ifstream in(filename.c_str(), ios::in | ios::binary);
00689 if (!in.good())
00690 {
00691 DPRINTF(0, "Read3DSFile: Error opening %s\n", filename.c_str());
00692 return NULL;
00693 }
00694 else
00695 {
00696 M3DScene* scene = Read3DSFile(in);
00697 in.close();
00698 return scene;
00699 }
00700 }
|
|
|
Definition at line 659 of file 3dsread.cpp. References DPRINTF, M3DCHUNK_MAGIC, processTopLevelChunk(), read3DSChunks(), readInt(), and readUshort(). Referenced by ModelInfo::load(), main(), and Read3DSFile(). 00660 {
00661 unsigned short chunkType = readUshort(in);
00662 if (chunkType != M3DCHUNK_MAGIC)
00663 {
00664 DPRINTF(0, "Read3DSFile: Wrong magic number in header\n");
00665 return NULL;
00666 }
00667
00668 int32 chunkSize = readInt(in);
00669 if (in.bad())
00670 {
00671 DPRINTF(0, "Read3DSFile: Error reading 3DS file.\n");
00672 return NULL;
00673 }
00674
00675 DPRINTF(1, "3DS file, %d bytes\n", chunkSize);
00676
00677 M3DScene* scene = new M3DScene();
00678 int contentSize = chunkSize - 6;
00679
00680 read3DSChunks(in, contentSize, processTopLevelChunk, (void*) scene);
00681
00682 return scene;
00683 }
|
|
|
Definition at line 66 of file 3dsread.cpp. Referenced by readColor(). 00067 {
00068 char c;
00069 in.read(&c, 1);
00070 return c;
00071 }
|
|
||||||||||||
|
Definition at line 251 of file 3dsread.cpp. References readChar(). Referenced by processColorChunk(). 00252 {
00253 unsigned char r = (unsigned char) readChar(in);
00254 unsigned char g = (unsigned char) readChar(in);
00255 unsigned char b = (unsigned char) readChar(in);
00256
00257 return M3DColor((float) r / 255.0f,
00258 (float) g / 255.0f,
00259 (float) b / 255.0f);
00260 }
|
|
||||||||||||||||
|
Definition at line 383 of file 3dsread.cpp. References M3DTriangleMesh::addFace(), processFaceArrayChunk(), read3DSChunks(), and readUshort(). Referenced by processTriMeshChunk(). 00384 {
00385 uint16 nFaces = readUshort(in);
00386
00387 for (int i = 0; i < (int) nFaces; i++)
00388 {
00389 uint16 v0 = readUshort(in);
00390 uint16 v1 = readUshort(in);
00391 uint16 v2 = readUshort(in);
00392 /*uint16 flags = */ readUshort(in);
00393 triMesh->addFace(v0, v1, v2);
00394 }
00395
00396 int bytesLeft = contentSize - (8 * nFaces + 2);
00397 if (bytesLeft > 0)
00398 {
00399 read3DSChunks(in,
00400 bytesLeft,
00401 processFaceArrayChunk,
00402 (void*) triMesh);
00403 }
00404 }
|
|
|
Definition at line 57 of file 3dsread.cpp. References LE_TO_CPU_FLOAT. 00058 {
00059 float f;
00060 in.read((char*) &f, sizeof(float));
00061 LE_TO_CPU_FLOAT(f, f);
00062 return f;
00063 }
|
|
||||||||||||
|
Definition at line 263 of file 3dsread.cpp. References readFloat(). Referenced by processColorChunk(). 00264 {
00265 float r = readFloat(in);
00266 float g = readFloat(in);
00267 float b = readFloat(in);
00268
00269 return M3DColor((float) r / 255.0f,
00270 (float) g / 255.0f,
00271 (float) b / 255.0f);
00272 }
|
|
|
Definition at line 33 of file 3dsread.cpp. References LE_TO_CPU_INT32. 00034 {
00035 int32 ret;
00036 in.read((char *) &ret, sizeof(int32));
00037 LE_TO_CPU_INT32(ret, ret);
00038 return ret;
00039 }
|
|
||||||||||||
|
Definition at line 275 of file 3dsread.cpp. References readFloat(). Referenced by processTriMeshChunk(). 00276 {
00277 float m00 = readFloat(in);
00278 float m01 = readFloat(in);
00279 float m02 = readFloat(in);
00280 float m10 = readFloat(in);
00281 float m11 = readFloat(in);
00282 float m12 = readFloat(in);
00283 float m20 = readFloat(in);
00284 float m21 = readFloat(in);
00285 float m22 = readFloat(in);
00286 float m30 = readFloat(in);
00287 float m31 = readFloat(in);
00288 float m32 = readFloat(in);
00289
00290 #if 0
00291 cout << m00 << " " << m01 << " " << m02 << '\n';
00292 cout << m10 << " " << m11 << " " << m12 << '\n';
00293 cout << m20 << " " << m21 << " " << m22 << '\n';
00294 cout << m30 << " " << m31 << " " << m32 << '\n';
00295 #endif
00296
00297 return Mat4f(Vec4f(m00, m01, m02, 0),
00298 Vec4f(m10, m11, m12, 0),
00299 Vec4f(m20, m21, m22, 0),
00300 Vec4f(m30, m31, m32, 1));
00301 }
|
|
||||||||||||
|
Definition at line 313 of file 3dsread.cpp. References readFloat(), and readUshort(). Referenced by processTriMeshChunk(). 00314 {
00315 uint16 nPoints = readUshort(in);
00316
00317 for (int i = 0; i < (int) nPoints; i++)
00318 {
00319 float x = readFloat(in);
00320 float y = readFloat(in);
00321 float z = readFloat(in);
00322 triMesh->addVertex(Point3f(x, y, z));
00323 }
00324 }
|
|
|
Definition at line 41 of file 3dsread.cpp. References LE_TO_CPU_INT16. 00042 {
00043 int16 ret;
00044 in.read((char *) &ret, sizeof(int16));
00045 LE_TO_CPU_INT16(ret, ret);
00046 return ret;
00047 }
|
|
|
Definition at line 88 of file 3dsread.cpp. Referenced by processFaceArrayChunk(), processMaterialChunk(), processSceneChunk(), and processTexmapChunk(). 00089 {
00090 char s[1024];
00091 int maxLength = sizeof(s);
00092
00093 for (int count = 0; count < maxLength; count++)
00094 {
00095 in.read(s + count, 1);
00096 if (s[count] == '\0')
00097 break;
00098 }
00099
00100 return string(s);
00101 }
|
|
||||||||||||
|
Definition at line 327 of file 3dsread.cpp. References readFloat(), and readUshort(). Referenced by processTriMeshChunk(). 00328 {
00329 uint16 nPoints = readUshort(in);
00330
00331 for (int i = 0; i < (int) nPoints; i++)
00332 {
00333 float u = readFloat(in);
00334 float v = readFloat(in);
00335 triMesh->addTexCoord(Point2f(u, -v));
00336 }
00337 }
|
|
|
Definition at line 49 of file 3dsread.cpp. References LE_TO_CPU_INT16. 00050 {
00051 uint16 ret;
00052 in.read((char *) &ret, sizeof(uint16));
00053 LE_TO_CPU_INT16(ret, ret);
00054 return ret;
00055 }
|
|
||||||||||||
|
Definition at line 104 of file 3dsread.cpp. Referenced by read3DSChunk(). 00105 {
00106 char c;
00107 while (count-- > 0)
00108 in.get(c);
00109 }
|
|
||||||||||||||||||||
|
Definition at line 304 of file 3dsread.cpp. 00308 {
00309 return false;
00310 }
|
|
|
Definition at line 30 of file 3dsread.cpp. Referenced by indent(), and read3DSChunks(). |
1.4.1