00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _CELMESH_MODELFILE_H_
00011 #define _CELMESH_MODELFILE_H_
00012
00013 #include "model.h"
00014 #include <iostream>
00015 #include <string>
00016
00017 #define CEL_MODEL_HEADER_LENGTH 16
00018 #define CEL_MODEL_HEADER_ASCII "#celmodel__ascii"
00019 #define CEL_MODEL_HEADER_BINARY "#celmodel_binary"
00020
00021 class ModelLoader
00022 {
00023 public:
00024 ModelLoader();
00025 virtual ~ModelLoader();
00026
00027 virtual Model* load() = 0;
00028
00029 const std::string& getErrorMessage() const;
00030 void setTexturePath(const std::string&);
00031 const std::string& getTexturePath() const;
00032
00033 static ModelLoader* OpenModel(std::istream& in);
00034
00035 protected:
00036 virtual void reportError(const std::string&);
00037
00038 private:
00039 std::string errorMessage;
00040 std::string texPath;
00041 };
00042
00043
00044 class ModelWriter
00045 {
00046 public:
00047 virtual ~ModelWriter() {};
00048
00049 virtual bool write(const Model&) = 0;
00050 };
00051
00052
00053
00054 Model* LoadModel(std::istream&);
00055 Model* LoadModel(std::istream& in, const std::string& texPath);
00056
00057 bool SaveModelAscii(const Model* model, std::ostream& out);
00058 bool SaveModelBinary(const Model* model, std::ostream& out);
00059
00060
00061
00062 enum ModelFileToken
00063 {
00064 CMOD_Material = 1001,
00065 CMOD_EndMaterial = 1002,
00066 CMOD_Diffuse = 1003,
00067 CMOD_Specular = 1004,
00068 CMOD_SpecularPower = 1005,
00069 CMOD_Opacity = 1006,
00070 CMOD_Texture = 1007,
00071 CMOD_Mesh = 1009,
00072 CMOD_EndMesh = 1010,
00073 CMOD_VertexDesc = 1011,
00074 CMOD_EndVertexDesc = 1012,
00075 CMOD_Vertices = 1013,
00076 CMOD_Emissive = 1014,
00077 };
00078
00079 enum ModelFileType
00080 {
00081 CMOD_Float1 = 1,
00082 CMOD_Float2 = 2,
00083 CMOD_Float3 = 3,
00084 CMOD_Float4 = 4,
00085 CMOD_String = 5,
00086 CMOD_Uint32 = 6,
00087 CMOD_Color = 7,
00088 };
00089
00090 #endif // !_CELMESH_MODELFILE_H_