diff --git a/src/osgPlugins/txp/ReaderWriterTXP.cpp b/src/osgPlugins/txp/ReaderWriterTXP.cpp index 0db658d92..5b1e20b3e 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.cpp +++ b/src/osgPlugins/txp/ReaderWriterTXP.cpp @@ -670,16 +670,16 @@ public: { for (unsigned int i = 0; i < group.getNumChildren(); i++) { - osg::Node* child = group.getChild(i); - osg::Node* seam = seamReplacement(child); - if (child != seam) - { - group.replaceChild(child,seam); - } - else - { - child->accept(*this); - } + osg::Node* child = group.getChild(i); + osg::Node* seam = seamReplacement(child); + if (child != seam) + { + group.replaceChild(child,seam); + } + else + { + child->accept(*this); + } } } @@ -720,10 +720,10 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node) bool nonSeamChild = true; - // looks like the problem is in here - likely due to seamLOD info - // not being adjusted properly in tiled databases - // seam center is outside the bounding box of the tile - osg::Vec3 lodCenter = lod->getCenter(); + // looks like the problem is in here - likely due to seamLOD info + // not being adjusted properly in tiled databases + // seam center is outside the bounding box of the tile + osg::Vec3 lodCenter = lod->getCenter(); if(tileType == trpgHeader::TileLocal) { @@ -739,7 +739,7 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node) tileExtents.y /= divider; offset[0] = _x*tileExtents.x;// + tileExtents.x*0.5; offset[1] = _y*tileExtents.y;// + tileExtents.y*0.5; - lodCenter += offset; + lodCenter += offset; } if (!_info.bbox.contains(lodCenter)) @@ -764,7 +764,6 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node) // low res seam has min/max ranges of lod+1 range/lod 0 range if (equalDoubles(lod_plus_oneSwitchInDistance,rangeList.at(0).first) && equalDoubles(lod0SwitchInDistance,rangeList.at(0).second)) { - if (loRes==0) { loRes = lod; @@ -793,7 +792,7 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node) int dx = 0; int dy = 0; int lod = _lod; - osg::Vec3 lodCenter = loRes->getCenter(); + osg::Vec3 lodCenter = loRes->getCenter(); if(tileType == trpgHeader::TileLocal) { @@ -809,7 +808,7 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node) tileExtents.y /= divider; offset[0] = _x*tileExtents.x;// + tileExtents.x*0.5; offset[1] = _y*tileExtents.y;// + tileExtents.y*0.5; - lodCenter += offset; + lodCenter += offset; } osg::Vec3 delta = lodCenter-_info.center; @@ -829,7 +828,7 @@ osg::Node* SeamFinder::seamReplacement(osg::Node* node) } TXPSeamLOD* seam = new TXPSeamLOD(_x, _y, lod, dx, dy); - seam->setCenter(loRes->getCenter()); + seam->setCenter(loRes->getCenter()); seam->addChild(loRes->getChild(0)); // low res if (hiRes) { diff --git a/src/osgPlugins/txp/TXPArchive.h b/src/osgPlugins/txp/TXPArchive.h index a9ee477f7..550d4b75b 100644 --- a/src/osgPlugins/txp/TXPArchive.h +++ b/src/osgPlugins/txp/TXPArchive.h @@ -55,231 +55,231 @@ namespace txp // this one handles different placement of light direction in osg and terrapage struct DeferredLightAttribute { - // light point at (0,0,0) looking in (0,0,0) direction - osg::ref_ptr lightPoint; - osg::ref_ptr fallback; - osg::Vec3 attitude; + // light point at (0,0,0) looking in (0,0,0) direction + osg::ref_ptr lightPoint; + osg::ref_ptr fallback; + osg::Vec3 attitude; }; class TXPParser; class TXPArchive : public trpgr_Archive, public osg::Referenced { public: - // Constructor - TXPArchive(); - - // Opens the archive file and reads the header - bool openFile(const std::string& archiveName); - // Load the materials from the archve - bool loadMaterials(); - bool loadMaterial(int ix); - bool loadTexture(int i); - - // Load the models from the archive - bool loadModels(); - bool loadModel(int ix); - - // Load the light attribs from the archive - bool loadLightAttributes(); + // Constructor + TXPArchive(); - // Load the text styles from the archive - bool loadTextStyles(); - inline std::map >& getStyles() - { - return _fonts; - } - inline std::map& getTextColors() - { - return _fcolors; - } - - // Add light attrib - void addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback , const osg::Vec3& attitude,int handle); - - int getNumLightAttributes() - { - return _lights.size(); - } + // Opens the archive file and reads the header + bool openFile(const std::string& archiveName); + // Load the materials from the archve + bool loadMaterials(); + bool loadMaterial(int ix); + bool loadTexture(int i); - // Get light attrib - inline DeferredLightAttribute& getLightAttribute(unsigned int i) - { - return _lights[i]; - }; - - // Gets some informations for a given tile - struct TileInfo - { - osg::Vec3 center; - double minRange; - double maxRange; - double lod0Range; - float radius; - osg::Vec3 size; - osg::BoundingBox bbox; - }; - struct TileLocationInfo - { - TileLocationInfo() : x( -1 ), y( -1 ), lod( -1 ) - {} - TileLocationInfo(int gx, int gy, int glod, const trpgwAppAddress& gaddr, float gzmin = 0.0f, float gzmax = 0.0f): - x( gx ), y( gy ), lod( glod ), addr( gaddr ), zmin( gzmin ), zmax( gzmax ) - {} - int x, y, lod; - trpgwAppAddress addr; - float zmin, zmax; - }; + // Load the models from the archive + bool loadModels(); + bool loadModel(int ix); - bool getTileInfo(int x, int y, int lod, TileInfo& info); - bool getTileInfo(const TileLocationInfo& loc, TileInfo& info); - - // Set/Get the archive id - inline void setId(int id) - { - _id = id; - } - inline const int& getId() const - { - return _id; - } - - // Returns the number of LODs for this archive - inline const int& getNumLODs() const - { - return _numLODs; - } - - // Returns the extents of the archive + // Load the light attribs from the archive + bool loadLightAttributes(); + + // Load the text styles from the archive + bool loadTextStyles(); + inline std::map >& getStyles() + { + return _fonts; + } + inline std::map& getTextColors() + { + return _fcolors; + } + + // Add light attrib + void addLightAttribute(osgSim::LightPointNode* lpn, osg::StateSet* fallback , const osg::Vec3& attitude,int handle); + + int getNumLightAttributes() + { + return _lights.size(); + } + + // Get light attrib + inline DeferredLightAttribute& getLightAttribute(unsigned int i) + { + return _lights[i]; + }; + + // Gets some informations for a given tile + struct TileInfo + { + osg::Vec3 center; + double minRange; + double maxRange; + double lod0Range; + float radius; + osg::Vec3 size; + osg::BoundingBox bbox; + }; + struct TileLocationInfo + { + TileLocationInfo() : x( -1 ), y( -1 ), lod( -1 ) + {} + TileLocationInfo(int gx, int gy, int glod, const trpgwAppAddress& gaddr, float gzmin = 0.0f, float gzmax = 0.0f): + x( gx ), y( gy ), lod( glod ), addr( gaddr ), zmin( gzmin ), zmax( gzmax ) + {} + int x, y, lod; + trpgwAppAddress addr; + float zmin, zmax; + }; + + bool getTileInfo(int x, int y, int lod, TileInfo& info); + bool getTileInfo(const TileLocationInfo& loc, TileInfo& info); + + // Set/Get the archive id + inline void setId(int id) + { + _id = id; + } + inline const int& getId() const + { + return _id; + } + + // Returns the number of LODs for this archive + inline const int& getNumLODs() const + { + return _numLODs; + } + + // Returns the extents of the archive // FIXME - Needs to change for databases that aren't flat-earth void getExtents(osg::BoundingBox& extents); -// { -// extents.set(_swExtents.x,_swExtents.y,0.0f,_neExtents.x,_neExtents.y,0.0f); -// } - - // Returns the origin of the archive - inline void getOrigin(double& x, double& y) - { - x=_swExtents.x; - y=_swExtents.y; - } - - // Returns global texture - inline osg::Texture2D* getGlobalTexture(int id) - { - return GetTexMapEntry(id).get(); - } - - // Returns scenegraph representing the Tile. - // For version 2.1 and over this function can only be call - // with lod = 0, since the archive tile table will contain - // only tiles with lod = 0 - osg::Group* getTileContent( - int x, - int y, - int lod, - double realMinRange, - double realMaxRange, - double usedMaxRange, - osg::Vec3& tileCenter, - std::vector& childInfoList); + // { + // extents.set(_swExtents.x,_swExtents.y,0.0f,_neExtents.x,_neExtents.y,0.0f); + // } - // To be used for Version 2.1 with lod > 0 - osg::Group* getTileContent( - const TileLocationInfo& loc, - double realMinRange, - double realMaxRange, - double usedMaxRange, - osg::Vec3& tileCenter, - std::vector& childInfoList); + // Returns the origin of the archive + inline void getOrigin(double& x, double& y) + { + x=_swExtents.x; + y=_swExtents.y; + } - // Get the number of tiles for given LOD - bool getLODSize(int lod, int& x, int& y); + // Returns global texture + inline osg::Texture2D* getGlobalTexture(int id) + { + return GetTexMapEntry(id).get(); + } - void GetVersion(int& majorVer, int& minorVer) const - { - majorVer = _majorVersion; - minorVer = _minorVersion; - } - - ////////////////////////////////////////////////////////////////// - // This section brought to you by A. Danklefsen and the team @ - // Alion Science And Technology 2/12/07 - // - // This will allow you to have smc / fid / swc / stp values and - // places them on the userdata of the state set. this way your own - // terrain loader / parser can know these values - void SetUserDataToMaterialAttributes(osg::StateSet& osg_state_set, const trpgMaterial& mat) - { - if(!_loadMaterialsToStateSet) - return; + // Returns scenegraph representing the Tile. + // For version 2.1 and over this function can only be call + // with lod = 0, since the archive tile table will contain + // only tiles with lod = 0 + osg::Group* getTileContent( + int x, + int y, + int lod, + double realMinRange, + double realMaxRange, + double usedMaxRange, + osg::Vec3& tileCenter, + std::vector& childInfoList); - int attr_values = 0; - osg::ref_ptr ourValueArray = new osg::IntArray(); - for(int attrIter = 0 ; attrIter < 4; ++attrIter) - { - mat.GetAttr(attrIter, attr_values); - ourValueArray->push_back(attr_values); - } - osg_state_set.setUserData(ourValueArray.get()); - } + // To be used for Version 2.1 with lod > 0 + osg::Group* getTileContent( + const TileLocationInfo& loc, + double realMinRange, + double realMaxRange, + double usedMaxRange, + osg::Vec3& tileCenter, + std::vector& childInfoList); - void SetMaterialAttributesToStateSetVar(bool value) {_loadMaterialsToStateSet = value;} + // Get the number of tiles for given LOD + bool getLODSize(int lod, int& x, int& y); + + void GetVersion(int& majorVer, int& minorVer) const + { + majorVer = _majorVersion; + minorVer = _minorVersion; + } + + ////////////////////////////////////////////////////////////////// + // This section brought to you by A. Danklefsen and the team @ + // Alion Science And Technology 2/12/07 + // + // This will allow you to have smc / fid / swc / stp values and + // places them on the userdata of the state set. this way your own + // terrain loader / parser can know these values + void SetUserDataToMaterialAttributes(osg::StateSet& osg_state_set, const trpgMaterial& mat) + { + if(!_loadMaterialsToStateSet) + return; + + int attr_values = 0; + osg::ref_ptr ourValueArray = new osg::IntArray(); + for(int attrIter = 0 ; attrIter < 4; ++attrIter) + { + mat.GetAttr(attrIter, attr_values); + ourValueArray->push_back(attr_values); + } + osg_state_set.setUserData(ourValueArray.get()); + } + + void SetMaterialAttributesToStateSetVar(bool value) {_loadMaterialsToStateSet = value;} protected: - // Destructor - virtual ~TXPArchive(); - - // Id of the archive - int _id; - - // Number of the LODs - int _numLODs; - - // Archive extents - trpg2dPoint _swExtents; - trpg2dPoint _neExtents; - - // Terra Page Parser - osg::ref_ptr _parser; - - // Textures - typedef std::map > OSGTexMapType; - OSGTexMapType _texmap; + // Destructor + virtual ~TXPArchive(); - void SetTexMap(int key,osg::ref_ptr ref); - osg::ref_ptr GetTexMapEntry(int key); + // Id of the archive + int _id; - - // States - typedef std::map > OSGStatesMapType; - OSGStatesMapType _statesMap; + // Number of the LODs + int _numLODs; - void SetStatesMap(int key,osg::ref_ptr ref); - osg::ref_ptr GetStatesMapEntry(int key); - - // Models - typedef std::map > OSGModelsMapType; - OSGModelsMapType _models; - - // Light attributes vector - std::map _lights; + // Archive extents + trpg2dPoint _swExtents; + trpg2dPoint _neExtents; - // Text styles / Fonts - std::map > _fonts; + // Terra Page Parser + osg::ref_ptr _parser; - // Text colors - std::map _fcolors; + // Textures + typedef std::map > OSGTexMapType; + OSGTexMapType _texmap; - // - OpenThreads::Mutex _mutex; + void SetTexMap(int key,osg::ref_ptr ref); + osg::ref_ptr GetTexMapEntry(int key); - // Cache those: TerraPage version - int _majorVersion, _minorVersion; - bool _isMaster; - - bool _loadMaterialsToStateSet; + // States + typedef std::map > OSGStatesMapType; + OSGStatesMapType _statesMap; + + void SetStatesMap(int key,osg::ref_ptr ref); + osg::ref_ptr GetStatesMapEntry(int key); + + // Models + typedef std::map > OSGModelsMapType; + OSGModelsMapType _models; + + // Light attributes vector + std::map _lights; + + // Text styles / Fonts + std::map > _fonts; + + // Text colors + std::map _fcolors; + + // + OpenThreads::Mutex _mutex; + + // Cache those: TerraPage version + int _majorVersion, _minorVersion; + + bool _isMaster; + + bool _loadMaterialsToStateSet; }; diff --git a/src/osgPlugins/txp/TXPNode.cpp b/src/osgPlugins/txp/TXPNode.cpp index d6f0fb2d2..b55b16533 100644 --- a/src/osgPlugins/txp/TXPNode.cpp +++ b/src/osgPlugins/txp/TXPNode.cpp @@ -330,10 +330,10 @@ osg::Node* TXPNode::addPagedLODTile(int x, int y) } else { - _nodesToAdd.push_back(pagedLOD); - - return pagedLOD; -} + _nodesToAdd.push_back(pagedLOD); + + return pagedLOD; + } } void TXPNode::updateSceneGraph() diff --git a/src/osgPlugins/txp/trpage_compat.cpp b/src/osgPlugins/txp/trpage_compat.cpp index 8110a1793..f69f9ebaa 100644 --- a/src/osgPlugins/txp/trpage_compat.cpp +++ b/src/osgPlugins/txp/trpage_compat.cpp @@ -56,49 +56,50 @@ bool trpgMatTable1_0::Read(trpgReadBuffer &buf) std::vector baseMats; try { - buf.Get(numTable); - buf.Get(numMat); - if (numTable <= 0 || numMat < 0) throw 1; + buf.Get(numTable); + buf.Get(numMat); + if (numTable <= 0 || numMat < 0) throw 1; - // Short material tables are always full size - shortTable.resize(numTable*numMat); + // Short material tables are always full size + shortTable.resize(numTable*numMat); - // Look for short material table - buf.GetToken(matTok,len); - if (matTok == TRPGSHORTMATTABLE) { - int32 numTex,texId; - buf.PushLimit(len); - for (i=0;i<(unsigned int)numTable;i++) + // Look for short material table + buf.GetToken(matTok,len); + if (matTok == TRPGSHORTMATTABLE) { + int32 numTex,texId; + buf.PushLimit(len); + for (i=0;i<(unsigned int)numTable;i++) { for (j=0;j<(unsigned int)numMat;j++) { - trpgShortMaterial &smat = shortTable[i*numMat+j]; - buf.Get(smat.baseMat); - buf.Get(numTex); + trpgShortMaterial &smat = shortTable[i*numMat+j]; + buf.Get(smat.baseMat); + buf.Get(numTex); for (k=0;k<(unsigned int)numTex;k++) { - buf.Get(texId); - smat.texids.push_back(texId); + buf.Get(texId); + smat.texids.push_back(texId); + } + } + } + buf.PopLimit(); + + // Now read the base materials + int32 numBaseMat; + buf.Get(numBaseMat); + if (numBaseMat < 0) throw 1; + baseMats.resize(numBaseMat); + for (i=0;i<(unsigned int)numBaseMat;i++) { + buf.GetToken(matTok,len); + if (matTok != TRPGMATERIAL) throw 1; + buf.PushLimit(len); + mat.Reset(); + status = mat.Read(buf); + buf.PopLimit(); + if (!status) throw 1; + baseMats[i] = mat; } } - buf.PopLimit(); - - // Now read the base materials - int32 numBaseMat; - buf.Get(numBaseMat); - if (numBaseMat < 0) throw 1; - baseMats.resize(numBaseMat); - for (i=0;i<(unsigned int)numBaseMat;i++) { - buf.GetToken(matTok,len); - if (matTok != TRPGMATERIAL) throw 1; - buf.PushLimit(len); - mat.Reset(); - status = mat.Read(buf); - buf.PopLimit(); - if (!status) throw 1; - baseMats[i] = mat; - } - } } catch (...) { - return false; + return false; } // Now convert to the new style material table @@ -124,7 +125,7 @@ bool trpgMatTable1_0::Read(trpgReadBuffer &buf) bool trpgMatTable1_0::Write(trpgWriteBuffer &buf) { if (!isValid()) - return false; + return false; // Create one short material for every material std::vector shortMats; @@ -134,21 +135,21 @@ bool trpgMatTable1_0::Write(trpgWriteBuffer &buf) MaterialMapType::iterator itr = materialMap.begin(); for ( ; itr != materialMap.end( ); itr++) { - //for (i=0;isecond; //matTables[i]; - // Fill in the short material - trpgShortMaterial &sMat = shortMats[i]; - sMat.baseMat = 0; - int numTex; - mat.GetNumTexture(numTex); - for (int j=0;jsecond; //matTables[i]; + // Fill in the short material + trpgShortMaterial &sMat = shortMats[i]; + sMat.baseMat = 0; + int numTex; + mat.GetNumTexture(numTex); + for (int j=0;j(shortMats.size());i++) { - trpgShortMaterial &sMat = shortMats[i]; - buf.Add(sMat.baseMat); - buf.Add((int)(sMat.texids.size())); - unsigned int j; - for (j=0;jsecond; //matTables[i]; + trpgMaterial &mat = itr->second; //matTables[i]; - // This will be bigger than the old 1.0 material, but it doesn't matter since - // the new stuff is on the end. - mat.Write(buf); + // This will be bigger than the old 1.0 material, but it doesn't matter since + // the new stuff is on the end. + mat.Write(buf); } // Close Mat Table @@ -199,13 +200,13 @@ bool trpgTexture1_0::Read(trpgReadBuffer &buf) mode = External; try { - char texName[1024]; - buf.Get(texName,1023); - SetName(texName); - buf.Get(useCount); + char texName[1024]; + buf.Get(texName,1023); + SetName(texName); + buf.Get(useCount); } catch (...) { - return false; + return false; } return true; @@ -215,7 +216,7 @@ bool trpgTexture1_0::Write(trpgWriteBuffer &buf) { // Can only deal with external textures in 1.0 if (mode != External) - return false; + return false; // Write the name and use count buf.Add(name); @@ -256,7 +257,7 @@ bool trpgTexTable1_0::Write(trpgWriteBuffer &buf) int32 numTex; if (!isValid()) - return false; + return false; buf.Begin(TRPGTEXTABLE); @@ -264,10 +265,10 @@ bool trpgTexTable1_0::Write(trpgWriteBuffer &buf) buf.Add(numTex); TextureMapType::const_iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { - trpgTexture1_0 tex1_0; - tex1_0 = itr->second; - if (!tex1_0.Write(buf)) - return false; + trpgTexture1_0 tex1_0; + tex1_0 = itr->second; + if (!tex1_0.Write(buf)) + return false; } buf.End(); @@ -283,12 +284,12 @@ trpgTileTable1_0::trpgTileTable1_0(const trpgTileTable& /*inTable*/) bool trpgTileTable1_0::Write(trpgWriteBuffer &buf) { try { - buf.Begin(TRPGTILETABLE); - buf.Add(""); - buf.End(); + buf.Begin(TRPGTILETABLE); + buf.Add(""); + buf.End(); } catch (...) { - return false; + return false; } return true; diff --git a/src/osgPlugins/txp/trpage_geom.h b/src/osgPlugins/txp/trpage_geom.h index 5648441fb..47c8b68f1 100644 --- a/src/osgPlugins/txp/trpage_geom.h +++ b/src/osgPlugins/txp/trpage_geom.h @@ -47,7 +47,7 @@ class trpgMatTable; */ TX_EXDECL class TX_CLDECL trpgHeader : public trpgReadWriteable { - public: +public: trpgHeader(void); ~trpgHeader(void); @@ -181,43 +181,43 @@ TX_EXDECL class TX_CLDECL trpgHeader : public trpgReadWriteable void SetMaster(bool isMaster) { - if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR)) - { - if(isMaster) - flags |= ISMASTER;//set the master flag - else - flags &= ~ISMASTER;//clear the master flag - } + if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR)) + { + if(isMaster) + flags |= ISMASTER;//set the master flag + else + flags &= ~ISMASTER;//clear the master flag + } } bool GetIsMaster() const { - return ((flags & ISMASTER)==ISMASTER); + return ((flags & ISMASTER)==ISMASTER); } void SetLocal(bool isLocal) { - if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR)) - { - if(isLocal) - flags |= ISLOCAL;//set the local flag - else - flags &= ~ISLOCAL;//clear the local flag - } + if((verMajor >= TRPG_NOMERGE_VERSION_MAJOR) && (verMinor >=TRPG_NOMERGE_VERSION_MINOR)) + { + if(isLocal) + flags |= ISLOCAL;//set the local flag + else + flags &= ~ISLOCAL;//clear the local flag + } } bool GetIsLocal() const { - return ((flags & ISLOCAL)==ISLOCAL); + return ((flags & ISLOCAL)==ISLOCAL); } void SetBlocks(int rows,int cols) { - this->rows = rows; - this->cols = cols; + this->rows = rows; + this->cols = cols; } void GetBlocks(int &rows,int &cols) { - rows = this->rows; - cols = this->cols; + rows = this->rows; + cols = this->cols; } - protected: +protected: int verMinor,verMajor; int dbVerMinor,dbVerMajor; int maxGroupID; @@ -249,7 +249,7 @@ TX_EXDECL class TX_CLDECL trpgHeader : public trpgReadWriteable TX_EXDECL class TX_CLDECL trpgTextureEnv : public trpgReadWriteable { friend class trpgMatTable; - public: +public: trpgTextureEnv(void); ~trpgTextureEnv(void); @@ -308,7 +308,7 @@ TX_EXDECL class TX_CLDECL trpgTextureEnv : public trpgReadWriteable // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int envMode; int minFilter; int magFilter; @@ -345,7 +345,7 @@ TX_EXDECL class TX_CLDECL trpgTextureEnv : public trpgReadWriteable TX_EXDECL class TX_CLDECL trpgMaterial : public trpgReadWriteable { friend class trpgMatTable; - public: +public: trpgMaterial(void); ~trpgMaterial(void); // Set base material color @@ -494,7 +494,7 @@ TX_EXDECL class TX_CLDECL trpgMaterial : public trpgReadWriteable // Note: Need to do equality operator - protected: +protected: bool isBump; trpgColor color; trpgColor ambient; @@ -531,7 +531,7 @@ TX_EXDECL class TX_CLDECL trpgMaterial : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLightAttr : public trpgReadWriteable { - public: +public: // Default constructor trpgLightAttr(void); // Copy constructor @@ -542,89 +542,89 @@ TX_EXDECL class TX_CLDECL trpgLightAttr : public trpgReadWriteable // Light Flags enum { - // Light flags - trpg_Day = 0x0001, - trpg_Dusk = 0x0002, - trpg_Night = 0x0004, - trpg_Directional = 0x0008, - trpg_BackColor = 0x0010, - trpg_Reflective = 0x0020, + // Light flags + trpg_Day = 0x0001, + trpg_Dusk = 0x0002, + trpg_Night = 0x0004, + trpg_Directional = 0x0008, + trpg_BackColor = 0x0010, + trpg_Reflective = 0x0020, - // Animation flags - trpg_Flashing = 0x0100, - trpg_Rotating = 0x0200, - trpg_ClockWise = 0x0400, - trpg_AnimationMask = 0x0f00, + // Animation flags + trpg_Flashing = 0x0100, + trpg_Rotating = 0x0200, + trpg_ClockWise = 0x0400, + trpg_AnimationMask = 0x0f00, - // Performer light flags - trpg_Perspective = 0x1000, - trpg_Fade = 0x2000, - trpg_ZBuffer = 0x4000, - trpg_FogPunch = 0x8000, - trpg_PerformerMask = 0xf000 + // Performer light flags + trpg_Perspective = 0x1000, + trpg_Fade = 0x2000, + trpg_ZBuffer = 0x4000, + trpg_FogPunch = 0x8000, + trpg_PerformerMask = 0xf000 } LightFlags; // Light Type typedef enum { - trpg_Raster, - trpg_Calligraphic, - trpg_RASCAL + trpg_Raster, + trpg_Calligraphic, + trpg_RASCAL } LightType; // Light Directionality typedef enum { - trpg_Omnidirectional, - trpg_Bidirectional, - trpg_Unidirectional + trpg_Omnidirectional, + trpg_Bidirectional, + trpg_Unidirectional } LightDirectionality; // Light Quality typedef enum { - trpg_Off, - trpg_Low, - trpg_Medium, - trpg_High, - trpg_Undefined + trpg_Off, + trpg_Low, + trpg_Medium, + trpg_High, + trpg_Undefined } LightQuality; // Struct for Performer Lights struct PerformerAttr { - PerformerAttr() : flags(0),minPixelSize(0),maxPixelSize(0),actualSize(0), - transparentPixelSize(0),transparentFallofExp(0),transparentScale(0), - transparentClamp(0),fogScale(0) {}; - int32 flags; - float64 minPixelSize; - float64 maxPixelSize; - float64 actualSize; - float64 transparentPixelSize; - float64 transparentFallofExp; - float64 transparentScale; - float64 transparentClamp; - float64 fogScale; + PerformerAttr() : flags(0),minPixelSize(0),maxPixelSize(0),actualSize(0), + transparentPixelSize(0),transparentFallofExp(0),transparentScale(0), + transparentClamp(0),fogScale(0) {}; + int32 flags; + float64 minPixelSize; + float64 maxPixelSize; + float64 actualSize; + float64 transparentPixelSize; + float64 transparentFallofExp; + float64 transparentScale; + float64 transparentClamp; + float64 fogScale; }; // Struct for Animated Lights struct AnimationAttr { - AnimationAttr() : period(0),phaseDelay(0),timeOn(0),vector(trpg3dPoint(0,0,0)),flags(0) {}; - float64 period; - float64 phaseDelay; - float64 timeOn; - trpg3dPoint vector; - int32 flags; + AnimationAttr() : period(0),phaseDelay(0),timeOn(0),vector(trpg3dPoint(0,0,0)),flags(0) {}; + float64 period; + float64 phaseDelay; + float64 timeOn; + trpg3dPoint vector; + int32 flags; }; // Struct for Calligraphic Lights struct CalligraphicAttr { - CalligraphicAttr() : drawOrder(0),minDefocus(0),maxDefocus(0) {} ; - int32 drawOrder; - float64 minDefocus; - float64 maxDefocus; + CalligraphicAttr() : drawOrder(0),minDefocus(0),maxDefocus(0) {} ; + int32 drawOrder; + float64 minDefocus; + float64 maxDefocus; }; // Setters @@ -808,31 +808,31 @@ TX_EXDECL class TX_CLDECL trpgLightAttr : public trpgReadWriteable void Reset(void); - protected: +protected: struct DataSet { - LightType type; - LightDirectionality directionality; - trpgColor frontColor; - float64 frontIntensity; - trpgColor backColor; - float64 backIntensity; - trpg3dPoint normal; - int32 smc; - int32 fid; - int32 flags; - float64 horizontalLobeAngle; - float64 verticalLobeAngle; - float64 lobeRollAngle; - float64 lobeFalloff; - float64 ambientIntensity; - LightQuality quality; - LightQuality randomIntensity; - float64 rascalSignificance; - CalligraphicAttr calligraphicAttr; - PerformerAttr performerAttr; - AnimationAttr animationAttr; - char *commentStr; + LightType type; + LightDirectionality directionality; + trpgColor frontColor; + float64 frontIntensity; + trpgColor backColor; + float64 backIntensity; + trpg3dPoint normal; + int32 smc; + int32 fid; + int32 flags; + float64 horizontalLobeAngle; + float64 verticalLobeAngle; + float64 lobeRollAngle; + float64 lobeFalloff; + float64 ambientIntensity; + LightQuality quality; + LightQuality randomIntensity; + float64 rascalSignificance; + CalligraphicAttr calligraphicAttr; + PerformerAttr performerAttr; + AnimationAttr animationAttr; + char *commentStr; } data; }; @@ -843,7 +843,7 @@ TX_EXDECL class TX_CLDECL trpgLightAttr : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLight : public trpgReadWriteable { - public: +public: // Default constructor trpgLight(void); // Copy constructor @@ -890,7 +890,7 @@ TX_EXDECL class TX_CLDECL trpgLight : public trpgReadWriteable // operator trpgLight& operator = (const trpgLight &); - protected: +protected: // Here we store the light locations std::vector lightPoints; int index; @@ -902,7 +902,7 @@ TX_EXDECL class TX_CLDECL trpgLight : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLightTable : public trpgReadWriteable { - public: +public: // Default constructor trpgLightTable(void); @@ -947,7 +947,7 @@ TX_EXDECL class TX_CLDECL trpgLightTable : public trpgReadWriteable typedef std::map LightMapType; LightMapType *getLightMap() { return &lightMap; } - protected: +protected: // Here we store the light attributes //std::vector lightList; LightMapType lightMap; @@ -962,7 +962,7 @@ TX_EXDECL class TX_CLDECL trpgLightTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgRange : public trpgReadWriteable { - public: +public: trpgRange(void); ~trpgRange(void); @@ -1013,7 +1013,7 @@ TX_EXDECL class TX_CLDECL trpgRange : public trpgReadWriteable // Assignment operator trpgRange & operator = (const trpgRange &); - protected: +protected: double inLod,outLod; char *category; char *subCategory; @@ -1054,7 +1054,7 @@ TX_EXDECL class TX_CLDECL trpgRange : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgRangeTable : public trpgReadWriteable { - public: +public: trpgRangeTable(void); ~trpgRangeTable(void); @@ -1087,7 +1087,7 @@ TX_EXDECL class TX_CLDECL trpgRangeTable : public trpgReadWriteable // Assignment operator trpgRangeTable & operator = (const trpgRangeTable &); - protected: +protected: typedef std::map RangeMapType; RangeMapType rangeMap; //std::vector rangeList; @@ -1118,7 +1118,7 @@ TX_EXDECL class TX_CLDECL trpgRangeTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgMatTable : public trpgReadWriteable { - public: +public: trpgMatTable(void); ~trpgMatTable(void); /* If you intend to have more than one material sub-table you'll @@ -1189,7 +1189,7 @@ TX_EXDECL class TX_CLDECL trpgMatTable : public trpgReadWriteable bool Print(trpgPrintBuffer &) const; - protected: +protected: int numTable; int numMat; typedef std::map MaterialMapType; @@ -1225,7 +1225,7 @@ TX_EXDECL class TX_CLDECL trpgMatTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgTexture : public trpgReadWriteable { - public: +public: trpgTexture(void); trpgTexture(const trpgTexture &); ~trpgTexture(void); @@ -1251,26 +1251,26 @@ TX_EXDECL class TX_CLDECL trpgTexture : public trpgReadWriteable */ typedef enum { - trpg_RGB8, - trpg_RGBA8, - trpg_INT8, - trpg_INTA8, - trpg_FXT1, - trpg_Filler, // This is not a texture format. It's here to keep the numbering consistent - trpg_RGBX, // MCM no longer - trpg_Unknown, - trpg_DDS, - trpg_DXT1, - trpg_DXT3, - trpg_DXT5, - // This is a bit ugly, but we can't change the size of the texture record without - // breaking existing readers. So there will be multiple MCM types to indicate the number - // of bands and the nature of the extra channels, if any - trpg_MCM5, - trpg_MCM6R, - trpg_MCM6A, - trpg_MCM7RA, - trpg_MCM7AR + trpg_RGB8, + trpg_RGBA8, + trpg_INT8, + trpg_INTA8, + trpg_FXT1, + trpg_Filler, // This is not a texture format. It's here to keep the numbering consistent + trpg_RGBX, // MCM no longer + trpg_Unknown, + trpg_DDS, + trpg_DXT1, + trpg_DXT3, + trpg_DXT5, + // This is a bit ugly, but we can't change the size of the texture record without + // breaking existing readers. So there will be multiple MCM types to indicate the number + // of bands and the nature of the extra channels, if any + trpg_MCM5, + trpg_MCM6R, + trpg_MCM6A, + trpg_MCM7RA, + trpg_MCM7AR } ImageType; // Set the texture name. @@ -1374,7 +1374,7 @@ TX_EXDECL class TX_CLDECL trpgTexture : public trpgReadWriteable trpgTexture & operator = (const trpgTexture &); int operator == (const trpgTexture &) const; - protected: +protected: // Mode for this texture. See ImageMode for details ImageMode mode; @@ -1437,7 +1437,7 @@ TX_EXDECL class TX_CLDECL trpgTexture : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgTexTable : public trpgReadWriteable { - public: +public: trpgTexTable(void); trpgTexTable(const trpgTexTable &); ~trpgTexTable(void); @@ -1489,17 +1489,17 @@ TX_EXDECL class TX_CLDECL trpgTexTable : public trpgReadWriteable const trpgTexture *FindByName(const char *name, int &texid) const; void SetCurrentBlock(int row, int col) { - currentRow = row; - currentCol = col; + currentRow = row; + currentCol = col; } //bool dumpGeoTypicalTextures(trpgwImageHelper *ihelper); typedef std::map TextureMapType; TextureMapType *getTextureMap() { - return &textureMap; + return &textureMap; } - protected: +protected: TextureMapType textureMap; //These are used to initialize the row/col values for @@ -1537,7 +1537,7 @@ TX_EXDECL class TX_CLDECL trpgTexTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgModel : public trpgReadWriteable { - public: +public: trpgModel(void); trpgModel(const trpgModel &); ~trpgModel(void); @@ -1591,7 +1591,7 @@ TX_EXDECL class TX_CLDECL trpgModel : public trpgReadWriteable int operator == (const trpgModel &) const; - protected: +protected: int type; char *name; trpgDiskRef diskRef; @@ -1615,7 +1615,7 @@ TX_EXDECL class TX_CLDECL trpgModel : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgModelTable : public trpgReadWriteable { - public: +public: trpgModelTable(void); ~trpgModelTable(void); @@ -1661,9 +1661,9 @@ TX_EXDECL class TX_CLDECL trpgModelTable : public trpgReadWriteable typedef std::map ModelMapType; ModelMapType *GetModelMap() { - return &modelsMap; + return &modelsMap; } - protected: +protected: ModelMapType modelsMap; }; @@ -1679,7 +1679,7 @@ TX_EXDECL class TX_CLDECL trpgModelTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgTileTable : public trpgReadWriteable { - public: +public: // Tiles can be stored individually (External and ExternalSaved) or in grouped files (Local). // ExternalSaved still have an entry in the table. In this case the addess data is not valid. @@ -1722,23 +1722,23 @@ TX_EXDECL class TX_CLDECL trpgTileTable : public trpgReadWriteable **/ void SetCurrentBlock(int row, int col, bool local) { - currentRow = row; - currentCol = col; - localBlock = local; + currentRow = row; + currentCol = col; + localBlock = local; } - protected: +protected: TileMode mode; class LodInfo { - public: - int numX,numY; - // Tile addresses into external Appendable files - std::vector addr; - // Elevation of the midpoint of each tile - // This is used for calculating bounding boxes - std::vector elev_min; - std::vector elev_max; + public: + int numX,numY; + // Tile addresses into external Appendable files + std::vector addr; + // Elevation of the midpoint of each tile + // This is used for calculating bounding boxes + std::vector elev_min; + std::vector elev_max; }; std::vector lodInfo; //These are used to initialize the row/col values for @@ -1762,7 +1762,7 @@ TX_EXDECL class TX_CLDECL trpgTileTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLocalMaterial : public trpgReadWriteable { - public: +public: trpgLocalMaterial(void); ~trpgLocalMaterial(void); @@ -1787,9 +1787,9 @@ TX_EXDECL class TX_CLDECL trpgLocalMaterial : public trpgReadWriteable class SubImageInfo { public: - int32 sx,sy; // Source (sx,sy) in pixels - int32 ex,ey; // Source (ex,ey) in pixels - int32 destWidth,destHeight; // Size of destination image (in pixels) + int32 sx,sy; // Source (sx,sy) in pixels + int32 ex,ey; // Source (ex,ey) in pixels + int32 destWidth,destHeight; // Size of destination image (in pixels) }; // Set the sub image info (only for writers) @@ -1838,7 +1838,7 @@ TX_EXDECL class TX_CLDECL trpgLocalMaterial : public trpgReadWriteable // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int32 baseMatTable,baseMat; // These are valid for Global images int32 sx,sy,ex,ey,destWidth,destHeight; @@ -1897,7 +1897,7 @@ TX_EXDECL class TX_CLDECL trpgLocalMaterial : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgTileHeader : public trpgReadWriteable { - public: +public: trpgTileHeader(void); ~trpgTileHeader(void); /* Add the given material reference to this tile if it's not already there. @@ -1962,15 +1962,15 @@ TX_EXDECL class TX_CLDECL trpgTileHeader : public trpgReadWriteable bool Print(trpgPrintBuffer &) const; void SetBlockNo(int row, int col) { - this->row = row; - this->col = col; + this->row = row; + this->col = col; } void GetBlockNo(int &row, int &col) { - row = this->row; - col = this->col; + row = this->row; + col = this->col; } - protected: +protected: std::vector matList; std::vector modelList; std::vector locMats; @@ -1989,7 +1989,7 @@ TX_EXDECL class TX_CLDECL trpgTileHeader : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgColorInfo { - public: +public: trpgColorInfo(void); ~trpgColorInfo(void); @@ -2023,7 +2023,7 @@ TX_EXDECL class TX_CLDECL trpgColorInfo */ TX_EXDECL class TX_CLDECL trpgTexData { - public: +public: trpgTexData(void); ~trpgTexData(void); // This should always be set to PerVertex @@ -2075,7 +2075,7 @@ TX_EXDECL class TX_CLDECL trpgTexData */ TX_EXDECL class TX_CLDECL trpgGeometry : public trpgReadWriteable { - public: +public: trpgGeometry(void); ~trpgGeometry(void); typedef enum {Points,LineStrips,LineLoops,Lines,Polygons,TriStrips, @@ -2295,7 +2295,7 @@ TX_EXDECL class TX_CLDECL trpgGeometry : public trpgReadWriteable // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int primType; int numPrim; std::vector primLength; @@ -2339,7 +2339,7 @@ TX_EXDECL class TX_CLDECL trpgGeometry : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgGroup : public trpgReadWriteable { - public: +public: trpgGroup(void); virtual ~trpgGroup(void); // Resets the contents back to empty @@ -2372,7 +2372,7 @@ TX_EXDECL class TX_CLDECL trpgGroup : public trpgReadWriteable // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int id; int numChild; char* name; @@ -2440,7 +2440,7 @@ TX_EXDECL class TX_CLDECL trpgGroup : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgAttach : public trpgGroup { - public: +public: trpgAttach(void); ~trpgAttach(void); // Resets the contents back to empty @@ -2469,13 +2469,13 @@ TX_EXDECL class TX_CLDECL trpgAttach : public trpgGroup // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int parentID,childPos; }; TX_EXDECL class TX_CLDECL trpgChildRef : public trpgReadWriteable { - public: +public: trpgChildRef(); ~trpgChildRef(); // Resets the contents back to empty @@ -2505,7 +2505,7 @@ TX_EXDECL class TX_CLDECL trpgChildRef : public trpgReadWriteable // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: // Grid Location int x,y,lod; // File Location @@ -2532,7 +2532,7 @@ TX_EXDECL class TX_CLDECL trpgChildRef : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgBillboard : public trpgGroup { - public: +public: trpgBillboard(void); ~trpgBillboard(void); enum {Individual,Group}; @@ -2578,7 +2578,7 @@ TX_EXDECL class TX_CLDECL trpgBillboard : public trpgGroup bool Read(trpgReadBuffer &); // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int type; int mode; trpg3dPoint center; @@ -2625,7 +2625,7 @@ TX_EXDECL class TX_CLDECL trpgBillboard : public trpgGroup */ TX_EXDECL class TX_CLDECL trpgLod : public trpgReadWriteable { - public: +public: trpgLod(void); ~trpgLod(void); // Set the calculated center @@ -2669,7 +2669,7 @@ TX_EXDECL class TX_CLDECL trpgLod : public trpgReadWriteable // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: int numRange; double switchIn,switchOut,width; trpg3dPoint center; @@ -2699,7 +2699,7 @@ TX_EXDECL class TX_CLDECL trpgLod : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLayer : public trpgGroup { - public: +public: trpgLayer(void); ~trpgLayer(void); // Writes this class to a write buffer @@ -2711,7 +2711,7 @@ TX_EXDECL class TX_CLDECL trpgLayer : public trpgGroup // Resets the contents back to empty void Reset(void); - protected: +protected: }; /* This is pretty much a standard 4x4 static transform. It has a matrix @@ -2721,7 +2721,7 @@ TX_EXDECL class TX_CLDECL trpgLayer : public trpgGroup */ TX_EXDECL class TX_CLDECL trpgTransform : public trpgGroup { - public: +public: trpgTransform(void); ~trpgTransform(void); @@ -2740,7 +2740,7 @@ TX_EXDECL class TX_CLDECL trpgTransform : public trpgGroup // Resets the contents back to empty void Reset(void); - protected: +protected: float64 m[4][4]; }; @@ -2765,7 +2765,7 @@ TX_EXDECL class TX_CLDECL trpgTransform : public trpgGroup */ TX_EXDECL class TX_CLDECL trpgModelRef : public trpgReadWriteable { - public: +public: trpgModelRef(void); ~trpgModelRef(void); // Set the model ID. Must come from a trpgModelTable @@ -2787,7 +2787,7 @@ TX_EXDECL class TX_CLDECL trpgModelRef : public trpgReadWriteable // Resets the contents back to empty void Reset(void); - protected: +protected: int modelRef; float64 m[4][4]; }; @@ -2800,7 +2800,7 @@ TX_EXDECL class TX_CLDECL trpgModelRef : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgTextStyle : public trpgReadWriteable { - public: +public: trpgTextStyle(void); ~trpgTextStyle(void); @@ -2848,7 +2848,7 @@ TX_EXDECL class TX_CLDECL trpgTextStyle : public trpgReadWriteable // Return object validity bool isValid(void) const; - protected: +protected: std::string font; bool bold,italic,underline; float32 characterSize; @@ -2861,7 +2861,7 @@ TX_EXDECL class TX_CLDECL trpgTextStyle : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgTextStyleTable : public trpgReadWriteable { - public: +public: trpgTextStyleTable(void); ~trpgTextStyleTable(void); @@ -2889,7 +2889,7 @@ TX_EXDECL class TX_CLDECL trpgTextStyleTable : public trpgReadWriteable bool Print(trpgPrintBuffer &) const; typedef std::map StyleMapType; const StyleMapType *getStyleMap()const { return &styleMap; } - protected: +protected: //std::vector styles; StyleMapType styleMap; @@ -2903,7 +2903,7 @@ TX_EXDECL class TX_CLDECL trpgTextStyleTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgSupportStyle : public trpgReadWriteable { - public: +public: trpgSupportStyle(void); ~trpgSupportStyle(void); @@ -2939,7 +2939,7 @@ TX_EXDECL class TX_CLDECL trpgSupportStyle : public trpgReadWriteable // Return object validity bool isValid(void) const; - protected: +protected: SupportType type; int matId; }; @@ -2950,7 +2950,7 @@ TX_EXDECL class TX_CLDECL trpgSupportStyle : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgSupportStyleTable : public trpgReadWriteable { - public: +public: trpgSupportStyleTable(void); ~trpgSupportStyleTable(void); @@ -2977,7 +2977,7 @@ TX_EXDECL class TX_CLDECL trpgSupportStyleTable : public trpgReadWriteable // Print this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: //std::vector styles; typedef std::map SupportStyleMapType; SupportStyleMapType supportStyleMap; @@ -2991,7 +2991,7 @@ TX_EXDECL class TX_CLDECL trpgSupportStyleTable : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLabelProperty : public trpgReadWriteable { - public: +public: trpgLabelProperty(void); ~trpgLabelProperty(void); @@ -3032,7 +3032,7 @@ TX_EXDECL class TX_CLDECL trpgLabelProperty : public trpgReadWriteable // Return object validity bool isValid(void) const; - protected: +protected: int fontId; int supportId; LabelType type; @@ -3044,7 +3044,7 @@ TX_EXDECL class TX_CLDECL trpgLabelProperty : public trpgReadWriteable */ TX_EXDECL class TX_CLDECL trpgLabelPropertyTable : public trpgReadWriteable { - public: +public: trpgLabelPropertyTable(void); ~trpgLabelPropertyTable(void); @@ -3072,7 +3072,7 @@ TX_EXDECL class TX_CLDECL trpgLabelPropertyTable : public trpgReadWriteable // Print this class to a print buffer bool Print(trpgPrintBuffer &) const; - protected: +protected: //std::vector properties; typedef std::map LabelPropertyMapType; LabelPropertyMapType labelPropertyMap; @@ -3085,7 +3085,7 @@ TX_EXDECL class TX_CLDECL trpgLabelPropertyTable : public trpgReadWriteable over a specific building in a visual database. */ TX_EXDECL class TX_CLDECL trpgLabel : public trpgReadWriteable { - public: +public: trpgLabel(void); ~trpgLabel(void); @@ -3176,7 +3176,7 @@ TX_EXDECL class TX_CLDECL trpgLabel : public trpgReadWriteable { // Resets the contents back to empty void Reset(void); - protected: +protected: int propertyId; std::string text; // Actual label text. May contain formatting AlignmentType alignment; diff --git a/src/osgPlugins/txp/trpage_managers.cpp b/src/osgPlugins/txp/trpage_managers.cpp index c5dd99656..e3ae1a006 100644 --- a/src/osgPlugins/txp/trpage_managers.cpp +++ b/src/osgPlugins/txp/trpage_managers.cpp @@ -56,7 +56,7 @@ bool trpgManagedTile::ParseTileHeader(trpgReadBuffer &buf) { isLoaded = false; if (!tileHead.Read(buf)) - return false; + return false; int numLoc; tileHead.GetNumLocalMaterial(numLoc); @@ -79,7 +79,7 @@ bool trpgManagedTile::SetTileLoc(int inX,int inY,int inLod) location.x = inX; location.y = inY; if (inLod < 0) - return false; + return false; location.lod = inLod; return true; @@ -108,18 +108,18 @@ const trpgwAppAddress& trpgManagedTile::GetTileAddress() const bool trpgManagedTile::SetChildLocationInfo(int childIdx, int x, int y, const trpgwAppAddress& addr) { if(childIdx < 0) - throw std::invalid_argument( - "trpgManagedTile::SetChildLocationInfo(): index argument out of bound."); + throw std::invalid_argument( + "trpgManagedTile::SetChildLocationInfo(): index argument out of bound."); int size = childLocationInfo.size(); if(childIdx < size) - childLocationInfo[childIdx] = TileLocationInfo(x, y, location.lod+1, addr); + childLocationInfo[childIdx] = TileLocationInfo(x, y, location.lod+1, addr); else if(childIdx == size) - childLocationInfo.push_back(TileLocationInfo(x, y, location.lod+1, addr)); + childLocationInfo.push_back(TileLocationInfo(x, y, location.lod+1, addr)); else { - childLocationInfo.resize(childIdx+1); - childLocationInfo[childIdx] = TileLocationInfo(x, y, location.lod+1, addr); + childLocationInfo.resize(childIdx+1); + childLocationInfo[childIdx] = TileLocationInfo(x, y, location.lod+1, addr); } return true; @@ -127,18 +127,18 @@ bool trpgManagedTile::SetChildLocationInfo(int childIdx, int x, int y, const trp bool trpgManagedTile::SetChildLocationInfo(int childIdx, const TileLocationInfo& info) { if(childIdx < 0) - throw std::invalid_argument( - "trpgManagedTile::SetChildLocationInfo(): index argument out of bound."); + throw std::invalid_argument( + "trpgManagedTile::SetChildLocationInfo(): index argument out of bound."); int size = childLocationInfo.size(); if(childIdx < size) - childLocationInfo[childIdx] = info; + childLocationInfo[childIdx] = info; else if(childIdx == size) - childLocationInfo.push_back(info); + childLocationInfo.push_back(info); else { - childLocationInfo.resize(childIdx+1); - childLocationInfo[childIdx] = info; + childLocationInfo.resize(childIdx+1); + childLocationInfo[childIdx] = info; } return true; @@ -146,8 +146,8 @@ bool trpgManagedTile::SetChildLocationInfo(int childIdx, const TileLocationInfo& const TileLocationInfo& trpgManagedTile::GetChildLocationInfo(int childIdx) const { if(childIdx < 0 || childIdx >= (int)childLocationInfo.size()) - throw std::invalid_argument( - "trpgManagedTile::GetChildLocationInfo(): index argument out of bound."); + throw std::invalid_argument( + "trpgManagedTile::GetChildLocationInfo(): index argument out of bound."); return childLocationInfo[childIdx]; @@ -156,8 +156,8 @@ const TileLocationInfo& trpgManagedTile::GetChildLocationInfo(int childIdx) cons bool trpgManagedTile::GetChildTileLoc(int childIdx, int &x,int &y,int &lod) const { if(childIdx < 0 || childIdx >= (int)childLocationInfo.size()) - throw std::invalid_argument( - "trpgManagedTile::GetChildTileLoc(): index argument out of bound."); + throw std::invalid_argument( + "trpgManagedTile::GetChildTileLoc(): index argument out of bound."); TileLocationInfo const& info = childLocationInfo[childIdx]; x = info.x; @@ -170,8 +170,8 @@ bool trpgManagedTile::GetChildTileLoc(int childIdx, int &x,int &y,int &lod) cons const trpgwAppAddress& trpgManagedTile::GetChildTileAddress(int childIdx) const { if(childIdx < 0 || childIdx >= (int)childLocationInfo.size()) - throw std::invalid_argument( - "trpgManagedTile::GetChildTileAddress(): index argument out of bound."); + throw std::invalid_argument( + "trpgManagedTile::GetChildTileAddress(): index argument out of bound."); return childLocationInfo[childIdx].addr; } @@ -191,7 +191,7 @@ const trpgLocalMaterial *trpgManagedTile::GetLocMaterial(int id) const matList = tileHead.GetLocalMaterialList(); if (id <0 || id >= (int)matList->size()) - return NULL; + return NULL; return &(*matList)[id]; } @@ -209,7 +209,7 @@ void *trpgManagedTile::GetLocalData() const bool trpgManagedTile::SetMatData(int id,void *info) { if (id < 0 || id >= (int)localMatData.size()) - return false; + return false; localMatData[id] = info; @@ -219,7 +219,7 @@ bool trpgManagedTile::SetMatData(int id,void *info) void *trpgManagedTile::GetMatData(int id) const { if (id < 0 || id >= (int)localMatData.size()) - return NULL; + return NULL; return localMatData[id]; } @@ -263,19 +263,19 @@ void trpgPageManager::LodPageInfo::Clean() // Clean up managed tile structures unsigned int i; for (i=0;i= 1) - maxNumTiles = (int)(1.15*(2*aoiSize.x+1)*(2*aoiSize.y+1)/freeListDivider); + maxNumTiles = (int)(1.15*(2*aoiSize.x+1)*(2*aoiSize.y+1)/freeListDivider); else - maxNumTiles = (int)(1.15*(2*aoiSize.x+1)*(2*aoiSize.y+1)); + maxNumTiles = (int)(1.15*(2*aoiSize.x+1)*(2*aoiSize.y+1)); // Allocate 'em for (int i=0;i 0) { - activeLoad = true; - return load[0]; + activeLoad = true; + return load[0]; } return NULL; @@ -383,8 +383,8 @@ trpgManagedTile *trpgPageManager::LodPageInfo::GetNextLoad() void trpgPageManager::LodPageInfo::AckLoad() { if (activeLoad) { - current.push_back(load[0]); - load.pop_front(); + current.push_back(load[0]); + load.pop_front(); } activeLoad = false; } @@ -393,15 +393,15 @@ trpgManagedTile *trpgPageManager::LodPageInfo::GetNextUnload() { // Can only unload one tile at a time if (activeUnload) - return NULL; + return NULL; // Clear any NULLs at the beginning while (unload.size() && !unload[0]) - unload.pop_front(); + unload.pop_front(); if (unload.size() > 0) { - activeUnload = true; - return unload[0]; + activeUnload = true; + return unload[0]; } return NULL; @@ -410,10 +410,10 @@ trpgManagedTile *trpgPageManager::LodPageInfo::GetNextUnload() void trpgPageManager::LodPageInfo::AckUnload() { if (activeUnload) { - trpgManagedTile *tile = unload[0]; - tile->Reset(); - freeList.push_back(tile); - unload.pop_front(); + trpgManagedTile *tile = unload[0]; + tile->Reset(); + freeList.push_back(tile); + unload.pop_front(); } activeUnload = false; } @@ -424,11 +424,11 @@ bool trpgPageManager::LodPageInfo::isWithin(trpgManagedTile *tile,trpg2iPoint &s tile->GetTileLoc(tileX,tileY,tileLod); if (tileX >= sw.x && tileX <= ne.x && - tileY >= sw.y && + tileY >= sw.y && tileY <= ne.y) - return true; + return true; else - return false; + return false; } bool trpgPageManager::LodPageInfo::Stop() @@ -436,13 +436,13 @@ bool trpgPageManager::LodPageInfo::Stop() // Empty the load list unsigned int i; for (i=0;i 0); @@ -450,7 +450,7 @@ bool trpgPageManager::LodPageInfo::Stop() void trpgPageManager::LodPageInfo::AddChildrenToLoadList(std::vector& parentList) { if(parentList.size() == 0) - return; + return; // Area coverage, in cell unit trpg2iPoint sw,ne; @@ -470,50 +470,50 @@ void trpgPageManager::LodPageInfo::AddChildrenToLoadList(std::vectorGetTileLoc(tileX,tileY,tileLod); - tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; - } + trpgManagedTile *tile = current[i]; + if (tile) { + int tileX,tileY,tileLod; + tile->GetTileLoc(tileX,tileY,tileLod); + tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; + } } for (unsigned int i=0;iGetTileLoc(tileX,tileY,tileLod); - tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; - } + trpgManagedTile *tile = load[i]; + if (tile) { + int tileX,tileY,tileLod; + tile->GetTileLoc(tileX,tileY,tileLod); + tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; + } } for(unsigned int parentIdx = 0; parentIdx < parentList.size(); ++parentIdx) { - trpgManagedTile* parentTile = parentList[parentIdx]; - unsigned int nbChildren = parentTile->GetNbChildren(); + trpgManagedTile* parentTile = parentList[parentIdx]; + unsigned int nbChildren = parentTile->GetNbChildren(); - for(unsigned int childIdx = 0; childIdx < nbChildren; ++childIdx) { - - const TileLocationInfo& childLoc = parentTile->GetChildLocationInfo(childIdx); + for(unsigned int childIdx = 0; childIdx < nbChildren; ++childIdx) { - // a sanity check: if the lod is not the same then this - // parent is not at the right place - if(childLoc.lod != lod) - break; + const TileLocationInfo& childLoc = parentTile->GetChildLocationInfo(childIdx); - // Make sure it is within - if (childLoc.x >= sw.x && - childLoc.x <= ne.x && - childLoc.y >= sw.y && - childLoc.y <= ne.y) { - - // Is it alread there ? - if(!tmpCurrent[(childLoc.y - sw.y)*dx + (childLoc.x - sw.x)]) { - - // Not there, add it - AddToLoadList(childLoc.x, childLoc.y, childLoc.addr); + // a sanity check: if the lod is not the same then this + // parent is not at the right place + if(childLoc.lod != lod) + break; + + // Make sure it is within + if (childLoc.x >= sw.x && + childLoc.x <= ne.x && + childLoc.y >= sw.y && + childLoc.y <= ne.y) { + + // Is it alread there ? + if(!tmpCurrent[(childLoc.y - sw.y)*dx + (childLoc.x - sw.x)]) { + + // Not there, add it + AddToLoadList(childLoc.x, childLoc.y, childLoc.addr); + } + } } - } - } } } @@ -533,26 +533,26 @@ bool trpgPageManager::LodPageInfo::AddToLoadList(int x, int y, const trpgwAppAdd ne.y = MIN(lodSize.y-1,ne.y); if (x >= sw.x && - x <= ne.x && - y >= sw.y && - y <= ne.y) { + x <= ne.x && + y >= sw.y && + y <= ne.y) { - trpgManagedTile *tile = 0; - if(freeList.size() > 0){ + trpgManagedTile *tile = 0; + if(freeList.size() > 0){ - tile = freeList[0]; - freeList.pop_front(); + tile = freeList[0]; + freeList.pop_front(); + } + else + tile = new trpgManagedTile(); + tile->SetTileLoc(x, y, lod); + tile->SetTileAddress(addr); + load.push_back(tile); + + return true; } else - tile = new trpgManagedTile(); - tile->SetTileLoc(x, y, lod); - tile->SetTileAddress(addr); - load.push_back(tile); - - return true; - } - else - return false; + return false; } /* Update does the major work of figuring out what to load and @@ -576,10 +576,10 @@ void trpgPageManager::LodPageInfo::Update() */ unsigned int i; for (i=0;i= 1) { - // Version 2.1, we update only lod 0 since the tile table - // will only contain lod 0. All tiles from other lod must be - // update through the trpgPageManager::AckLoad(tile info) - if(lod != 0) - doUpdate = false; + // Version 2.1, we update only lod 0 since the tile table + // will only contain lod 0. All tiles from other lod must be + // update through the trpgPageManager::AckLoad(tile info) + if(lod != 0) + doUpdate = false; } if(doUpdate) { - // Sort the currently loaded stuff into a spatial array - // so we can figure out what needs to be loaded in addition. - int dx,dy; - dx = ne.x - sw.x+1; dy = ne.y - sw.y+1; - tmpCurrent.resize(dx*dy); - for (i=0;iGetTileLoc(tileX,tileY,tileLod); - tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; + // Sort the currently loaded stuff into a spatial array + // so we can figure out what needs to be loaded in addition. + int dx,dy; + dx = ne.x - sw.x+1; dy = ne.y - sw.y+1; + tmpCurrent.resize(dx*dy); + for (i=0;iGetTileLoc(tileX,tileY,tileLod); + tmpCurrent[(tileY-sw.y)*dx + (tileX-sw.x)] = true; + } } - } - // Now figure out which ones are missing and add them - // to the load list - for (int x=0;x 0) { - tile = freeList[0]; - freeList.pop_front(); - } else - tile = new trpgManagedTile(); - tile->SetTileLoc(x+sw.x,y+sw.y,lod); - trpgwAppAddress addr; - float32 zmin, zmax; + // Now figure out which ones are missing and add them + // to the load list + for (int x=0;x 0) { + tile = freeList[0]; + freeList.pop_front(); + } else + tile = new trpgManagedTile(); + tile->SetTileLoc(x+sw.x,y+sw.y,lod); + trpgwAppAddress addr; + float32 zmin, zmax; - if(tileTable && tileTable->GetTile(x+sw.x, y+sw.y, lod, addr, zmin, zmax)) - tile->SetTileAddress(addr); + if(tileTable && tileTable->GetTile(x+sw.x, y+sw.y, lod, addr, zmin, zmax)) + tile->SetTileAddress(addr); - load.push_back(tile); + load.push_back(tile); + } + } } - } - } } // That's it. All the rest is handled by the caller @@ -694,8 +694,8 @@ void trpgPageManager::LodPageInfo::GetLoadedTileWithin(double pagingDistance, st tileList.clear(); for (unsigned i=0; i Print(buf); + if (load[i]) + load[i]->Print(buf); buf.DecreaseIndent(); sprintf(line,"Unloads: (activeUnload = %s)",(activeUnload ? "yes" : "no")); buf.prnLine(line); buf.IncreaseIndent(); for (i=0;iPrint(buf); + if (unload[i]) + unload[i]->Print(buf); buf.DecreaseIndent(); buf.prnLine("Currently loaded:"); buf.IncreaseIndent(); for (i=0;iPrint(buf); + if (current[i]) + current[i]->Print(buf); buf.DecreaseIndent(); sprintf(line,"Free list size = %d", (int)freeList.size()); buf.prnLine(line); @@ -769,10 +769,10 @@ void trpgPageManager::Init(trpgr_Archive *inArch) valid = true; pageInfo.resize(numLod); for (int i=0;i 3) - pageInfo[i].Init(archive,i,scale, 4); - else - pageInfo[i].Init(archive,i,scale); + if(i > 3) + pageInfo[i].Init(archive,i,scale, 4); + else + pageInfo[i].Init(archive,i,scale); } } @@ -803,10 +803,10 @@ void trpgPageManager::Init(trpgr_Archive *inArch, int maxLod) valid = true; pageInfo.resize(maxLod); for (int i=0;i 3) - pageInfo[i].Init(archive,i,scale, 4); - else - pageInfo[i].Init(archive,i,scale); + if(i > 3) + pageInfo[i].Init(archive,i,scale, 4); + else + pageInfo[i].Init(archive,i,scale); } } @@ -814,7 +814,7 @@ bool trpgPageManager::SetPageDistFactor(double inFact) { // A scaling factor less than 1 will break the archive display. if (inFact <= 1.0) - return false; + return false; scale = inFact; @@ -825,42 +825,42 @@ bool trpgPageManager::SetLocation(trpg2dPoint &pt) { // Do a basic sanity check if (!valid || (pagePt.x == pt.x && pagePt.y == pt.y)) - return false; + return false; pagePt = pt; // Call each terrain LOD and let if figure out if something // has changed. bool change = false; for (unsigned int i=0;i= 1 && change) { - // Version 2.1 and over - // Since we don't have a tile table for lod > 0, - // we must rely on the parent to see if children - // tiles have to be loaded: - // First we get the list of parent tiles that falls - // in the area of interest of the children, - // Second we add to the load list all the parent's - // children that are no already part of the list + // Version 2.1 and over + // Since we don't have a tile table for lod > 0, + // we must rely on the parent to see if children + // tiles have to be loaded: + // First we get the list of parent tiles that falls + // in the area of interest of the children, + // Second we add to the load list all the parent's + // children that are no already part of the list - for(unsigned int lodIdx = 1; lodIdx < pageInfo.size(); ++lodIdx) { + for(unsigned int lodIdx = 1; lodIdx < pageInfo.size(); ++lodIdx) { - LodPageInfo& parentInfo = pageInfo[lodIdx -1]; - LodPageInfo& childInfo = pageInfo[lodIdx]; + LodPageInfo& parentInfo = pageInfo[lodIdx -1]; + LodPageInfo& childInfo = pageInfo[lodIdx]; - // Get the list of parents tile that are currently - // loaded in the children aoi - std::vector parentList; - parentInfo.GetLoadedTileWithin(childInfo.GetPageDistance(), parentList); - - // Add the children of those parents to the load list - // of the children info, if they are not already there - childInfo.AddChildrenToLoadList(parentList); - } + // Get the list of parents tile that are currently + // loaded in the children aoi + std::vector parentList; + parentInfo.GetLoadedTileWithin(childInfo.GetPageDistance(), parentList); + + // Add the children of those parents to the load list + // of the children info, if they are not already there + childInfo.AddChildrenToLoadList(parentList); + } } @@ -871,22 +871,22 @@ trpgManagedTile *trpgPageManager::GetNextLoad() { // If we're already doing something, let them know about it if (lastLoad != None) - throw 1; + throw 1; // Look for anything that needs loaded // Start with lowest LOD, work up to highest trpgManagedTile *tile = NULL; for (unsigned int i=0;ilocation.lod; + // Found one. Now the user has to load it. + if (tile) { + lastLoad = Load; + lastTile = tile; + lastLod = tile->location.lod; } return tile; @@ -901,26 +901,26 @@ void trpgPageManager::AckLoad(std::vector const& children) { // If we're not in the middle of a load, register our displeasure if (lastLoad != Load) - throw 1; + throw 1; if(majorVersion >= 2 && minorVersion >=1) { - if(children.size() > 0) - { - LodPageInfo& childInfo = pageInfo[lastLod+1]; - for(unsigned int idx = 0; idx < children.size(); ++idx) + if(children.size() > 0) { - TileLocationInfo const&childLocInfo = children[idx]; - if(childLocInfo.lod != lastLod+1) - continue; // Something wrong here - childInfo.AddToLoadList(childLocInfo.x, childLocInfo.y, childLocInfo.addr); + LodPageInfo& childInfo = pageInfo[lastLod+1]; + for(unsigned int idx = 0; idx < children.size(); ++idx) + { + TileLocationInfo const&childLocInfo = children[idx]; + if(childLocInfo.lod != lastLod+1) + continue; // Something wrong here + childInfo.AddToLoadList(childLocInfo.x, childLocInfo.y, childLocInfo.addr); - // Also save info in parent tile - lastTile->SetChildLocationInfo(idx, childLocInfo); + // Also save info in parent tile + lastTile->SetChildLocationInfo(idx, childLocInfo); + } } } - } pageInfo[lastLod].AckLoad(); lastLoad = None; @@ -937,7 +937,7 @@ void *trpgPageManager::GetGroupData(int groupID) { ManageGroupMap::const_iterator p = groupMap.find(groupID); if (p != groupMap.end()) - return (*p).second; + return (*p).second; return NULL; } @@ -946,22 +946,22 @@ trpgManagedTile *trpgPageManager::GetNextUnload() { // If we're already doing something, let them know about it if (lastLoad != None) - throw 1; + throw 1; // Look for anything that needs unloaded // Start with highest LOD, work down to lowest trpgManagedTile *tile = NULL; for (int i=pageInfo.size()-1;i>=0;i--) { - LodPageInfo &info = pageInfo[i]; - if ((tile = info.GetNextUnload())) - break; + LodPageInfo &info = pageInfo[i]; + if ((tile = info.GetNextUnload())) + break; } // Found one. Now the user has to unload it. if (tile) { - lastLoad = Unload; - lastTile = tile; - lastLod = tile->location.lod; + lastLoad = Unload; + lastTile = tile; + lastLod = tile->location.lod; } return tile; @@ -971,14 +971,14 @@ void trpgPageManager::AckUnload() { // If we're not in the middle of an unload, let 'em know. if (lastLoad != Unload) - throw 1; + throw 1; // Remove this tile's group IDs from the map const std::vector *groupIDs = lastTile->GetGroupIDs(); for (unsigned int i=0;isize();i++) { - ManageGroupMap::iterator p = groupMap.find((*groupIDs)[i]); - if (p != groupMap.end()) - groupMap.erase(p); + ManageGroupMap::iterator p = groupMap.find((*groupIDs)[i]); + if (p != groupMap.end()) + groupMap.erase(p); } LodPageInfo &info = pageInfo[lastLod]; @@ -991,7 +991,7 @@ bool trpgPageManager::Stop() { bool res=false; for (unsigned int i=0;i= childList.size()) - throw std::invalid_argument( - "trpgPageManageTester::ChildRefCB::GetChild(): index argument out of bound."); + throw std::invalid_argument( + "trpgPageManageTester::ChildRefCB::GetChild(): index argument out of bound."); else - return childList[idx]; + return childList[idx]; } /* Page Manager Tester @@ -1067,7 +1067,7 @@ void trpgPageManageTester::Init(trpgPrintBuffer *pBuf,trpgPageManager *pMan,trpg printBuf = pBuf; if (!archive->isValid()) - throw 1; + throw 1; const trpgHeader *header = archive->GetHeader(); header->GetVersion(majorVersion, minorVersion); @@ -1081,11 +1081,11 @@ void trpgPageManageTester::Init(trpgPrintBuffer *pBuf,trpgPageManager *pMan,trpg void trpgPageManageTester::RandomTest(int num,int seed) { if (!manager || !archive || !printBuf) - throw 1; + throw 1; // Seed the random number generator so we can replicate runs if (seed != -1) - srand(seed); + srand(seed); // Need the extents trpg2dPoint ll,ur,lod0Size; @@ -1101,20 +1101,20 @@ void trpgPageManageTester::RandomTest(int num,int seed) int i; char line[1024]; for (i=0;iSetLocation(pt); - sprintf(line,"Jumped to (%f,%f). Tiles to load/unload = %s",pt.x,pt.y, - (changes ? "yes" : "no")); printBuf->prnLine(line); + // Jump to the point + bool changes = manager->SetLocation(pt); + sprintf(line,"Jumped to (%f,%f). Tiles to load/unload = %s",pt.x,pt.y, + (changes ? "yes" : "no")); printBuf->prnLine(line); - // Process the results - ProcessChanges(); + // Process the results + ProcessChanges(); } // Ask the page manager for its final status @@ -1128,7 +1128,7 @@ void trpgPageManageTester::Fly_LL_to_UR(double dist) char line[1024]; if (!manager || !archive || !printBuf) - throw 1; + throw 1; // Need the extents trpg2dPoint ll,ur,lod0Size; @@ -1144,15 +1144,15 @@ void trpgPageManageTester::Fly_LL_to_UR(double dist) // Fly the path trpg2dPoint loc; loc = ll; do { - loc.x += dist; loc.y += dist; + loc.x += dist; loc.y += dist; - // Jump to next point - bool changes = manager->SetLocation(loc); - sprintf(line,"Moved to (%f,%f). Tiles to load/unload = %s",loc.x,loc.y, - (changes ? "yes" : "no")); printBuf->prnLine(line); + // Jump to next point + bool changes = manager->SetLocation(loc); + sprintf(line,"Moved to (%f,%f). Tiles to load/unload = %s",loc.x,loc.y, + (changes ? "yes" : "no")); printBuf->prnLine(line); - // Process new location - ProcessChanges(); + // Process new location + ProcessChanges(); } while (loc.x < ur.x && loc.y < ur.y); // Ask the page manager for its final status @@ -1171,9 +1171,9 @@ void trpgPageManageTester::ProcessChanges() printBuf->prnLine("Tiles to unload:"); printBuf->IncreaseIndent(); while ((unloadTile = manager->GetNextUnload())) { - unloadTile->GetTileLoc(x,y,lod); - sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); printBuf->prnLine(line); - manager->AckUnload(); + unloadTile->GetTileLoc(x,y,lod); + sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); printBuf->prnLine(line); + manager->AckUnload(); } printBuf->DecreaseIndent(); @@ -1182,45 +1182,45 @@ void trpgPageManageTester::ProcessChanges() printBuf->prnLine("Tiles to load:"); printBuf->IncreaseIndent(); while ((loadTile = manager->GetNextLoad())) { - loadTile->GetTileLoc(x,y,lod); - sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); printBuf->prnLine(line); + loadTile->GetTileLoc(x,y,lod); + sprintf(line,"x = %d, y = %d, lod = %d",x,y,lod); printBuf->prnLine(line); - if(majorVersion == 2 && minorVersion >= 1) - { - // Version 2.1 and over - // We need to parse the loaded tile to get all of its children info - const trpgwAppAddress& tileAddress = loadTile->GetTileAddress(); - trpgMemReadBuffer buf(archive->GetEndian()); - if(archive->ReadTile(tileAddress, buf)) + if(majorVersion == 2 && minorVersion >= 1) { - childRefCB.Reset(); - if(tileParser.Parse(buf)) - { - // childRefCB should now have alist of trpgChildRef found in the tile - unsigned int nbChildRef = childRefCB.GetNbChildren(); - if(nbChildRef > 0) + // Version 2.1 and over + // We need to parse the loaded tile to get all of its children info + const trpgwAppAddress& tileAddress = loadTile->GetTileAddress(); + trpgMemReadBuffer buf(archive->GetEndian()); + if(archive->ReadTile(tileAddress, buf)) { - std::vector locInfoList; - for(unsigned int idx = 0; idx < nbChildRef; ++idx) - { - const trpgChildRef& childRef = childRefCB.GetChildRef(idx); - locInfoList.push_back(TileLocationInfo()); - TileLocationInfo& locInfo = locInfoList.back(); - childRef.GetTileLoc(locInfo.x, locInfo.y, locInfo.lod); - childRef.GetTileAddress(locInfo.addr); - } + childRefCB.Reset(); + if(tileParser.Parse(buf)) + { + // childRefCB should now have alist of trpgChildRef found in the tile + unsigned int nbChildRef = childRefCB.GetNbChildren(); + if(nbChildRef > 0) + { + std::vector locInfoList; + for(unsigned int idx = 0; idx < nbChildRef; ++idx) + { + const trpgChildRef& childRef = childRefCB.GetChildRef(idx); + locInfoList.push_back(TileLocationInfo()); + TileLocationInfo& locInfo = locInfoList.back(); + childRef.GetTileLoc(locInfo.x, locInfo.y, locInfo.lod); + childRef.GetTileAddress(locInfo.addr); + } - manager->AckLoad(locInfoList); + manager->AckLoad(locInfoList); + } + else + manager->AckLoad(); + } } else - manager->AckLoad(); - } + manager->AckLoad(); } else - manager->AckLoad(); - } - else - manager->AckLoad(); + manager->AckLoad(); } printBuf->DecreaseIndent(); } diff --git a/src/osgPlugins/txp/trpage_managers.h b/src/osgPlugins/txp/trpage_managers.h index ed1a260a6..bcfa57e44 100644 --- a/src/osgPlugins/txp/trpage_managers.h +++ b/src/osgPlugins/txp/trpage_managers.h @@ -43,7 +43,7 @@ struct TileLocationInfo TX_EXDECL class TX_CLDECL trpgManagedTile { friend class trpgPageManager; - public: +public: trpgManagedTile(void); // Called to clear any info out of this tile @@ -136,7 +136,7 @@ TX_EXDECL class TX_CLDECL trpgManagedTile // Children info, will throw exception if child index is out of bound unsigned int GetNbChildren() const { - return (unsigned int)childLocationInfo.size(); + return (unsigned int)childLocationInfo.size(); } bool SetChildLocationInfo(int childIdx, int x, int y, const trpgwAppAddress& addr); bool SetChildLocationInfo(int childIdx, const TileLocationInfo& info); @@ -145,7 +145,7 @@ TX_EXDECL class TX_CLDECL trpgManagedTile const trpgwAppAddress& GetChildTileAddress(int childIdx) const; - protected: +protected: // Set if a tile is currently loaded bool isLoaded; // Tile location info @@ -178,7 +178,7 @@ TX_EXDECL class TX_CLDECL trpgManagedTile */ TX_EXDECL class TX_CLDECL trpgPageManager { - public: +public: trpgPageManager(void); virtual ~trpgPageManager(void); @@ -272,156 +272,156 @@ TX_EXDECL class TX_CLDECL trpgPageManager detail as related to paging. */ TX_EXDECL class TX_CLDECL LodPageInfo { - friend class trpgPageManager; + friend class trpgPageManager; public: - LodPageInfo(void); - virtual ~LodPageInfo(void); + LodPageInfo(void); + virtual ~LodPageInfo(void); - /* Initializes the class with its current LOD. - It figures out all the rest. - */ - virtual bool Init(trpgr_Archive *, int myLod, double scale, int freeListDivider = 1); + /* Initializes the class with its current LOD. + It figures out all the rest. + */ + virtual bool Init(trpgr_Archive *, int myLod, double scale, int freeListDivider = 1); - /* Reset the location. This forces a recalculation - of what to load and unload if the cell has changed - or if this is the first SetLocation. - The location passed in must be relative to the southwest - corner of the TerraPage archive. - */ - virtual bool SetLocation(trpg2dPoint &); + /* Reset the location. This forces a recalculation + of what to load and unload if the cell has changed + or if this is the first SetLocation. + The location passed in must be relative to the southwest + corner of the TerraPage archive. + */ + virtual bool SetLocation(trpg2dPoint &); - // Return the next tile to load for this terrain lod - virtual trpgManagedTile *GetNextLoad(void); - // Acknowledge the load. Move the active tile to the - // loaded list. - virtual void AckLoad(); + // Return the next tile to load for this terrain lod + virtual trpgManagedTile *GetNextLoad(void); + // Acknowledge the load. Move the active tile to the + // loaded list. + virtual void AckLoad(); - // Get the lsit of - //bool GetLoadedTile + // Get the lsit of + //bool GetLoadedTile - // Return the next tile to unload for this terrain lod - virtual trpgManagedTile *GetNextUnload(void); - // Acknowledge the unload. Move the active tile to the - // free list. - virtual void AckUnload(void); - // Called to stop paging. Everything active is dumped on - // the unload list. - virtual bool Stop(void); - // Print current status and content information - virtual void Print(trpgPrintBuffer &); + // Return the next tile to unload for this terrain lod + virtual trpgManagedTile *GetNextUnload(void); + // Acknowledge the unload. Move the active tile to the + // free list. + virtual void AckUnload(void); + // Called to stop paging. Everything active is dumped on + // the unload list. + virtual bool Stop(void); + // Print current status and content information + virtual void Print(trpgPrintBuffer &); - const trpg2iPoint& GetLodSize() const - { - return lodSize; - } + const trpg2iPoint& GetLodSize() const + { + return lodSize; + } - int GetLod() const - { - return lod; - } + int GetLod() const + { + return lod; + } - double GetPageDistance() const - { - return pageDist; - } + double GetPageDistance() const + { + return pageDist; + } - const trpg2dPoint& GetCellSize() const - { - return cellSize; - } + const trpg2dPoint& GetCellSize() const + { + return cellSize; + } - // The unit are cellSize - const trpg2iPoint& GetAreaOfInterest() const - { - return aoiSize; - } - + // The unit are cellSize + const trpg2iPoint& GetAreaOfInterest() const + { + return aoiSize; + } - // The middle of this cell correspond to our paging - // location - const trpg2iPoint& GetCellPagingLocation() const - { - return cell; - } + + // The middle of this cell correspond to our paging + // location + const trpg2iPoint& GetCellPagingLocation() const + { + return cell; + } protected: - virtual void Clean(void); - virtual void Update(void); + virtual void Clean(void); + virtual void Update(void); - // Add to the load list the given tile if it is within the proper - // bound - bool AddToLoadList(int x, int y, const trpgwAppAddress& addr); + // Add to the load list the given tile if it is within the proper + // bound + bool AddToLoadList(int x, int y, const trpgwAppAddress& addr); - // Add the children of the given parent list - // to the load list if it it not already loaded - // or if it is not already in the list - void AddChildrenToLoadList(std::vector& parentList); + // Add the children of the given parent list + // to the load list if it it not already loaded + // or if it is not already in the list + void AddChildrenToLoadList(std::vector& parentList); - // Check if the given tile is within the area we care about - bool isWithin(trpgManagedTile *,trpg2iPoint &sw,trpg2iPoint &ne); + // Check if the given tile is within the area we care about + bool isWithin(trpgManagedTile *,trpg2iPoint &sw,trpg2iPoint &ne); - // Get the list of currently loaded tiles that fall within - // the region calculated from the given paging distance. - void GetLoadedTileWithin(double pagingDistance, std::vector& tileList); + // Get the list of currently loaded tiles that fall within + // the region calculated from the given paging distance. + void GetLoadedTileWithin(double pagingDistance, std::vector& tileList); - bool valid; + bool valid; - // Terrain LOD we're responsible for - int lod; + // Terrain LOD we're responsible for + int lod; - /* Adjusted (e.g. paranoid) distance outward from - which to page this terrain LOD. This takes into - account the distance in the header as well as - any factor the user may have added. - */ - double pageDist; + /* Adjusted (e.g. paranoid) distance outward from + which to page this terrain LOD. This takes into + account the distance in the header as well as + any factor the user may have added. + */ + double pageDist; - /* Max tiles we could have loaded in at any given time. - This is just a guess because it's up to the user - to load (and, more importantly) unload. - */ - int maxNumTiles; + /* Max tiles we could have loaded in at any given time. + This is just a guess because it's up to the user + to load (and, more importantly) unload. + */ + int maxNumTiles; - // Size of a single cell. Copied from the archive. - trpg2dPoint cellSize; + // Size of a single cell. Copied from the archive. + trpg2dPoint cellSize; - // Number of tiles (cells) in each direction - trpg2iPoint lodSize; + // Number of tiles (cells) in each direction + trpg2iPoint lodSize; - /* Area of interest size in cells - This is a linear distance "ahead" of the center cell. - */ - trpg2iPoint aoiSize; + /* Area of interest size in cells + This is a linear distance "ahead" of the center cell. + */ + trpg2iPoint aoiSize; - /* Our effective paging location sits at the middle - of this cell. We don't recalculate unless the - cell changes. */ - trpg2iPoint cell; + /* Our effective paging location sits at the middle + of this cell. We don't recalculate unless the + cell changes. */ + trpg2iPoint cell; - // List of tiles to load - std::deque load; - // List of tiles to unload - std::deque unload; - // List of currently loaded tiles - std::deque current; + // List of tiles to load + std::deque load; + // List of tiles to unload + std::deque unload; + // List of currently loaded tiles + std::deque current; - // Used by Update. Here because we want to avoid memory allocs, if possible. - std::vector tmpCurrent; + // Used by Update. Here because we want to avoid memory allocs, if possible. + std::vector tmpCurrent; - // Set if a load is in progress - // Load w/o ACK - bool activeLoad; - // Set if an unload is in progress - // Unload w/o ACK - bool activeUnload; + // Set if a load is in progress + // Load w/o ACK + bool activeLoad; + // Set if an unload is in progress + // Unload w/o ACK + bool activeUnload; - // List of tile pointers we can reuse - std::deque freeList; + // List of tile pointers we can reuse + std::deque freeList; - // TerraPage version - int majorVersion, minorVersion; + // TerraPage version + int majorVersion, minorVersion; - const trpgTileTable *tileTable; + const trpgTileTable *tileTable; }; // Per terrain lod paging information diff --git a/src/osgPlugins/txp/trpage_material.cpp b/src/osgPlugins/txp/trpage_material.cpp index 2fd9c354e..62e60bf3c 100644 --- a/src/osgPlugins/txp/trpage_material.cpp +++ b/src/osgPlugins/txp/trpage_material.cpp @@ -606,17 +606,17 @@ void trpgMaterial::SetAttr(int attrCode,int val) { switch (attrCode) { case TR_FID: - attrSet.fid = val; - break; + attrSet.fid = val; + break; case TR_SMC: - attrSet.smc = val; - break; + attrSet.smc = val; + break; case TR_STP: - attrSet.stp = val; - break; + attrSet.stp = val; + break; case TR_SWC: - attrSet.swc = val; - break; + attrSet.swc = val; + break; } return; @@ -626,7 +626,7 @@ void trpgMaterial::SetAttr(int attrCode,int val) bool trpgMaterial::Write(trpgWriteBuffer &buf) { if (!isValid()) - return false; + return false; buf.Begin(TRPGMATERIAL); @@ -669,8 +669,8 @@ bool trpgMaterial::Write(trpgWriteBuffer &buf) buf.Begin(TRPGMAT_TEXTURE); buf.Add(numTex); for (int i=0;iSetColor(color); - buf.Get(color); - mat->SetAmbient(color); - buf.Get(color); - mat->SetDiffuse(color); - buf.Get(color); - mat->SetSpecular(color); - buf.Get(color); - mat->SetEmission(color); - buf.Get(shininess); - mat->SetShininess(shininess); - buf.Get(numtile); - mat->SetNumTiles(numtile); - break; - case TRPGMAT_SHADE: - buf.Get(shadeModel); - mat->SetShadeModel(shadeModel); - break; - case TRPGMAT_SIZES: - buf.Get(size); - mat->SetPointSize(size); - buf.Get(size); - mat->SetLineWidth(size); - break; - case TRPGMAT_CULL: - buf.Get(cullMode); - mat->SetCullMode(cullMode); - break; - case TRPGMAT_ALPHA: - buf.Get(alphaFunc); - buf.Get(alphaRef); - buf.Get(alpha); - mat->SetAlphaFunc(alphaFunc); - mat->SetAlphaRef(alphaRef); - mat->SetAlpha(alpha); - break; - case TRPGMAT_NORMAL: - { - int32 tmp; - buf.Get(tmp); - if (tmp) - autoNormal = true; - else - autoNormal = false; - mat->SetAutoNormal(autoNormal); - } - break; - case TRPGMAT_TEXTURE: - buf.Get(numTex); - for (i=0;iAddTexture(texId,texEnv); + switch (tok) { + case TRPGMAT_BASIC: + buf.Get(color); + mat->SetColor(color); + buf.Get(color); + mat->SetAmbient(color); + buf.Get(color); + mat->SetDiffuse(color); + buf.Get(color); + mat->SetSpecular(color); + buf.Get(color); + mat->SetEmission(color); + buf.Get(shininess); + mat->SetShininess(shininess); + buf.Get(numtile); + mat->SetNumTiles(numtile); + break; + case TRPGMAT_SHADE: + buf.Get(shadeModel); + mat->SetShadeModel(shadeModel); + break; + case TRPGMAT_SIZES: + buf.Get(size); + mat->SetPointSize(size); + buf.Get(size); + mat->SetLineWidth(size); + break; + case TRPGMAT_CULL: + buf.Get(cullMode); + mat->SetCullMode(cullMode); + break; + case TRPGMAT_ALPHA: + buf.Get(alphaFunc); + buf.Get(alphaRef); + buf.Get(alpha); + mat->SetAlphaFunc(alphaFunc); + mat->SetAlphaRef(alphaRef); + mat->SetAlpha(alpha); + break; + case TRPGMAT_NORMAL: + { + int32 tmp; + buf.Get(tmp); + if (tmp) + autoNormal = true; + else + autoNormal = false; + mat->SetAutoNormal(autoNormal); } break; - case TRPGMAT_BUMP: - { - int32 tmp; - buf.Get(tmp); - bool isBump = (tmp) ? true : false; - mat->SetIsBumpMap(isBump); - } - break; - case TRPGMAT_ATTR: - { - int tmp; - buf.Get(tmp); - mat->SetAttr(trpgMaterial::TR_FID,tmp); - buf.Get(tmp); - mat->SetAttr(trpgMaterial::TR_SMC,tmp); - buf.Get(tmp); - mat->SetAttr(trpgMaterial::TR_STP,tmp); - buf.Get(tmp); - mat->SetAttr(trpgMaterial::TR_SWC,tmp); - } - break; - case TRPGMAT_HANDLE: - { - int hdl; - buf.Get(hdl); - mat->SetHandle(hdl); - } - break; - default: + case TRPGMAT_TEXTURE: + buf.Get(numTex); + for (i=0;iAddTexture(texId,texEnv); + } + break; + case TRPGMAT_BUMP: + { + int32 tmp; + buf.Get(tmp); + bool isBump = (tmp) ? true : false; + mat->SetIsBumpMap(isBump); + } break; - } + case TRPGMAT_ATTR: + { + int tmp; + buf.Get(tmp); + mat->SetAttr(trpgMaterial::TR_FID,tmp); + buf.Get(tmp); + mat->SetAttr(trpgMaterial::TR_SMC,tmp); + buf.Get(tmp); + mat->SetAttr(trpgMaterial::TR_STP,tmp); + buf.Get(tmp); + mat->SetAttr(trpgMaterial::TR_SWC,tmp); + } + break; + case TRPGMAT_HANDLE: + { + int hdl; + buf.Get(hdl); + mat->SetHandle(hdl); + } + break; + default: + break; + } } catch (...) { - return NULL; + return NULL; } return mat; @@ -1050,7 +1050,7 @@ void trpgTexture::Reset() type = trpg_Unknown; numLayer = -1; if (name) - delete [] name; + delete [] name; name = NULL; useCount = 0; sizeX = sizeY = -1; @@ -1073,15 +1073,15 @@ bool trpgTexture::isValid() const { switch (mode) { case External: - return (name != NULL); + return (name != NULL); case Local: - return (type != trpg_Unknown && sizeX != -1 && sizeY != -1); + return (type != trpg_Unknown && sizeX != -1 && sizeY != -1); case Global: - return (type != trpg_Unknown); + return (type != trpg_Unknown); case Template: - return (type != trpg_Unknown && sizeX != -1 && sizeY != -1); + return (type != trpg_Unknown && sizeX != -1 && sizeY != -1); default: - return false; + return false; } } @@ -1090,11 +1090,11 @@ bool trpgTexture::isValid() const void trpgTexture::SetName(const char *inName) { if (name) - delete [] name; + delete [] name; name = NULL; if (!inName) - return; + return; name = new char[strlen(inName)+1]; strcpy(name,inName); @@ -1104,7 +1104,7 @@ void trpgTexture::SetName(const char *inName) bool trpgTexture::GetName(char *outName,int outLen) const { if (!isValid()) - return false; + return false; int len = (name) ? strlen(name) : 0; strncpy(outName,name,MIN(len,outLen)+1); @@ -1141,7 +1141,7 @@ void trpgTexture::SetImageSize(const trpg2iPoint &inSize) bool trpgTexture::GetImageSize(trpg2iPoint &outSize) const { if (mode != Local && mode != Template) - return false; + return false; outSize.x = sizeX; outSize.y = sizeY; @@ -1159,7 +1159,7 @@ bool trpgTexture::GetIsMipmap(bool &ret) const bool trpgTexture::GetImageAddr(trpgwAppAddress &outAddr) const { if (mode != Local) - return false; + return false; outAddr = addr; @@ -1173,46 +1173,46 @@ bool trpgTexture::GetImageDepth(int32 &depth) const { switch (type) { case trpg_RGB8: - depth = 3; - break; + depth = 3; + break; case trpg_RGBA8: - depth = 4; - break; + depth = 4; + break; case trpg_INT8: - depth = 1; - break; + depth = 1; + break; case trpg_INTA8: - depth = 2; - break; + depth = 2; + break; case trpg_FXT1: - depth = 3; - break; + depth = 3; + break; case trpg_RGBX: - depth = numLayer; - break; + depth = numLayer; + break; case trpg_DXT1: - depth = 3; - break; + depth = 3; + break; case trpg_DXT3: - depth = 3; - break; + depth = 3; + break; case trpg_DXT5: - depth = 3; - break; + depth = 3; + break; case trpg_MCM5: - depth = 5; - break; + depth = 5; + break; case trpg_MCM6R: case trpg_MCM6A: - depth = 6; - break; + depth = 6; + break; case trpg_MCM7RA: case trpg_MCM7AR: - depth = 7; - break; + depth = 7; + break; default: - depth = -1; - break; + depth = -1; + break; } return true; @@ -1226,7 +1226,7 @@ void trpgTexture::SetNumLayer(int layers) bool trpgTexture::GetNumLayer(int &layers) const { if (!isValid()) - return false; + return false; GetImageDepth(layers); return true; } @@ -1255,7 +1255,7 @@ trpgTexture &trpgTexture::operator = (const trpgTexture &in) type = in.type; if (in.name) - SetName(in.name); + SetName(in.name); useCount = in.useCount; @@ -1278,28 +1278,28 @@ trpgTexture &trpgTexture::operator = (const trpgTexture &in) int trpgTexture::operator == (const trpgTexture &in) const { if (mode != in.mode) - return 0; + return 0; switch (mode) { case External: - if (!in.name && !name) - return 1; - if (!in.name || !name) - return 0; - return (!strcmp(in.name,name)); - break; + if (!in.name && !name) + return 1; + if (!in.name || !name) + return 0; + return (!strcmp(in.name,name)); + break; case Local: - if (type == in.type && sizeX == in.sizeX && sizeY == in.sizeY && - isMipmap == in.isMipmap && - addr.file == in.addr.file && addr.offset == in.addr.offset && - addr.row == in.addr.row && addr.col==in.addr.col ) - return 1; - break; + if (type == in.type && sizeX == in.sizeX && sizeY == in.sizeY && + isMipmap == in.isMipmap && + addr.file == in.addr.file && addr.offset == in.addr.offset && + addr.row == in.addr.row && addr.col==in.addr.col ) + return 1; + break; case Global: case Template: - if (type == in.type && sizeX == in.sizeX && sizeY == in.sizeY && - isMipmap == in.isMipmap) - return 1; + if (type == in.type && sizeX == in.sizeX && sizeY == in.sizeY && + isMipmap == in.isMipmap) + return 1; } return 0; @@ -1318,8 +1318,8 @@ int32 trpgTexture::CalcNumMipmaps() const // Now look for the highest bit int p2; for (p2=0;p2<32;p2++) - if ((1<= 0 && miplevel < CalcNumMipmaps() ) { - if ( !storageSize.size() ) - CalcMipLevelSizes(); - return storageSize[miplevel]; + if ( !storageSize.size() ) + CalcMipLevelSizes(); + return storageSize[miplevel]; } return 0; @@ -1353,9 +1353,9 @@ int32 trpgTexture::MipLevelSize(int miplevel) int32 trpgTexture::MipLevelOffset(int miplevel) { if ( miplevel > 0 && miplevel < CalcNumMipmaps() ) { - if ( !levelOffset.size() ) - CalcMipLevelSizes(); - return levelOffset[miplevel]; + if ( !levelOffset.size() ) + CalcMipLevelSizes(); + return levelOffset[miplevel]; } return 0; @@ -1380,7 +1380,7 @@ bool trpgTexture::Write(trpgWriteBuffer &buf) buf.Add(addr.offset); buf.Add((int32)isMipmap); if(writeHandle) { - buf.Add((int32)handle); + buf.Add((int32)handle); } buf.End(); @@ -1393,42 +1393,42 @@ bool trpgTexture::Read(trpgReadBuffer &buf) char texName[1024]; try { - buf.Get(texName,1023); - SetName(texName); - buf.Get(useCount); + buf.Get(texName,1023); + SetName(texName); + buf.Get(useCount); - mode = External; - // New in 2.0 from here down - unsigned char bval; - buf.Get(bval); mode = (trpgTexture::ImageMode)bval; - buf.Get(bval); type = (trpgTexture::ImageType)bval; - GetImageDepth(numLayer); // heh - buf.Get(sizeX); - buf.Get(sizeY); - buf.Get(addr.file); - buf.Get(addr.offset); - int32 ival; - buf.Get(ival); - // Read the handle if we can.. - try { - int32 tempHandle; - if(buf.Get(tempHandle)) + mode = External; + // New in 2.0 from here down + unsigned char bval; + buf.Get(bval); mode = (trpgTexture::ImageMode)bval; + buf.Get(bval); type = (trpgTexture::ImageType)bval; + GetImageDepth(numLayer); // heh + buf.Get(sizeX); + buf.Get(sizeY); + buf.Get(addr.file); + buf.Get(addr.offset); + int32 ival; + buf.Get(ival); + // Read the handle if we can.. + try { + int32 tempHandle; + if(buf.Get(tempHandle)) { - writeHandle = true; + writeHandle = true; handle = tempHandle; } else { - handle = -1; + handle = -1; + } } + catch (...) { + handle = -1; + } + isMipmap = (ival) ? true : false; } catch (...) { - handle = -1; - } - isMipmap = (ival) ? true : false; - } - catch (...) { - return false; + return false; } if (!isValid()) return false; @@ -1452,51 +1452,51 @@ void trpgTexture::CalcMipLevelSizes() switch (type) { case trpg_DXT1: - isDXT = true; - block_size = 8; - break; + isDXT = true; + block_size = 8; + break; case trpg_DXT3: case trpg_DXT5: - isDXT = true; - block_size = 16; - break; + isDXT = true; + block_size = 16; + break; case trpg_RGB8: - pad_size = 4; - pixel_size = 3; - break; + pad_size = 4; + pixel_size = 3; + break; case trpg_RGBA8: - pad_size = 4; - pixel_size = 4; - break; + pad_size = 4; + pixel_size = 4; + break; case trpg_RGBX: - pad_size = 4; - pixel_size = numLayer; - break; + pad_size = 4; + pixel_size = numLayer; + break; case trpg_MCM5: - pad_size = 4; - pixel_size = 5; - break; + pad_size = 4; + pixel_size = 5; + break; case trpg_MCM6R: case trpg_MCM6A: - pad_size = 4; - pixel_size = 6; - break; + pad_size = 4; + pixel_size = 6; + break; case trpg_MCM7RA: case trpg_MCM7AR: - pad_size = 4; - pixel_size = 7; - break; + pad_size = 4; + pixel_size = 7; + break; case trpg_INT8: - pad_size = 4; - pixel_size = 1; - break; + pad_size = 4; + pixel_size = 1; + break; case trpg_INTA8: - pad_size = 4; - pixel_size = 2; - break; + pad_size = 4; + pixel_size = 2; + break; case trpg_FXT1: - isFXT = true; - break; + isFXT = true; + break; default: break; } @@ -1510,85 +1510,85 @@ void trpgTexture::CalcMipLevelSizes() if ( isDXT ) { // DXT compressed - int num_x_blocks = ((sizeX/4)+(sizeX%4?1:0)); - int num_y_blocks = ((sizeY/4)+(sizeY%4?1:0)); - - level_size = num_x_blocks * num_y_blocks * block_size; - storageSize.push_back(level_size); - - for ( int i = 1; i < num_miplevels; i++ ) { - level_offset += level_size; - levelOffset.push_back(level_offset); - - num_x_blocks /= 2; - num_y_blocks /= 2; - num_x_blocks = MAX(1,num_x_blocks); - num_y_blocks = MAX(1,num_y_blocks); + int num_x_blocks = ((sizeX/4)+(sizeX%4?1:0)); + int num_y_blocks = ((sizeY/4)+(sizeY%4?1:0)); level_size = num_x_blocks * num_y_blocks * block_size; storageSize.push_back(level_size); - } - return; + for ( int i = 1; i < num_miplevels; i++ ) { + level_offset += level_size; + levelOffset.push_back(level_offset); + + num_x_blocks /= 2; + num_y_blocks /= 2; + num_x_blocks = MAX(1,num_x_blocks); + num_y_blocks = MAX(1,num_y_blocks); + + level_size = num_x_blocks * num_y_blocks * block_size; + storageSize.push_back(level_size); + } + + return; } if ( isFXT) { - // bits per pixel and size - int bpp = 4; - int x = sizeX; - int y = sizeY; - - int nummiplevels = (isMipmap ? CalcNumMipmaps() : 1); - for (int i = 0; i < nummiplevels; i++) { - if (i > 0) - levelOffset.push_back(level_offset); + // bits per pixel and size + int bpp = 4; + int x = sizeX; + int y = sizeY; - x = ( x + 0x7 ) & ~0x7; - y = ( y + 0x3 ) & ~0x3; + int nummiplevels = (isMipmap ? CalcNumMipmaps() : 1); + for (int i = 0; i < nummiplevels; i++) { + if (i > 0) + levelOffset.push_back(level_offset); - // Number of bytes - level_size = ( x * y * bpp ) >> 3; - storageSize.push_back(level_size); - level_offset += level_size; + x = ( x + 0x7 ) & ~0x7; + y = ( y + 0x3 ) & ~0x3; - if (x > 1) x /= 2; - if (y > 1) y /= 2; - } + // Number of bytes + level_size = ( x * y * bpp ) >> 3; + storageSize.push_back(level_size); + level_offset += level_size; - return; + if (x > 1) x /= 2; + if (y > 1) y /= 2; + } + + return; } { - int x_size = sizeX; - int y_size = sizeY; + int x_size = sizeX; + int y_size = sizeY; - // Pad to a given size, if necessary - int row_size = x_size * pixel_size; - if (pad_size > 0) { - int left = row_size%pad_size; - if (left) - row_size += pad_size - left; - } - - level_size = row_size * y_size; - storageSize.push_back(level_size); - for ( int i = 1; i < num_miplevels; i++ ) { - level_offset += level_size; - levelOffset.push_back(level_offset); - - x_size /= 2; - y_size /= 2; - x_size = MAX(1,x_size); - y_size = MAX(1,y_size); - - row_size = x_size * pixel_size; + // Pad to a given size, if necessary + int row_size = x_size * pixel_size; if (pad_size > 0) { - int left = row_size%pad_size; - if (left) - row_size += pad_size - left; + int left = row_size%pad_size; + if (left) + row_size += pad_size - left; } + level_size = row_size * y_size; storageSize.push_back(level_size); - } + for ( int i = 1; i < num_miplevels; i++ ) { + level_offset += level_size; + levelOffset.push_back(level_offset); + + x_size /= 2; + y_size /= 2; + x_size = MAX(1,x_size); + y_size = MAX(1,y_size); + + row_size = x_size * pixel_size; + if (pad_size > 0) { + int left = row_size%pad_size; + if (left) + row_size += pad_size - left; + } + level_size = row_size * y_size; + storageSize.push_back(level_size); + } } } @@ -1628,16 +1628,16 @@ bool trpgTexTable::isValid() const { if (!textureMap.size()) { - strcpy(errMess, "Texture table list is empty"); - return false; + strcpy(errMess, "Texture table list is empty"); + return false; } TextureMapType::const_iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { - if(!itr->second.isValid()) { - strcpy(errMess, "A texture in the texture table is invalid"); - return false; - } + if(!itr->second.isValid()) { + strcpy(errMess, "A texture in the texture table is invalid"); + return false; + } } return true; } @@ -1654,30 +1654,30 @@ int trpgTexTable::AddTexture(const trpgTexture &inTex) TeAttrHdl hdl = inTex.GetHandle(); if(hdl==-1) { - // if no handle is specified, we will use an index as the handle (just like before 2.3) - hdl = textureMap.size(); + // if no handle is specified, we will use an index as the handle (just like before 2.3) + hdl = textureMap.size(); } TextureMapType::iterator itr = textureMap.find(hdl); // Don't overwrite the texture if it was already there if(itr==textureMap.end()) - textureMap[hdl] = inTex; + textureMap[hdl] = inTex; return hdl; } int trpgTexTable::FindAddTexture(const trpgTexture &inTex) { TextureMapType::iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { - trpgTexture tx = itr->second; - if(tx == inTex) { - return itr->first; - } + trpgTexture tx = itr->second; + if(tx == inTex) { + return itr->first; + } } return AddTexture(inTex); } void trpgTexTable::SetTexture(int id,const trpgTexture &inTex) { if (id < 0) - return; + return; textureMap[id] = inTex; } @@ -1687,9 +1687,9 @@ trpgTexTable &trpgTexTable::operator = (const trpgTexTable &in) Reset(); TextureMapType::const_iterator itr = in.textureMap.begin(); for ( ; itr != in.textureMap.end( ); itr++) { - trpgTexture tex = itr->second; - in.GetTexture(itr->first,tex); - AddTexture(tex); + trpgTexture tex = itr->second; + in.GetTexture(itr->first,tex); + AddTexture(tex); } return *this; @@ -1701,14 +1701,14 @@ bool trpgTexTable::Write(trpgWriteBuffer &buf) int32 numTex; if (!isValid()) - return false; + return false; buf.Begin(TRPGTEXTABLE2); numTex = textureMap.size(); buf.Add(numTex); TextureMapType::iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { - itr->second.Write(buf); + itr->second.Write(buf); } buf.End(); @@ -1729,12 +1729,12 @@ bool trpgTexTable::GetNumTextures(int &no) const bool trpgTexTable::GetTexture(int id,trpgTexture &ret) const { if (!isValid()) - return false; + return false; if (id < 0) - return false; + return false; TextureMapType::const_iterator itr = textureMap.find(id); - if(itr == textureMap.end()) { - return false; + if(itr == textureMap.end()) { + return false; } ret = itr->second; @@ -1743,10 +1743,10 @@ bool trpgTexTable::GetTexture(int id,trpgTexture &ret) const const trpgTexture *trpgTexTable::GetTextureRef(int id) const { if (id < 0) - return false; + return false; TextureMapType::const_iterator itr = textureMap.find(id); - if(itr == textureMap.end()) { - return false; + if(itr == textureMap.end()) { + return false; } const trpgTexture *ret = &(itr->second); return ret; @@ -1756,14 +1756,14 @@ const trpgTexture *trpgTexTable::FindByName(const char *name, int &texid) const { TextureMapType::const_iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { - char thisName[1024]; - thisName[0] = '\0'; - itr->second.GetName(thisName,1023); - if(strcasecmp(thisName,name)==0) - { - texid = itr->first; - return &(itr->second); - } + char thisName[1024]; + thisName[0] = '\0'; + itr->second.GetName(thisName,1023); + if(strcasecmp(thisName,name)==0) + { + texid = itr->first; + return &(itr->second); + } } return false; @@ -1776,29 +1776,29 @@ bool trpgTexTable::Read(trpgReadBuffer &buf) int32 len; try { - buf.Get(numTex); - - for (int i=0;i=2.3) - if((currentRow!=-1)&&(currentCol!=-1)) { - trpgwAppAddress taddr; - tex.GetImageAddr(taddr); - taddr.col = currentCol; - taddr.row = currentRow; - tex.SetImageAddr(taddr); + buf.Get(numTex); + + for (int i=0;i=2.3) + if((currentRow!=-1)&&(currentCol!=-1)) { + trpgwAppAddress taddr; + tex.GetImageAddr(taddr); + taddr.col = currentCol; + taddr.row = currentRow; + tex.SetImageAddr(taddr); + } + AddTexture(tex); + buf.PopLimit(); + if (!status) throw 1; } - AddTexture(tex); - buf.PopLimit(); - if (!status) throw 1; - } } catch (...) { - return false; + return false; } return true; @@ -1940,7 +1940,7 @@ bool trpgLocalMaterial::isValid() const bool trpgLocalMaterial::Write(trpgWriteBuffer &buf) { if (!isValid()) - return false; + return false; buf.Begin(TRPGLOCALMATERIAL); @@ -1958,11 +1958,11 @@ bool trpgLocalMaterial::Write(trpgWriteBuffer &buf) // and in case there's more... int numAddrs=(int)(addr.size()); if (numAddrs>1) { - buf.Add(numAddrs-1); // suppressed due to breaking old readers. - for (int i=1;isecond.cb; + return iter->second.cb; else - return 0; + return 0; } trpgr_Callback *trpgr_Parser::GetCallback(trpgToken tok) { tok_map::iterator iter = tokenMap.find(tok); if(iter != tokenMap.end()) - return iter->second.cb; + return iter->second.cb; else - return 0; + return 0; } @@ -154,7 +154,7 @@ void trpgr_Parser::SetDefaultCallback(trpgr_Callback *cb,bool in_dest) bool trpgr_Parser::TokenIsValid(trpgToken tok) { if (tok < 0) - return false; + return false; return true; } @@ -170,61 +170,61 @@ bool trpgr_Parser::Parse(trpgReadBuffer &buf) try { - while (!buf.isEmpty()) - { - /* We're expecting the following - Token (int32) - Length (int32) - Data (variable) - */ - trpgToken tok; - int32 len; - if (!buf.Get(tok)) throw 1; - // Push and Pop are special - no data - if (tok != TRPG_PUSH && tok != TRPG_POP) + while (!buf.isEmpty()) { - if (!buf.Get(len)) throw 1; - if (!TokenIsValid(tok)) throw 1; - if (len < 0) throw 1; - // Limit what we're reading to the length of this - buf.PushLimit(len); - } + /* We're expecting the following + Token (int32) + Length (int32) + Data (variable) + */ + trpgToken tok; + int32 len; + if (!buf.Get(tok)) throw 1; + // Push and Pop are special - no data + if (tok != TRPG_PUSH && tok != TRPG_POP) + { + if (!buf.Get(len)) throw 1; + if (!TokenIsValid(tok)) throw 1; + if (len < 0) throw 1; + // Limit what we're reading to the length of this + buf.PushLimit(len); + } - // Call our token handler for this one - try - { - const trpgr_Token *tcb = NULL; - tok_map::const_iterator p = tokenMap.find(tok); - if (p != tokenMap.end()) - tcb = &(*p).second; - if (!tcb) - // No such token, call the default - tcb = &defCb; + // Call our token handler for this one + try + { + const trpgr_Token *tcb = NULL; + tok_map::const_iterator p = tokenMap.find(tok); + if (p != tokenMap.end()) + tcb = &(*p).second; + if (!tcb) + // No such token, call the default + tcb = &defCb; - // Run the callback - if (tcb->cb) - { - void *ret = tcb->cb->Parse(tok,buf); - // Note: Do something with the return value - lastObject = ret; + // Run the callback + if (tcb->cb) + { + void *ret = tcb->cb->Parse(tok,buf); + // Note: Do something with the return value + lastObject = ret; + } + } + catch (...) + { + // Don't want to screw up the limit stack + } + // No limit to worry about with push and pop + if (tok != TRPG_PUSH && tok != TRPG_POP) + { + buf.SkipToLimit(); + buf.PopLimit(); + } } - } - catch (...) - { - // Don't want to screw up the limit stack - } - // No limit to worry about with push and pop - if (tok != TRPG_PUSH && tok != TRPG_POP) - { - buf.SkipToLimit(); - buf.PopLimit(); - } - } } catch (...) { - // Failed to parse. - ret = false; + // Failed to parse. + ret = false; } return ret; @@ -243,10 +243,10 @@ public: void *Parse(trpgToken /*tok*/,trpgReadBuffer& /*buf*/) { - // Call the start children callback - parse->StartChildren(parse->lastObject); - parse->parents.push_back(parse->lastObject); - return (void *)1; + // Call the start children callback + parse->StartChildren(parse->lastObject); + parse->parents.push_back(parse->lastObject); + return (void *)1; } protected: trpgSceneParser *parse; @@ -260,15 +260,15 @@ public: { parse = in_parse; }; void *Parse(trpgToken /*tok*/,trpgReadBuffer& /*buf*/) { - // Make sure we don't have an extra pop - if (parse->parents.size() == 0) - // Note: let someone know about the extra pop - return NULL; - // Call the end children callback - int len = parse->parents.size(); - parse->EndChildren(parse->parents[len-1]); - parse->parents.resize(len-1); - return (void *)1; + // Make sure we don't have an extra pop + if (parse->parents.size() == 0) + // Note: let someone know about the extra pop + return NULL; + // Call the end children callback + int len = parse->parents.size(); + parse->EndChildren(parse->parents[len-1]); + parse->parents.resize(len-1); + return (void *)1; } protected: trpgSceneParser *parse; @@ -283,8 +283,8 @@ public: trpgSceneHelperDefault(trpgSceneParser *in_parse) { parse = in_parse; } void *Parse(trpgToken /*tok*/,trpgReadBuffer& /*buf*/) { - // Absorb it quietly - return (void *)1; + // Absorb it quietly + return (void *)1; } protected: trpgSceneParser *parse; diff --git a/src/osgPlugins/txp/trpage_print.h b/src/osgPlugins/txp/trpage_print.h index 70826f1e5..be52d96fe 100644 --- a/src/osgPlugins/txp/trpage_print.h +++ b/src/osgPlugins/txp/trpage_print.h @@ -41,7 +41,7 @@ public: virtual void IncreaseIndent(int amount=1); // Decreases the current indentation by the amount given (defaults to one) virtual void DecreaseIndent(int amount=1); - protected: +protected: void updateIndent(void); int curIndent; char indentStr[200]; @@ -51,7 +51,7 @@ public: debugging output to a file. */ TX_EXDECL class TX_CLDECL trpgFilePrintBuffer : public trpgPrintBuffer { - public: +public: // This class can be constructed with either a FILE pointer or a file name trpgFilePrintBuffer(FILE *); trpgFilePrintBuffer(char *); @@ -62,7 +62,7 @@ TX_EXDECL class TX_CLDECL trpgFilePrintBuffer : public trpgPrintBuffer { // For a file printer buffer, this writes a string out to a file bool prnLine(const char *str = NULL); - protected: +protected: bool valid; bool isMine; FILE *fp; @@ -75,7 +75,7 @@ TX_EXDECL class TX_CLDECL trpgFilePrintBuffer : public trpgPrintBuffer { */ TX_EXDECL class TX_CLDECL trpgPrintGraphParser : public trpgSceneParser { - public: +public: trpgPrintGraphParser(trpgr_Archive *,trpgrImageHelper *,trpgPrintBuffer *); virtual ~trpgPrintGraphParser(void) { }; @@ -96,15 +96,15 @@ TX_EXDECL class TX_CLDECL trpgPrintGraphParser : public trpgSceneParser class ReadHelper : public trpgr_Callback { public: - // typedef std::vector ChildRefList; - // The const in the template parameter was removed because it causes GCC to - // freak out. I am of the opinion that const doesn't make sense in a template - // parameter for std::vector anyway... const prevents you from changing the - // value, so what exactly is the point? How does one add entries to the vector - // without giving them a value? -ADS - typedef std::vector ChildRefList; + // typedef std::vector ChildRefList; + // The const in the template parameter was removed because it causes GCC to + // freak out. I am of the opinion that const doesn't make sense in a template + // parameter for std::vector anyway... const prevents you from changing the + // value, so what exactly is the point? How does one add entries to the vector + // without giving them a value? -ADS + typedef std::vector ChildRefList; - ReadHelper(trpgPrintGraphParser *inPG,trpgPrintBuffer *inBuf): pBuf(inBuf), parse(inPG) {} + ReadHelper(trpgPrintGraphParser *inPG,trpgPrintBuffer *inBuf): pBuf(inBuf), parse(inPG) {} ~ReadHelper() { Reset();} void *Parse(trpgToken,trpgReadBuffer &buf); @@ -121,15 +121,13 @@ TX_EXDECL class TX_CLDECL trpgPrintGraphParser : public trpgSceneParser private: ChildRefList childRefList; - - }; // Fetch the archive associated with this print trpgr_Archive *GetArchive() {return archive; }; trpgrImageHelper *GetImageHelp() {return imageHelp; }; - protected: +protected: bool StartChildren(void *); bool EndChildren(void *); diff --git a/src/osgPlugins/txp/trpage_range.cpp b/src/osgPlugins/txp/trpage_range.cpp index 7d866df4e..e34f17f92 100644 --- a/src/osgPlugins/txp/trpage_range.cpp +++ b/src/osgPlugins/txp/trpage_range.cpp @@ -140,7 +140,7 @@ bool trpgRange::operator == (const trpgRange &in) const return false; } else { if ((category && !in.category) || - (!category && in.category) ) + (!category && in.category) ) return false; } @@ -192,13 +192,13 @@ bool trpgRange::Read(trpgReadBuffer &buf) // Read the handle if we can.. try { - int32 tempHandle; + int32 tempHandle; if(buf.Get(tempHandle)) - { - handle = tempHandle; - } - else - { + { + handle = tempHandle; + } + else + { handle = -1; } } @@ -245,7 +245,7 @@ bool trpgRangeTable::GetRange(int id,trpgRange &ret) const return false; RangeMapType::const_iterator itr = rangeMap.find(id); - if(itr == rangeMap.end()) { + if(itr == rangeMap.end()) { return false; } ret = itr->second; diff --git a/src/osgPlugins/txp/trpage_warchive.cpp b/src/osgPlugins/txp/trpage_warchive.cpp index 6095ce5d7..a4543f2b2 100644 --- a/src/osgPlugins/txp/trpage_warchive.cpp +++ b/src/osgPlugins/txp/trpage_warchive.cpp @@ -1057,17 +1057,17 @@ void trpgwGeomHelper::EndPolygon() break; } - ResetPolygon(); + ResetPolygon(); } // Clean out the polygon arrays void trpgwGeomHelper::ResetPolygon() { - tmpTex.resize(0); - matPoly.resize(0); - polyTex.resize(0); - polyNorm.resize(0); - polyVert.resize(0); + tmpTex.resize(0); + matPoly.resize(0); + polyTex.resize(0); + polyNorm.resize(0); + polyVert.resize(0); } // Set the current color @@ -1081,28 +1081,28 @@ void trpgwGeomHelper::SetColor(trpgColor& /*col*/) // Note: Required void trpgwGeomHelper::SetTexCoord(trpg2dPoint &pt) { - tmpTex.resize(0); - tmpTex.push_back(pt); + tmpTex.resize(0); + tmpTex.push_back(pt); } void trpgwGeomHelper::AddTexCoord(trpg2dPoint &pt) { - tmpTex.push_back(pt); + tmpTex.push_back(pt); } // Set the current normal // Note: required void trpgwGeomHelper::SetNormal(trpg3dPoint &pt) { - tmpNorm = pt; + tmpNorm = pt; } // Set the current material // Note: required void trpgwGeomHelper::SetMaterial(int32 imat) { - matPoly.resize(0); - matPoly.push_back(imat); + matPoly.resize(0); + matPoly.push_back(imat); } void trpgwGeomHelper::AddMaterial(int32 imat) @@ -1135,7 +1135,7 @@ void trpgwGeomHelper::AddVertex(trpg3dPoint &pt) } else #endif - polyVert.push_back(pt); + polyVert.push_back(pt); // Update min/max zmin = MIN(pt.z,zmin); diff --git a/src/osgPlugins/txp/trpage_write.h b/src/osgPlugins/txp/trpage_write.h index eab83320b..18759cd61 100644 --- a/src/osgPlugins/txp/trpage_write.h +++ b/src/osgPlugins/txp/trpage_write.h @@ -342,7 +342,7 @@ protected: std::vector tileFiles; - std::vector externalTiles; + std::vector externalTiles; int maxTileFileLen;