#include "modelfile.h"#include "tokenizer.h"#include "texmanager.h"#include <celutil/bytes.h>#include <cstring>#include <cassert>#include <cmath>#include <cstdio>Include dependency graph for modelfile.cpp:

Go to the source code of this file.
Functions | |
| static Color | DefaultDiffuse (0.0f, 0.0f, 0.0f) |
| static Color | DefaultEmissive (0.0f, 0.0f, 0.0f) |
| static Color | DefaultSpecular (0.0f, 0.0f, 0.0f) |
| static bool | ignoreValue (istream &in) |
| Model * | LoadModel (istream &in, const string &texPath) |
| Model * | LoadModel (istream &in) |
| static float | readFloat (istream &in) |
| static int16 | readInt16 (istream &in) |
| static ModelFileToken | readToken (istream &in) |
| static ModelFileType | readType (istream &in) |
| static bool | readTypeColor (istream &in, Color &c) |
| static bool | readTypeFloat1 (istream &in, float &f) |
| static bool | readTypeString (istream &in, string &s) |
| static int32 | readUint (istream &in) |
| bool | SaveModelAscii (const Model *model, std::ostream &out) |
| bool | SaveModelBinary (const Model *model, std::ostream &out) |
| static void | writeFloat (ostream &out, float val) |
| static void | writeInt16 (ostream &out, int16 val) |
| static void | writeToken (ostream &out, ModelFileToken val) |
| static void | writeType (ostream &out, ModelFileType val) |
| static void | writeTypeColor (ostream &out, const Color &c) |
| static void | writeTypeFloat1 (ostream &out, float f) |
| static void | writeTypeString (ostream &out, const string &s) |
| static void | writeUint (ostream &out, uint32 val) |
Variables | |
| static float | DefaultOpacity = 1.0f |
| static float | DefaultSpecularPower = 1.0f |
|
||||||||||||||||
|
Referenced by BinaryModelLoader::loadMaterial(), AsciiModelLoader::loadMaterial(), BinaryModelWriter::writeMaterial(), and AsciiModelWriter::writeMaterial(). |
|
||||||||||||||||
|
Referenced by BinaryModelLoader::loadMaterial(), AsciiModelLoader::loadMaterial(), BinaryModelWriter::writeMaterial(), and AsciiModelWriter::writeMaterial(). |
|
||||||||||||||||
|
Referenced by BinaryModelLoader::loadMaterial(), AsciiModelLoader::loadMaterial(), BinaryModelWriter::writeMaterial(), and AsciiModelWriter::writeMaterial(). |
|
|
Definition at line 1156 of file modelfile.cpp. References CMOD_Color, CMOD_Float1, CMOD_Float2, CMOD_Float3, CMOD_Float4, CMOD_String, CMOD_Uint32, LE_TO_CPU_INT16, and readType(). Referenced by BinaryModelLoader::loadMaterial(). 01157 {
01158 ModelFileType type = readType(in);
01159 int size = 0;
01160
01161 switch (type)
01162 {
01163 case CMOD_Float1:
01164 size = 4;
01165 break;
01166 case CMOD_Float2:
01167 size = 8;
01168 break;
01169 case CMOD_Float3:
01170 size = 12;
01171 break;
01172 case CMOD_Float4:
01173 size = 16;
01174 break;
01175 case CMOD_Uint32:
01176 size = 4;
01177 break;
01178 case CMOD_Color:
01179 size = 12;
01180 break;
01181 case CMOD_String:
01182 {
01183 uint16 len;
01184 in.read((char*) &len, sizeof(uint16));
01185 LE_TO_CPU_INT16(len, len);
01186 size = len;
01187 }
01188 break;
01189
01190 default:
01191 return false;
01192 }
01193
01194 in.ignore(size);
01195
01196 return true;
01197 }
|
|
||||||||||||
|
Definition at line 223 of file modelfile.cpp. References ModelLoader::getErrorMessage(), ModelLoader::load(), ModelLoader::OpenModel(), and ModelLoader::setTexturePath(). 00224 {
00225 ModelLoader* loader = ModelLoader::OpenModel(in);
00226 if (loader == NULL)
00227 return NULL;
00228
00229 loader->setTexturePath(texPath);
00230
00231 Model* model = loader->load();
00232 if (model == NULL)
00233 cerr << "Error in model file: " << loader->getErrorMessage() << '\n';
00234
00235 delete loader;
00236
00237 return model;
00238 }
|
|
|
Definition at line 217 of file modelfile.cpp. Referenced by ModelInfo::load(), and main(). 00218 {
00219 return LoadModel(in, "");
00220 }
|
|
|
Definition at line 1080 of file modelfile.cpp. References readUint(). Referenced by DumpOldStarDatabase(), DumpStarDatabase(), BinaryModelLoader::loadVertices(), processPercentageChunk(), readFloatColor(), readMeshMatrix(), readPointArray(), readTextureCoordArray(), readTypeColor(), and readTypeFloat1(). 01081 {
01082 int i = readUint(in);
01083 return *((float*) &i);
01084 }
|
|
|
Definition at line 1087 of file modelfile.cpp. References LE_TO_CPU_INT16. Referenced by TextureFont::load(), BinaryModelLoader::loadMaterial(), BinaryModelLoader::loadMesh(), BinaryModelLoader::loadVertexDescription(), readToken(), and readType(). 01088 {
01089 int16 ret;
01090 in.read((char *) &ret, sizeof(int16));
01091 LE_TO_CPU_INT16(ret, ret);
01092 return ret;
01093 }
|
|
|
Definition at line 1096 of file modelfile.cpp. References readInt16(). Referenced by BinaryModelLoader::load(), BinaryModelLoader::loadMaterial(), BinaryModelLoader::loadVertexDescription(), and BinaryModelLoader::loadVertices(). 01097 {
01098 return (ModelFileToken) readInt16(in);
01099 }
|
|
|
Definition at line 1102 of file modelfile.cpp. References readInt16(). Referenced by ignoreValue(), readTypeColor(), readTypeFloat1(), and readTypeString(). 01103 {
01104 return (ModelFileType) readInt16(in);
01105 }
|
|
||||||||||||
|
Definition at line 1117 of file modelfile.cpp. References CMOD_Color, readFloat(), and readType(). Referenced by BinaryModelLoader::loadMaterial(). 01118 {
01119 if (readType(in) != CMOD_Color)
01120 return false;
01121
01122 float r = readFloat(in);
01123 float g = readFloat(in);
01124 float b = readFloat(in);
01125 c = Color(r, g, b);
01126
01127 return true;
01128 }
|
|
||||||||||||
|
Definition at line 1108 of file modelfile.cpp. References CMOD_Float1, readFloat(), and readType(). Referenced by BinaryModelLoader::loadMaterial(). 01109 {
01110 if (readType(in) != CMOD_Float1)
01111 return false;
01112 f = readFloat(in);
01113 return true;
01114 }
|
|
||||||||||||
|
Definition at line 1131 of file modelfile.cpp. References CMOD_String, LE_TO_CPU_INT16, and readType(). Referenced by BinaryModelLoader::loadMaterial(). 01132 {
01133 if (readType(in) != CMOD_String)
01134 return false;
01135
01136 uint16 len;
01137 in.read((char*) &len, sizeof(uint16));
01138 LE_TO_CPU_INT16(len, len);
01139
01140 if (len == 0)
01141 {
01142 s = "";
01143 }
01144 else
01145 {
01146 char* buf = new char[len];
01147 in.read(buf, len);
01148 s = string(buf, len);
01149 delete[] buf;
01150 }
01151
01152 return true;
01153 }
|
|
|
Definition at line 1071 of file modelfile.cpp. References LE_TO_CPU_INT32. 01072 {
01073 int32 ret;
01074 in.read((char*) &ret, sizeof(int32));
01075 LE_TO_CPU_INT32(ret, ret);
01076 return (uint32) ret;
01077 }
|
|
||||||||||||
|
Definition at line 264 of file modelfile.cpp. Referenced by main(). 00265 {
00266 if (model == NULL)
00267 return false;
00268
00269 AsciiModelWriter(out).write(*model);
00270
00271 return true;
00272 }
|
|
||||||||||||
|
Definition at line 275 of file modelfile.cpp. Referenced by main(). 00276 {
00277 if (model == NULL)
00278 return false;
00279
00280 BinaryModelWriter(out).write(*model);
00281
00282 return true;
00283 }
|
|
||||||||||||
|
Definition at line 1590 of file modelfile.cpp. References LE_TO_CPU_FLOAT. Referenced by WriteStarDatabase(), writeTypeColor(), writeTypeFloat1(), and BinaryModelWriter::writeVertices(). 01591 {
01592 LE_TO_CPU_FLOAT(val, val);
01593 out.write(reinterpret_cast<char*>(&val), sizeof(float));
01594 }
|
|
||||||||||||
|
Definition at line 1596 of file modelfile.cpp. References LE_TO_CPU_INT16. Referenced by BinaryModelWriter::writeGroup(), BinaryModelWriter::writeMaterial(), writeToken(), writeType(), writeTypeString(), and BinaryModelWriter::writeVertexDescription(). 01597 {
01598 LE_TO_CPU_INT16(val, val);
01599 out.write(reinterpret_cast<char*>(&val), sizeof(int16));
01600 }
|
|
||||||||||||
|
Definition at line 1602 of file modelfile.cpp. References writeInt16(). Referenced by BinaryModelWriter::writeMaterial(), BinaryModelWriter::writeMesh(), BinaryModelWriter::writeVertexDescription(), and BinaryModelWriter::writeVertices(). 01603 {
01604 writeInt16(out, static_cast<int16>(val));
01605 }
|
|
||||||||||||
|
Definition at line 1607 of file modelfile.cpp. References writeInt16(). Referenced by writeTypeColor(), writeTypeFloat1(), and writeTypeString(). 01608 {
01609 writeInt16(out, static_cast<int16>(val));
01610 }
|
|
||||||||||||
|
Definition at line 1620 of file modelfile.cpp. References CMOD_Color, writeFloat(), and writeType(). Referenced by BinaryModelWriter::writeMaterial(). 01621 {
01622 writeType(out, CMOD_Color);
01623 writeFloat(out, c.red());
01624 writeFloat(out, c.green());
01625 writeFloat(out, c.blue());
01626 }
|
|
||||||||||||
|
Definition at line 1613 of file modelfile.cpp. References CMOD_Float1, writeFloat(), and writeType(). Referenced by BinaryModelWriter::writeMaterial(). 01614 {
01615 writeType(out, CMOD_Float1);
01616 writeFloat(out, f);
01617 }
|
|
||||||||||||
|
Definition at line 1629 of file modelfile.cpp. References CMOD_String, writeInt16(), and writeType(). Referenced by BinaryModelWriter::writeMaterial(). 01630 {
01631 writeType(out, CMOD_String);
01632 writeInt16(out, static_cast<int16>(s.length()));
01633 out.write(s.c_str(), s.length());
01634 }
|
|
||||||||||||
|
Definition at line 1584 of file modelfile.cpp. References LE_TO_CPU_INT32. Referenced by WriteCrossIndex(), BinaryModelWriter::writeGroup(), WriteStarDatabase(), and BinaryModelWriter::writeVertices(). 01585 {
01586 LE_TO_CPU_INT32(val, val);
01587 out.write(reinterpret_cast<char*>(&val), sizeof(uint32));
01588 }
|
|
|
Definition at line 28 of file modelfile.cpp. Referenced by BinaryModelLoader::loadMaterial(), AsciiModelLoader::loadMaterial(), BinaryModelWriter::writeMaterial(), and AsciiModelWriter::writeMaterial(). |
|
|
Definition at line 27 of file modelfile.cpp. Referenced by BinaryModelLoader::loadMaterial(), AsciiModelLoader::loadMaterial(), BinaryModelWriter::writeMaterial(), and AsciiModelWriter::writeMaterial(). |
1.4.1