00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _CIvfAc3DReader_h_
00026 #define _CIvfAc3DReader_h_
00027
00028 #include <ivffile/IvfFileReader.h>
00029
00030 #include <ivf/IvfComposite.h>
00031 #include <ivf/IvfPolySet.h>
00032 #include <ivf/IvfMaterialSet.h>
00033 #include <ivf/IvfLineStripSet.h>
00034 #include <ivf/IvfLighting.h>
00035
00036 #include <ivfmath/IvfVec3d.h>
00037
00038 #define OT_NONE -1
00039 #define OT_WORLD 0
00040 #define OT_POLY 1
00041 #define OT_GROUP 2
00042 #define OT_LIGHT 3
00043
00044 IvfSmartPointer(CIvfAc3DReader);
00045
00055 class IVFFILE_API CIvfAc3DReader : public CIvfFileReader {
00056 public:
00057 enum TSurfaceType {
00058 ST_POLY,
00059 ST_POLY_LINE
00060 };
00061 private:
00062 void clearVertexList();
00063 std::string m_row;
00064 long m_currentObject;
00065 unsigned char m_currentSurfaceType;
00066 long m_currentNumberOfKids;
00067 std::string m_currentName;
00068 long m_currentMaterialIdx;
00069 long m_kidsLeft;
00070
00071 TSurfaceType m_surfaceType;
00072
00073 CIvfCompositePtr m_world;
00074 CIvfCompositePtr m_currentGroup;
00075 CIvfMaterialPtr m_currentMaterial;
00076 CIvfPolySetPtr m_currentPolySet;
00077 CIvfLightPtr m_currentLight;
00078 CIvfLineStripSetPtr m_currentLineStripSet;
00079 CIvfIndexPtr m_currentIndex;
00080 CIvfMaterialSetPtr m_materialSet;
00081 CIvfShapePtr m_currentShape;
00082 CIvfTexturePtr m_lastTexture;
00083 CIvfLightingPtr m_lighting;
00084
00085 std::vector<CIvfVec3dPtr> m_vertexList;
00086
00087 int m_lightCount;
00088
00089 CIvfCompositePtr m_groupStack[100];
00090 int m_childStack[100];
00091 int m_currentLevel;
00092
00093 bool m_haveKids;
00094 bool m_haveGeometry;
00095
00096 double m_currentPos[3];
00097
00098 int m_surfacesRead;
00099
00100 int m_currentTextureIndex;
00101
00102 double m_texrep[2];
00103
00104
00105 int m_nSurfaces;
00106
00107 bool checkHeader(std::istream &in);
00108 bool readData(std::istream &in);
00109
00110 int getOptionalKeyword(std::string &row);
00111 int getKeyword(std::string &row);
00112
00113 bool parseObject(std::string &row);
00114 bool parseMaterial(std::string &row);
00115 bool parseKids(std::string &row);
00116 bool parseRefs(std::string &row, std::istream &in);
00117 bool parseMat(std::string &row);
00118 bool parseNumsurf(std::string &row);
00119 bool parseNumvert(std::string &row, std::istream &in);
00120 bool parseUrl(std::string &row);
00121 bool parseLoc(std::string &row);
00122 bool parseRot(std::string &row);
00123 bool parseTexture(std::string &row);
00124 bool parseData(std::string &row);
00125 bool parseName(std::string &row);
00126 bool parseSurf(std::string &row);
00127 bool parseTexrep(std::string &row);
00128
00129 bool haveMoreChildren();
00130 void decChild();
00131 CIvfComposite* currentGroup();
00132 void popGroup();
00133 void pushGroup(CIvfComposite* group);
00134 void initGroupStack();
00135 public:
00137 CIvfAc3DReader();
00138
00140 virtual ~CIvfAc3DReader();
00141
00142 IvfClassInfo("CIvfAc3DReader",CIvfFileReader);
00143
00145 virtual void read();
00146 };
00147
00150 #endif