📄 trpage_geom.h
字号:
// Add a new range and return the ID int AddRange(trpgRange &); // Find a matching range and return it or add a new one if needed int FindAddRange(trpgRange &); // Writes this class to a write buffer bool Write(trpgWriteBuffer &); // Reads this class from a read buffer bool Read(trpgReadBuffer &); // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; // Resets the contents back to empty void Reset(void); // Assignment operator trpgRangeTable & operator = (const trpgRangeTable &); protected: typedef std::map<int,trpgRange> RangeMapType; RangeMapType rangeMap; //std::vector<trpgRange> rangeList;};/* All materials are centrally indexed in TerraPage. There is one material table per archive. All trpgGeometry nodes point to that material table (with indices) for their trpgMaterial definitions. The material table has one wrinkle. It is divided up into sub-tables or channels. Each sub-table has the same number of materials, so there will be NxM trpgMaterial structures in a trpgMatTable. The sub-tables are intended for use in simple sensor simulations. For example, the base table (0) is the purely visual, out the window representation. The next table (1) might the Infra-Red version. It's up to the run-time system to switch between these two. TerraPage simply provides the means for keeping track of it. If you're doing a TerraPage reader you'll get a trpgMatTable from the trpgr_Archive. This is your central index for materials. If you can handle the multiple channels/sub-tables then you can access those as you need. If you can't, just use 0 for the sub-table index where appropriate. If you're doing a TerraPage writer you'll need to build up a trpgMatTable to pass to trpgwArchive. If you're only doing a single sub-table (i.e. visible materials only) just use AddMaterial and add them as you go. The trpgMaterial object you build up for a given material are copied when you call the add function. So you can have a single trpgMaterial, modify just a few fields and call AddMaterial repeatedly. {group:Read/Write Classes}*/TX_EXDECL class TX_CLDECL trpgMatTable : public trpgReadWriteable{ public: trpgMatTable(void); ~trpgMatTable(void); /* If you intend to have more than one material sub-table you'll need to set this first before doing anything else. */ void SetNumTable(int); /* This sets the total number of materials. Each sub-table will have this many of its own materials. If you call this function you can't use AddMaterial. */ void SetNumMaterial(int); /* Sets a material definition for the given sub-table material ID combination. If you only have one sub-table you can use AddMaterial instead. The two argument version assumes subTable = 0 */ //void SetMaterial(int subTable,int mat,const trpgMaterial &); void SetMaterial(int,const trpgMaterial &); /* This function should be used if you only have a single material sub-table. It searches for a matching material and then adds a new one if it doesn't find a match. The new (or old) ID is returned. */ int AddMaterial(const trpgMaterial &,bool lookForExisting=true); // The following method is unused currently /* This function should be used when adding materials to multiple sub-tables. It searches for a matching material and then adds a new one if it doesn't find a match. The new (or old) ID is returned. */ //int AddMaterialInSubtable(const trpgMaterial &,int table,bool lookForExisting=true); /* Return the number of sub-tables. This will, most commonly, be 1. Any value more than 1 means the archive has alternate material definitions (think IR or Radar versions). */ bool GetNumTable(int &) const; /* The number of materials per sub-table. Each sub-table has the same number of materials. So there will be N x M number of materials total, but you'll only see M of them at any given time. */ bool GetNumMaterial(int &) const; /* Returns the material definition for the given subTable and the given material ID. The most common subTable will be 0 (visual). The material ID comes from the value(s) in trpgGeometry. */ bool GetMaterial(int subTable,int matID,trpgMaterial &) const; /* This is a convenience method for getting a reference to a trpgMaterial object. The reason you might want to do this is if you don't want to create a full trpgMaterial object to pass to GetMaterial. The returned value is only valid until the next GetMaterialRef call. */ const trpgMaterial *GetMaterialRef(int,int) const; // Validity check bool isValid(void) const; // Resets the contents back to empty void Reset(void); // Writes this class to a write buffer bool Write(trpgWriteBuffer &); // Reads this class from a read buffer bool Read(trpgReadBuffer &); // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; protected: int numTable; int numMat; typedef std::map<int,trpgMaterial> MaterialMapType; MaterialMapType materialMap;};/* This class holds the texture definition TerraPage uses. Textures are a little different than other TerraPage objects for the following reason: they aren't stored in the archive. Instead they're stored individually on disk in your favorite image format. We don't constrain what that format is, although SGI format (.rgb) is always the safest in this industry. Texture objects are really just references to these on-disk textures. As such, they're pretty simple. They just consist of a filename. These trpgTexture objects will be indexed in a trpgTexTable. The indices you get from trpgMaterial objects point to trpgTexture objects through that table. trpgMaterial objects should be the only things that have texture indices. If you're doing a TerraPage reader textures are pretty simple to read in. There are two ways to do it. First, if you're not doing texture paging, simply read them all in, using the trpgTexTable to figure out where they all are. If you are doing texture paging (highly recommended) then you'll need to call GetNumTile to figure out how many tiles a texture is used in. If it's 1, then this is probably a geospecific textures and ought to be paged. If it's more than 1, then it's a geotypical texture (i.e. a tree or road) and should be loaded in at the beginning. If you're doing a TerraPage writer you'll need to be creating trpgTexture objects as you go and adding them to your central trpgTexTable. If you want to support texture paging set the numTile count to 1 for the geospecific textures and more than 1 for everything else. There are utility functions for keeping track of all of this. It's best to use those. {group:Read/Write Classes}*/TX_EXDECL class TX_CLDECL trpgTexture : public trpgReadWriteable{ public: trpgTexture(void); trpgTexture(const trpgTexture &); ~trpgTexture(void); /* This enum is used to determine where the image is. External - Stored in an external file, just like TerraPage 1.x. Local - Stored in one of the archive files. The type and size will be here. Use trpgrImageHelper to fetch the image, either initially or later. Global - This image is really large and parts of it will be referenced later within individual tiles. Use the trpgrImageHelper class to reference the various parts of the image. Don't load it yourself. Template - This isn't an image at all. It's here to represent a class of images with a certain size and type. You'll encounter inline materials (for pageable textures) in the tiles which make use of this template. If you use trpgrImageHelper to fetch those textures, you don't need to do anything with this texture. */ typedef enum {External,Local,Global,Template} ImageMode; /* These are the types of images TerraPage can support for Local and Template image modes (see ImageMode). If the image is External or Global, anything is fair game, but these are the only types TerraPage can store itself. */ 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 } ImageType; // Set the texture name. void SetName(const char *); /* This is the texture name. You pass in a string of a pre-defined length and it returns the texture name in that. */ bool GetName(char *retStr,int strLen) const; /* Sets the number of tiles this texture is used in. This hint is used by readers to determine texture pageability. */ void SetNumTile(int); /* Instead of calling SetNumTile after you've built a database, you can call AddTile as you encounter each texture reference (per tile). */ void AddTile(void); /* This tells you the number of tiles this texture is used in. You can use this to do texture paging (if you can support it). It's a pretty general meachanism and will work for large scale geospecific terrain textures as well as things like specific building pictures. When GetImageMode returns Global, expect this value to always be 1. For Template texture, it will be set to the total number of uses of the template (which should be fairly large). */ bool GetNumTile(int &) const; // Retrieve the image mode for this texture. See ImageMode for details. bool GetImageMode(ImageMode &) const; // Retrieve the image type for this texture. See ImageType for details. // This method is only used if ImageMode is Local or Template bool GetImageType(ImageType &) const; // Retrieve the size of this image. Valid only for Local and Template textures. bool GetImageSize(trpg2iPoint &) const; // Get the location of a Local image bool GetImageAddr(trpgwAppAddress &) const; // Figure out the image depth from the type bool GetImageDepth(int32 &depth) const; // Determine whether this image (must be Local or Template) has all its mipmaps bool GetIsMipmap(bool &) const; // Set the image mode of this texture. Used by writers only. void SetImageMode(ImageMode); // Set the image type of this texture. See GetImageType for details. void SetImageType(ImageType); // Set the image size of this texture. See GetImageSize for details void SetImageSize(const trpg2iPoint &); // Set the image location (For Local images only) void SetImageAddr(const trpgwAppAddress &); // Set whether or not this is a full set of mipmaps void SetIsMipmap(bool); // Set the storage sizes for all mipmap levels // void SetStorageSizes(vector<int> &); // Get the storage sizes for all mipmap levels. // bool GetStorageSizes(const vector<int> *) const; // Set the number of mipmap levels void SetNumMipmap(int); // Set the number of layers used in an RGBX image void SetNumLayer(int); // Get the number of layers used in an RGBX image. RGBX images are typically for // sensors and contain arbitrary data which is not visual. bool GetNumLayer(int &) const; /* Utility to figure out the number of mipmap levels this image would have. Only really necessary for Local or Template images. */ int32 CalcNumMipmaps() const; // Calculate the total size of this texture int32 CalcTotalSize() const; // Returns the size of a given mip level int32 MipLevelSize(int miplevel); // Returns the offset of the mip level in the whole texture data buffer int32 MipLevelOffset(int miplevel); // Validity check bool isValid(void) const; // Resets the contents back to empty void Reset(void); // Writes this class to a write buffer bool Write(trpgWriteBuffer &); // Reads this class from a read buffer bool Read(trpgReadBuffer &); // Prints this class to a print buffer bool Print(trpgPrintBuffer &) const; trpgTexture & operator = (const trpgTexture &); int operator == (const trpgTexture &) const; protected: // Mode for this texture. See ImageMode for details ImageMode mode; // Type of texture (only valid if ImageMode is Local or Template) ImageType type; // The name really only has meaning for External or Global textures char *name; int useCount; // The size values are used only if this is a Local or Template image int sizeX,sizeY; // Whether or not there are mipmap levels bool isMipmap; // Number of mipmap levels, 0 if not present int numMipMap; // Number of layers (for RGBX) int numLayer; // Sizes of each level. This is important for compressed textures in particular, // which may have random sizes. Used only for Local textures. std::vector<int> storageSize; // Offset of each level std::vector<int> levelOffset; // Address is used only for Local textures trpgwAppAddress addr; // calculate the mip level sizes void CalcMipLevelSizes();};/* The texture table keeps track of all the textures in a TerraPage archive. All textures are indexed centrally here. The indices in trpgMaterial objects point into a trpgTexTable. Although the trpgMatTable potentially has several sub-tables for different representations (visual, IR, etc..), the trpgTexTable is not affected by that. All textures, no matter what their use, are indexed together here. If you're doing a TerraPage reader you'll get a trpgTexTable back from your trpgr_Archive. You'll then want to iterate over the trpgTexture objects and load in the ones used in more than one tile. If you can do texture paging you should leave the ones only used in 1 tile alone initially. You may also
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -