⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trpage_geom.h

📁 最新osg包
💻 H
📖 第 1 页 / 共 5 页
字号:
   want to set up a mapping from texture indices here into whatever your own texture   repository is.  The texture indices in trpgMaterial objects refer to the listing   here.   If you're doing a TerraPage writer you'll want to create one of these and add   textures as you go.  Textures are copied in when you call AddTexture or SetTexture   so you can reused the trpgTexture object you put together to pass in.  The texture   index returned by AddTexture should be used in the trpgMaterial you'll need to build.   Textures don't live in isolation and must be applied to geometry through a trpgMaterial.   After the trpgTexTable is built it will get passed to a trpgwArchive for writing.  That   can be done right before you close the archive.   {group:Read/Write Classes}*/TX_EXDECL class TX_CLDECL trpgTexTable : public trpgReadWriteable{ public:    trpgTexTable(void);    trpgTexTable(const trpgTexTable &);    ~trpgTexTable(void);    /* Sets the total number of textures in this table.  This is used in       combination with SetTexture.  If you can, you should use AddTexture       and FindAddTexture instead.    */    void	SetNumTextures(int);    /* Adds the given texture to the table and increments the total texture       count.  If you use this, you should not use SetNumTextures and SetTexture.    */    int		AddTexture(const trpgTexture &);    /* This is the same as AddTexture except that it searches for a matching texture       first.  This is convenient for writers who aren't keeping track of their       own textures internally.    */    int		FindAddTexture(const trpgTexture &);    /* This sets the given texture ID to be the trpgTexture passed in.  It's used       in combination with SetNumTextures.  Use AddTexture or FindAddTexture instead       if you can.    */    void	SetTexture(int texID,const trpgTexture &);    // Returns the number of textures in this table    bool	GetNumTextures(int &) const;    // This returns the trpgTexture corresponding to the given ID (from a trpgMaterial)    bool	GetTexture(int texID,trpgTexture &) const;    /* Does the same thing as GetTexture only it returns a pointer instead.       You would use this if you don't want a new trpgTexture created for you.       Assume the value it returns is only good until the next GetTextureRef call.    */    const trpgTexture *GetTextureRef(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;    trpgTexTable & operator = (const trpgTexTable &);    const trpgTexture *FindByName(const char *name, int &texid) const;    void	SetCurrentBlock(int row, int col)    {	currentRow = row;	currentCol = col;    }    //bool dumpGeoTypicalTextures(trpgwImageHelper *ihelper);    typedef std::map<int,trpgTexture> TextureMapType;    TextureMapType *getTextureMap()    {	return &textureMap;    } protected:	    TextureMapType textureMap;    //These are used to initialize the row/col values for    //multi-archive archives    int currentRow;    int currentCol;};/* Models are basically just references in TerraPage.  This class just points   to a model from somewhere else.  There are two places it can point.  (1) It   can point externally to a model in some arbitrary format (OpenFlight(tm) is   a popular one).  (2) It can also point to a model within the TerraPage archive.   The first case is much like trpgTexture objects are treated.  That is, the actual   thing itself is on disk somewhere corresponding to a file name.  The second case is   more like tile terrain geometry.  In that case there is scene node type data (LODs,   groups, geometry, etc...) associated with it.   trpgModel objects live within a trpgModelTable.  They are indexed there and refered   to by trpgModelRef objects.  Those model references are the only things that explicitly   use trpgModel objects.   If you're doing a TerraPage reader you'll need to take into account whether the   model is external or internal.  If it's external you'll need to read the given file   and convert it to your own representation.  If it's internal you've probably already   got the code for dealing with terrain tiles, which is essentially the same thing.   Models can be paged, if you're so inclined.  They have tile reference counts just   like trpgTexture objects.  If numTile == 1 then page it, if > 1 then don't.   If you're doing a TerraPage writer you'll want to build up a trpgModelTable of these   as you encounter them.  If your models are external in some other format then setting   up a trpgModel is pretty easy.  If you want to do internal models, the support is not   quite there yet.   {group:Read/Write Classes}*/TX_EXDECL class TX_CLDECL trpgModel : public trpgReadWriteable{ public:    trpgModel(void);    trpgModel(const trpgModel &);    ~trpgModel(void);    enum {Local,External};    // Sets the name of the external model file and sets this model to External type.    // 5.28.04 - It will not set the model to be as of external type. Use the method    // from below to set the type of the model    void	SetName(const char *);    // Sets the on-disk reference to an internal model and sets this model to Internal type.    // 5.28.04 - It will not set the model to be as of internal type. Use the method    // from below to set the type of the model    void	SetReference(trpgDiskRef);    // Sets the model type    void	SetType(int);    /* Models are reference counted (per-tile).  It's up to the writer to set this       value.  */    void	SetNumTiles(int);    /* TerraPage writers can use AddTile (starts at 0) every time they use this model       in a tile.  Note that this is not for every instance within a tile.  So if       you use a model 40 times within a tile, you call AddTile once.       This is used instead of SetNumTiles. */    void	AddTile(void);    /* Returns the type (Local or External) of this model */    bool	GetType(int &);    /* If the model is external, this returns the file name of that model.       You pass in a string and a length and it copies the filename into that. */    bool	GetName(char *ret,int strLen) const;    /* If the model is internal, this returns the disk reference to it.       At some future data you'll be able to simply read these out of an archive. */    bool	GetReference(trpgDiskRef &) const;    /* Models are reference counted, like trpgTexture objects.  You can  use this       value to determine whether or not you should page models.    */    bool	GetNumTiles(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 &, bool);    // Prints this class to a print buffer    bool	Print(trpgPrintBuffer &) const;    trpgModel & operator =  (const trpgModel &);    int operator == (const trpgModel &) const; protected:    int type;    char *name;    trpgDiskRef diskRef;    int useCount;};/* Models (trpgModel) are indexed together in a model table.  There is one   model table per TerraPage archive.  It holds the canonical list of models   for the entire database.  It's pretty simple.  Just a list of models, really.   the trpgModel object holds the real information.   If you're doing a TerraPage reader you'll get one of these from a trpgr_Archive.   You'll want to iterate over the models in it and figure out which ones to page,   if you're doing model paging.  If not, then you can just read them all in   at initialization time and index them as need per-tile.   If you're doing a TerraPage writer you'll build one of these up for the entire   database as you go.  Just call AddModel every time you finish a model definition.   The finished table will be passed to trpgwArchive at the end.   {group:Read/Write Classes}*/TX_EXDECL class TX_CLDECL trpgModelTable : public trpgReadWriteable{ public:    trpgModelTable(void);    ~trpgModelTable(void);    /* Set the total number of models in the table.  Use this in conjunction       with SetModel.  If you can, use AddModel isntead of either of these.    */    void	SetNumModels(int);    /* Add the given model to the table.  Makes a copy of the model you pass in       and returns the new model ID which you'll need to reference in trpgModelRef.    */    int		AddModel(trpgModel &);    /* Look for a given model.  If it's not there, add it. */    int		FindAddModel(trpgModel &);    /* Sets the model definition corresponding to the given ID.  Use this in conjunction       with SetNumModels. */    void	SetModel(int,const trpgModel &);    // Returns the number of models in this table    bool	GetNumModels(int &) const;    /* Returns the Nth model.  trpgModelRef objects point into this table       and that is where the model ID comes from. */    bool	GetModel(int modID,trpgModel &) const;    /* The same as GetModel only it returns a pointer to the trpgModel instead.       Use this if you don't want to create a copy of the model.       The result is only good until the next GetModelRef call.    */    trpgModel *GetModelRef(int);    // 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;    bool FindByName(const char *name, unsigned int &mId);    typedef std::map<int,trpgModel> ModelMapType;    ModelMapType *GetModelMap()    {	return &modelsMap;    } protected:	    ModelMapType modelsMap;};/* The tile table keeps track of tile locations within a TerraPage archive.   Tiles can be stored either externally (as individual files) or locally   (grouped together into bigger files).  The details are hidden from the   reader completely and the writer in most cases.   In version 2.1 the tile table only contains the location of lod 0 tiles.   All other tiles location are stored in the parent tile as trpgChildRef   nodes, so you need to parse the parent tile to get at them.   {group:Read/Write Classes}*/TX_EXDECL class TX_CLDECL trpgTileTable : public trpgReadWriteable{ 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.       enum TileMode {Local,External, ExternalSaved};    trpgTileTable();    ~trpgTileTable(void);    // Set the tile storage mode: external or local    void	SetMode(TileMode);    // Set the total number of LODs    // For version 2.1 only lod 0 is stored in the table    void	SetNumLod(int numLod);    // Set the number of tiles in each dimenion for each terrain LOD    // This must agree with trpgHeader    void	SetNumTiles(int numX,int numY,int lod);    // Set the external address of a given tile as well as its Z value    void	SetTile(int x,int y,int lod,trpgwAppAddress &,float32 min,float32 max);    // Local or external tiles    bool	GetMode(TileMode &) const;    // Get the disk reference (local)    bool	GetTile(int x,int y,int lod,trpgwAppAddress &,float32 &min,float32 &max) const;     // Validity check    bool	isValid(void) const;    // Reads this class from a read buffer    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;    /**     * SetCurrentBlock is used in two cases:     * 1. When building a block specific tile archive (MMB and non-MMB). (local is TRUE)     * 2. When merging several blocks into memory for visualization. (local is FALSE)     **/    void	SetCurrentBlock(int row, int col, bool local)    {	currentRow = row;	currentCol = col;	localBlock = local;    } protected:    TileMode mode;    class LodInfo    {					      public:	int numX,numY;	// Tile addresses into external Appendable files	std::vector<trpgwAppAddress> addr;	// Elevation of the midpoint of each tile	// This is used for calculating bounding boxes	std::vector<float> elev_min;	std::vector<float> elev_max;    };    std::vector <LodInfo> lodInfo;    //These are used to initialize the row/col values for    //multi-archive archives    int currentRow;    int currentCol;    bool localBlock; // if true, this tile table should only contain entries for one block.};/* Local materials are new to TerraPage 2.0.   The idea is that for pageable one-time textures it makes more sense   to define them in the tiles.  This keeps the size of Texture and   Material tables down in the header.  It also lets us make use of   Global textures by grabbing subimages.   You'll encounter these in a tile right after the tile header.  They'll   be referenced by ID in trpgGeometry nodes within that tile.  They   can represent a sub-image of a Global texture or a whole Local texture.   In either case, you can pass this class to trpgrTextureHelper and let   it get the image data for you.*/TX_EXDECL class TX_CLDECL trpgLocalMaterial : public trpgReadWriteable{ public:    trpgLocalMaterial(void);    ~trpgLocalMaterial(void);    // Set the base material for this local material    void	SetBaseMaterial(int32 matSubTable,int32 matID);    /* Get the base material for this local material.  Base materials       define the colors, specularity, texture environments, and in       general everything not having to do with the texture image itself.       In effect you're using the base material as your material definition and       the local material is just telling you what part of the image to use.       By convention, there should only be one global image used in any given       trpgMaterial and it should be at texture index 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -