
00001 //***************************************************************************** 00002 // File : gzDbManager_txp.h 00003 // Module : 00004 // Description : Class definition of the TerraPage format 00005 // Author : Anders Modén 00006 // Product : Gizmo3D 2.1.1 00007 // 00008 // Copyright © 2003- Saab Training Systems AB, Sweden 00009 // 00010 // NOTE: Gizmo3D is a high performance 3D Scene Graph and effect visualisation 00011 // C++ toolkit for Linux, Mac OS X, Windows (Win32) and IRIX® for 00012 // usage in Game or VisSim development. 00013 // 00014 // 00015 // Revision History... 00016 // 00017 // Who Date Description 00018 // 00019 // AMO 000226 Created file 00020 // 00021 //****************************************************************************** 00022 #ifndef __GZ_DB_TXP_H__ 00023 #define __GZ_DB_TXP_H__ 00024 00030 #include "gzNode.h" 00031 #include "gzGroup.h" 00032 #include "gzGeometry.h" 00033 00034 // UserData Db INFO attributes 00035 const gzString GZ_DB_INFO_TYPE_TERRAPAGE ="txp"; 00036 00037 class gzTxpTileOffset 00038 { 00039 public: 00040 00041 gzULong fileID; 00042 gzULong offset; 00043 }; 00044 00045 class gzTxpLodInfo 00046 { 00047 public: 00048 00049 gzLongXY size; 00050 00051 gzDouble range; 00052 00053 gzDoubleXY tileSize; 00054 00055 gzMatrix<gzTxpTileOffset> offsetInfo; 00056 00057 gzFloat elevMax; 00058 00059 gzFloat elevMin; 00060 }; 00061 00062 class gzTxpMaterial : public gzReference 00063 { 00064 public: 00065 00066 gzTxpMaterial(): 00067 texID(-1), 00068 texEnvMode(3), 00069 minFilter(1), 00070 magFilter(1) 00071 {}; 00072 00073 virtual ~gzTxpMaterial(){}; 00074 00075 gzRefPointer<gzMaterial> material; 00076 00077 gzRefPointer<gzTexture> texture; 00078 00079 gzVec4 color; 00080 00081 gzLong texID; 00082 00083 gzUByte texEnvMode:3; 00084 00085 gzUByte minFilter:3; 00086 00087 gzUByte magFilter:3; 00088 00089 gzUByte repeatS:1; 00090 00091 gzUByte repeatT:1; 00092 00093 gzUByte cullMode:2; 00094 00095 00096 }; 00097 00098 class gzTxpLocalMaterial : public gzReference 00099 { 00100 public: 00101 00102 gzTxpLocalMaterial(){}; 00103 virtual ~gzTxpLocalMaterial(){}; 00104 00105 gzInt baseMatTable; 00106 gzInt baseMat; 00107 00108 gzArray<gzULong> file; 00109 gzArray<gzULong> offset; 00110 00111 gzRefPointer<gzTexture> texture; 00112 00113 }; 00114 00115 class gzTxpTexture : public gzReference 00116 { 00117 public: 00118 00119 gzTxpTexture() {}; 00120 virtual ~gzTxpTexture() {}; 00121 00122 gzString image; 00123 gzBool isMipMap; 00124 gzUByte mode; 00125 gzUByte type; 00126 gzUByte layers; 00127 00128 gzULong sizeX; 00129 gzULong sizeY; 00130 00131 gzULong file; 00132 gzULong offset; 00133 00134 }; 00135 00136 00137 class gzTxpInfo : public gzReference 00138 { 00139 public: 00140 00141 gzTxpInfo(const gzString &dir): currentDirectory(dir) 00142 {}; 00143 00144 virtual ~gzTxpInfo(){}; 00145 00146 // All public valiables.... 00147 00148 gzLong numberOfLodLevels; 00149 gzLong numberOfMaterialTables; 00150 gzLong numberOfMaterialInTable; 00151 00152 gzDoubleXYZ origin; 00153 00154 gzDoubleXY sw; 00155 gzDoubleXY ne; 00156 00157 gzArray<gzTxpLodInfo> lodInfo; 00158 00159 gzLong numberOfSetLodLevels; 00160 00161 gzString currentDirectory; 00162 00163 gzArray<gzRefPointer<gzTxpMaterial> > materialArray; 00164 gzArray<gzRefPointer<gzTxpTexture> > textureArray; 00165 gzArray<gzRefPointer<gzNode> > modelArray; 00166 00167 // Shared states created out of materials 00168 gzArray<gzRefPointer<gzState> > stateArray; 00169 00170 gzUByte tileOriginType; 00171 00172 gzBool isArchived; 00173 00174 gzULong nodeIdBase; 00175 00176 gzDouble version; 00177 00178 gzRoi *roi; 00179 00180 gzArray< gzMatrix<gzRefPointer<gzRoiNode> > > nodes; 00181 gzArray< gzMatrix<gzRefPointer<gzRoiDependancyInterface> > > dependencies; 00182 }; 00183 00184 class gzTptInfo : public gzReference 00185 { 00186 public: 00187 00188 gzTptInfo(){}; 00189 00190 virtual ~gzTptInfo(){}; 00191 00192 gzULongXY pos; 00193 00194 gzDoubleXY center; 00195 00196 gzULong lodLevel; 00197 00198 gzDoubleXY size; 00199 00200 gzArray<gzRefPointer<gzTxpLocalMaterial> > localMaterialArray; 00201 gzArray<gzRefPointer<gzState> > stateArray; 00202 gzRefPointer<gzTxpLocalMaterial> currentLocalMaterial; 00203 00204 gzRoiNode *roiNode; 00205 }; 00206 00207 class gzDbManager_txp_reader : public gzProgressInterface 00208 { 00209 public: 00210 00211 gzDbManager_txp_reader(gzSerializeAdapter *adapter); 00212 00213 virtual ~gzDbManager_txp_reader(){}; 00214 00215 gzNode *loadDB(); 00216 00217 gzNode *loadTile(); 00218 00219 gzVoid setTxpInfo(gzTxpInfo *info); 00220 00221 private: 00222 00223 gzNode *buildRoiGroup(); 00224 00225 gzSerializeAdapter *m_adapter; 00226 gzULong m_fileSize; 00227 00228 // Common private methods 00229 00230 gzVoid processTokens(const gzULong & size); 00231 gzVoid processHeader(const gzULong & size); 00232 gzVoid processLodInfo(const gzULong & size); 00233 00234 gzVoid processMaterialTable(const gzULong & size); 00235 gzVoid processMaterialTable2(const gzULong & size); 00236 00237 gzVoid processBasicMaterial(const gzULong & size); 00238 gzVoid processShadeMaterial(const gzULong & size); 00239 gzVoid processSizeMaterial(const gzULong & size); 00240 gzVoid processCullMaterial(const gzULong & size); 00241 gzVoid processAlphaMaterial(const gzULong & size); 00242 gzVoid processNormalMaterial(const gzULong & size); 00243 gzVoid processTextureMaterial(const gzULong & size); 00244 gzVoid processBumpMaterial(const gzULong & size); 00245 gzVoid processAttrMaterial(const gzULong & size); 00246 00247 gzVoid processModeTexEnv(const gzULong & size); 00248 gzVoid processFilterTexEnv(const gzULong & size); 00249 gzVoid processWrapTexEnv(const gzULong & size); 00250 gzVoid processBorderTexEnv(const gzULong & size); 00251 00252 gzVoid processTexTable(const gzULong & size); 00253 gzVoid processTexture(const gzULong & size); 00254 00255 gzVoid processTexTable2(const gzULong & size); 00256 gzVoid processTexture2(const gzULong & size); 00257 00258 gzVoid processModelTable(const gzULong & size); 00259 gzVoid processModelRef(const gzULong & size); 00260 gzVoid processModelRefDef1(const gzULong & size); 00261 gzVoid processModelRefDef2(const gzULong & size); 00262 gzVoid processLight(const gzULong & size); 00263 gzVoid processLabel(const gzULong & size); 00264 gzVoid processTileTable2(const gzULong & size); 00265 gzVoid processLightTable(const gzULong & size); 00266 gzVoid processRangeTable(const gzULong & size); 00267 gzVoid processRange(const gzULong & size); 00268 gzVoid processTextStyleTable(const gzULong & size); 00269 gzVoid processTextStyle(const gzULong & size); 00270 00271 gzVoid processTileHeader(const gzULong & size); 00272 gzVoid processTileMaterialList(const gzULong & size); 00273 gzVoid processTileModelList(const gzULong & size); 00274 gzVoid processTileDate(const gzULong & size); 00275 gzVoid processTileLocalMaterialList(const gzULong & size); 00276 gzVoid processLocalMaterial(const gzULong & size); 00277 gzVoid processChildReference(const gzULong & size); 00278 00279 gzVoid processGroup(const gzULong & size); 00280 gzVoid processBillboard(const gzULong & size); 00281 gzVoid processAttach(const gzULong & size); 00282 gzVoid processLod(const gzULong & size); 00283 00284 gzVoid processGeometry(const gzULong & size); 00285 gzVoid processGeometryPrim(const gzULong & size); 00286 gzVoid processGeometryMaterial(const gzULong & size); 00287 gzVoid processGeometryVert32(const gzULong & size); 00288 gzVoid processGeometryVert64(const gzULong & size); 00289 gzVoid processGeometryNorm32(const gzULong & size); 00290 gzVoid processGeometryNorm64(const gzULong & size); 00291 gzVoid processGeometryColor(const gzULong & size); 00292 gzVoid processGeometryTex32(const gzULong & size); 00293 gzVoid processGeometryTex64(const gzULong & size); 00294 00295 00296 gzVoid processPush(); 00297 gzVoid processPop(); 00298 00299 00300 // Common serializers 00301 00302 gzSerializeBinary<gzULong> s_ulong; 00303 gzSerializeBinary<gzULongLong> s_ulonglong; 00304 gzSerializeBinary<gzULong> s_long; 00305 gzSerializeBinary<gzDouble> s_double; 00306 gzSerializeBinary<gzFloat> s_float; 00307 gzSerializeBinary<gzUByte> s_ubyte; 00308 00309 gzArray<gzUByte> s_data; 00310 gzSerializeString s_string; 00311 00312 // processed data 00313 00314 gzRefPointer<gzTxpInfo> m_txpInfo; 00315 00316 gzRefPointer<gzTptInfo> m_tptInfo; 00317 00318 // Work Data 00319 00320 gzVoid clean(); 00321 00322 gzRefPointer<gzGroup> currentParent; 00323 00324 gzRefPointer<gzNode> currentNode; 00325 00326 gzRefPointer<gzGroup> topGroup; 00327 00328 gzRefList<gzGroup> stack; 00329 00330 // Current geometry info 00331 00332 gzDynamicArray<gzULong> geoPrimLens; 00333 00334 gzDynamicArray<gzLong> geoPrimMaterials; 00335 00336 gzDynamicArray<gzVec3> geoPrimCoordinates; 00337 00338 gzDynamicArray<gzVec3> geoPrimNormals; 00339 00340 gzDynamicArray<gzVec4> geoPrimColors; 00341 00342 gzDynamicArray<gzDynamicArray<gzVec2> > geoPrimTexCoords; 00343 00344 gzGeoPrimType geoPrimType; 00345 00346 // State & Material 00347 00348 gzRefPointer<gzTxpMaterial> m_currentMaterial; 00349 gzRefPointer<gzTxpTexture> m_currentTexture; 00350 00351 }; 00352 00353 class gzDbManager_txp : public gzDbManager 00354 { 00355 public: 00356 00357 GZ_DB_EXPORT gzDbManager_txp(); 00358 GZ_DB_EXPORT virtual ~gzDbManager_txp(){}; 00359 00360 GZ_DB_EXPORT virtual gzNode * loadDB(gzSerializeAdapter *adapter); 00361 00362 //GZ_DB_EXPORT virtual gzBool saveDB(gzNode *node ,gzSerializeAdapter *adapter); 00363 00364 GZ_DB_EXPORT virtual gzString getExtensions(); 00365 00366 GZ_DB_EXPORT virtual gzULong getVersion(const gzString &extension); 00367 }; 00368 00369 class gzDbManager_tpt : public gzDbManager 00370 { 00371 public: 00372 00373 GZ_DB_EXPORT gzDbManager_tpt(); 00374 GZ_DB_EXPORT virtual ~gzDbManager_tpt(){}; 00375 00376 GZ_DB_EXPORT virtual gzNode * loadDB(gzSerializeAdapter *adapter); 00377 00378 //GZ_DB_EXPORT virtual gzBool saveDB(gzNode *node ,gzSerializeAdapter *adapter); 00379 00380 GZ_DB_EXPORT virtual gzString getExtensions(); 00381 00382 GZ_DB_EXPORT virtual gzULong getVersion(const gzString &extension); 00383 }; 00384 00385 #endif