| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | #ifndef _txpage_read_h_ |
|---|
| 17 | |
|---|
| 18 | #define _txpage_read_h_ |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #include <trpage_sys.h> |
|---|
| 25 | |
|---|
| 26 | #include <trpage_geom.h> |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | TX_EXDECL class TX_CLDECL trpgr_Callback |
|---|
| 33 | { |
|---|
| 34 | public: |
|---|
| 35 | virtual ~trpgr_Callback(void) { }; |
|---|
| 36 | virtual void *Parse(trpgToken,trpgReadBuffer &) { return (void *)1; }; |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | TX_EXDECL class TX_CLDECL trpgr_Token |
|---|
| 44 | { |
|---|
| 45 | public: |
|---|
| 46 | trpgr_Token(void); |
|---|
| 47 | trpgr_Token(int,trpgr_Callback *,bool destroy=true); |
|---|
| 48 | ~trpgr_Token(void); |
|---|
| 49 | void init(int,trpgr_Callback *,bool destroy=true); |
|---|
| 50 | int Token; |
|---|
| 51 | trpgr_Callback *cb; |
|---|
| 52 | bool destroy; |
|---|
| 53 | void Destruct(void); |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | TX_EXDECL class TX_CLDECL trpgr_Parser |
|---|
| 61 | { |
|---|
| 62 | public: |
|---|
| 63 | trpgr_Parser(void); |
|---|
| 64 | virtual ~trpgr_Parser(void); |
|---|
| 65 | bool isValid(void) const; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | virtual void AddCallback(trpgToken,trpgr_Callback *,bool destroy = true); |
|---|
| 69 | virtual void AddCallback(trpgToken,trpgReadWriteable *); |
|---|
| 70 | virtual const trpgr_Callback *GetCallback(trpgToken tok) const; |
|---|
| 71 | virtual trpgr_Callback *GetCallback(trpgToken tok); |
|---|
| 72 | virtual void RemoveCallback(trpgToken); |
|---|
| 73 | virtual void SetDefaultCallback(trpgr_Callback *,bool destroy = true); |
|---|
| 74 | |
|---|
| 75 | virtual bool Parse(trpgReadBuffer &); |
|---|
| 76 | virtual bool TokenIsValid(trpgToken); |
|---|
| 77 | protected: |
|---|
| 78 | void *lastObject; |
|---|
| 79 | private: |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | #if defined(_WIN32) |
|---|
| 83 | typedef std::map<trpgToken,trpgr_Token> tok_map; |
|---|
| 84 | #else |
|---|
| 85 | typedef std::map< trpgToken,trpgr_Token,std::less<trpgToken> > tok_map; |
|---|
| 86 | #endif |
|---|
| 87 | tok_map tokenMap; |
|---|
| 88 | trpgr_Token defCb; |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | class trpgwImageHelper; |
|---|
| 99 | TX_EXDECL class TX_CLDECL trpgrImageHelper |
|---|
| 100 | { |
|---|
| 101 | public: |
|---|
| 102 | trpgrImageHelper() {;}; |
|---|
| 103 | trpgrImageHelper(trpgEndian ness,char *dir,const trpgMatTable &,const trpgTexTable &,bool separateGeoTyp); |
|---|
| 104 | |
|---|
| 105 | virtual void Init(trpgEndian ness,char *dir,const trpgMatTable &,const trpgTexTable &,bool separateGeoTyp); |
|---|
| 106 | virtual ~trpgrImageHelper(void); |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | virtual bool GetLocalGL(const trpgTexture *,char *data,int32 dataSize); |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | virtual bool GetMipLevelLocalGL(int miplevel, const trpgTexture *,char *data,int32 dataSize); |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | virtual bool GetImageInfoForLocalMat(const trpgLocalMaterial *locMat, |
|---|
| 124 | const trpgMaterial **retMat,const trpgTexture **retTex, |
|---|
| 125 | int &totSize); |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | virtual bool GetNthImageInfoForLocalMat(const trpgLocalMaterial *locMat, int index, |
|---|
| 130 | const trpgMaterial **retMat,const trpgTexture **retTex, |
|---|
| 131 | int &totSize); |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | virtual bool GetImageForLocalMat(const trpgLocalMaterial *locMat,char *data,int dataSize); |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | virtual bool GetNthImageForLocalMat(const trpgLocalMaterial *locMat, int index, char *data,int dataSize); |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | virtual bool GetMipLevelForLocalMat(int miplevel, const trpgLocalMaterial *locMat,char *data,int dataSize); |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | virtual bool GetNthImageMipLevelForLocalMat(int miplevel, const trpgLocalMaterial *locMat, int index, char *data,int dataSize); |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | virtual bool GetImagePath(const trpgTexture *,char *,int len); |
|---|
| 158 | |
|---|
| 159 | virtual trpgrAppFileCache* GetNewRAppFileCache(const char *fullBase,const char *ext); |
|---|
| 160 | |
|---|
| 161 | trpgrAppFileCache *GetGeoTypCache() |
|---|
| 162 | { |
|---|
| 163 | return geotypCache; |
|---|
| 164 | } |
|---|
| 165 | void SetTexTable(trpgTexTable *texTable) |
|---|
| 166 | { |
|---|
| 167 | this->texTable = texTable; |
|---|
| 168 | } |
|---|
| 169 | protected: |
|---|
| 170 | char dir[1024]; |
|---|
| 171 | trpgEndian ness; |
|---|
| 172 | const trpgMatTable *matTable; |
|---|
| 173 | const trpgTexTable *texTable; |
|---|
| 174 | |
|---|
| 175 | trpgrAppFileCache *texCache; |
|---|
| 176 | trpgrAppFileCache *geotypCache; |
|---|
| 177 | bool separateGeoTyp; |
|---|
| 178 | }; |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | TX_EXDECL class TX_CLDECL trpgr_Archive : public trpgCheckable |
|---|
| 186 | { |
|---|
| 187 | public: |
|---|
| 188 | trpgr_Archive(void); |
|---|
| 189 | virtual ~trpgr_Archive(void); |
|---|
| 190 | |
|---|
| 191 | virtual void SetDirectory(const char *); |
|---|
| 192 | virtual bool OpenFile(const char *); |
|---|
| 193 | virtual void CloseFile(void); |
|---|
| 194 | virtual bool ReadHeader(void); |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | virtual bool ReadHeader(bool readAllBlocks); |
|---|
| 198 | bool ReadSubArchive(int row, int col, trpgEndian cpuNess); |
|---|
| 199 | |
|---|
| 200 | virtual bool ReadTile(uint32 x, uint32 y, uint32 lod,trpgMemReadBuffer &); |
|---|
| 201 | virtual bool ReadTile(const trpgwAppAddress& addr, trpgMemReadBuffer &buf); |
|---|
| 202 | virtual bool ReadExternalTile(uint32 x,uint32 y,uint32 lod,trpgMemReadBuffer &buf); |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | virtual const trpgHeader *GetHeader(void) const; |
|---|
| 206 | virtual const trpgMatTable *GetMaterialTable(void) const; |
|---|
| 207 | virtual trpgTexTable *GetTexTable(void) ; |
|---|
| 208 | virtual const trpgModelTable *GetModelTable(void) const; |
|---|
| 209 | virtual const trpgTileTable *GetTileTable(void) const; |
|---|
| 210 | virtual const trpgLightTable *GetLightTable(void) const; |
|---|
| 211 | virtual const trpgRangeTable *GetRangeTable(void) const; |
|---|
| 212 | virtual const trpgLabelPropertyTable *GetLabelPropertyTable() const; |
|---|
| 213 | virtual const trpgTextStyleTable *GetTextStyleTable() const; |
|---|
| 214 | virtual const trpgSupportStyleTable *GetSupportStyleTable() const; |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | virtual bool trpgGetTileMBR(uint32 x,uint32 y,uint32 lod, |
|---|
| 218 | trpg3dPoint &ll,trpg3dPoint &ur) const; |
|---|
| 219 | |
|---|
| 220 | trpgEndian GetEndian(void) const; |
|---|
| 221 | char* getDir(void){return dir;}; |
|---|
| 222 | virtual trpgrImageHelper* GetNewRImageHelper(trpgEndian ness,char *dir,const trpgMatTable &matTable,const trpgTexTable &texTable); |
|---|
| 223 | virtual trpgrAppFileCache* GetNewRAppFileCache(const char *fullBase, const char *ext); |
|---|
| 224 | virtual int32 GetHeaderData(char *dataPtr,int32 length,FILE *filehandle); |
|---|
| 225 | virtual int32 GetMagicNumber() {return TRPG_MAGIC;}; |
|---|
| 226 | protected: |
|---|
| 227 | bool headerRead; |
|---|
| 228 | trpgEndian ness; |
|---|
| 229 | FILE *fp; |
|---|
| 230 | int fid; |
|---|
| 231 | |
|---|
| 232 | char dir[1024]; |
|---|
| 233 | trpgHeader header; |
|---|
| 234 | trpgMatTable materialTable; |
|---|
| 235 | trpgTexTable texTable; |
|---|
| 236 | trpgModelTable modelTable; |
|---|
| 237 | trpgTileTable tileTable; |
|---|
| 238 | trpgLightTable lightTable; |
|---|
| 239 | trpgRangeTable rangeTable; |
|---|
| 240 | trpgTextStyleTable textStyleTable; |
|---|
| 241 | trpgSupportStyleTable supportStyleTable; |
|---|
| 242 | trpgLabelPropertyTable labelPropertyTable; |
|---|
| 243 | |
|---|
| 244 | trpgrAppFileCache *tileCache; |
|---|
| 245 | }; |
|---|
| 246 | |
|---|
| 247 | class trpgSceneHelperPush; |
|---|
| 248 | class trpgSceneHelperPop; |
|---|
| 249 | class trpgSceneHelperDefault; |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | |
|---|
| 256 | TX_EXDECL class TX_CLDECL trpgSceneParser : public trpgr_Parser |
|---|
| 257 | { |
|---|
| 258 | friend class trpgSceneHelperPush; |
|---|
| 259 | friend class trpgSceneHelperPop; |
|---|
| 260 | friend class trpgSceneHelperDefault; |
|---|
| 261 | public: |
|---|
| 262 | trpgSceneParser(void); |
|---|
| 263 | virtual ~trpgSceneParser(void); |
|---|
| 264 | protected: |
|---|
| 265 | |
|---|
| 266 | virtual bool StartChildren(void *) { return true;}; |
|---|
| 267 | virtual bool EndChildren(void *) { return true;}; |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | std::vector<void *> parents; |
|---|
| 271 | }; |
|---|
| 272 | |
|---|
| 273 | #endif |
|---|