VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
trpage_read.h
Go to the documentation of this file.
1 /* ************************
2  Copyright Terrain Experts Inc.
3  Terrain Experts Inc (TERREX) reserves all rights to this source code
4  unless otherwise specified in writing by the President of TERREX.
5  This copyright may be updated in the future, in which case that version
6  supercedes this one.
7  -------------------
8  Terrex Experts Inc.
9  4400 East Broadway #314
10  Tucson, AZ 85711
11  info@terrex.com
12  Tel: (520) 323-7990
13  ************************
14  */
15 
16 #ifndef _txpage_read_h_
17 #define _txpage_read_h_
19 
20 /* txpage_read.h
21  Classes used to represent read objects for paging files.
22 */
23 
25 
27 
28 /* Callback base class
29  Called when a given token is found.
30  {group:Archive Reading}
31 */
33 {
34 public:
35  virtual ~trpgr_Callback(void) { };
36  virtual void *Parse(trpgToken,trpgReadBuffer &) { return (void *)1; };
37 };
38 
39 /* Paging Token
40  Stores callback info associated with a given token.
41  {group:Archive Reading}
42 */
44 {
45 public:
46  trpgr_Token(void);
47  trpgr_Token(int,trpgr_Callback *,bool destroy=true);
48  ~trpgr_Token(void);
49  void init(int,trpgr_Callback *,bool destroy=true);
50  int Token;
52  bool destroy;
53  void Destruct(void);
54 };
55 
56 /* Parse class for paging data structures.
57  This executes callbacks
58  {group:Archive Reading}
59 */
61 {
62 public:
63  trpgr_Parser(void);
64  virtual ~trpgr_Parser(void);
65  bool isValid(void) const;
66 
68  virtual void AddCallback(trpgToken,trpgr_Callback *,bool destroy = true);
69  virtual void AddCallback(trpgToken,trpgReadWriteable *);
70  virtual const trpgr_Callback *GetCallback(trpgToken tok) const;
71  virtual trpgr_Callback *GetCallback(trpgToken tok);
72  virtual void RemoveCallback(trpgToken);
73  virtual void SetDefaultCallback(trpgr_Callback *,bool destroy = true);
75  virtual bool Parse(trpgReadBuffer &);
76  virtual bool TokenIsValid(trpgToken);
77 protected:
78  void *lastObject;
79 private:
82 #if defined(_WIN32)
83  typedef std::map<trpgToken,trpgr_Token> tok_map;
84 #else
85  typedef std::map< trpgToken,trpgr_Token,std::less<trpgToken> > tok_map;
86 #endif
89 };
90 
91 /* Image Read Helper.
92  Used to help read Local and Tile Local textures into
93  memory (in OpenGL format). You're on your own for External
94  textures.
95  If you want to add additional ways to read textures, feel free
96  to subclass this object.
97 */
98 class trpgwImageHelper;
100 {
101  public:
103  trpgrImageHelper(trpgEndian ness,char *dir,const trpgMatTable &,const trpgTexTable &,bool separateGeoTyp);
105  virtual void Init(trpgEndian ness,char *dir,const trpgMatTable &,const trpgTexTable &,bool separateGeoTyp);
106  virtual ~trpgrImageHelper(void);
107 
108  /* Fetch the bytes for the given texture.
109  This is only valid for Local textures.
110  */
111  virtual bool GetLocalGL(const trpgTexture *,char *data,int32 dataSize);
112 
113  /* Fetch the bytes for the given mip level of a given texture.
114  This is only valid for Local textures.
115  */
116  virtual bool GetMipLevelLocalGL(int miplevel, const trpgTexture *,char *data,int32 dataSize);
117 
118  /* Do the lookups to figure out the correct material
119  and Template (or Local) texture for a given Local Material.
120  You'll need this for sizes (among other things).
121  This routine also calculates the total size, including mipmaps if they're there.
122  */
123  virtual bool GetImageInfoForLocalMat(const trpgLocalMaterial *locMat,
124  const trpgMaterial **retMat,const trpgTexture **retTex,
125  int &totSize);
126 
127  /* Same as above, but gets info for nth image associated with this local material
128  */
129  virtual bool GetNthImageInfoForLocalMat(const trpgLocalMaterial *locMat, int index,
130  const trpgMaterial **retMat,const trpgTexture **retTex,
131  int &totSize);
132 
133  /* Fetch the bytes for the given Local Material (and
134  associated texture). This is for Tile Local and
135  Global textures.
136  Data is a pre-allocated buffer for the data and
137  dataSize is the size of that buffer.
138  */
139  virtual bool GetImageForLocalMat(const trpgLocalMaterial *locMat,char *data,int dataSize);
140 
141  /* Same as above, but gets nth image associated with this local material
142  */
143  virtual bool GetNthImageForLocalMat(const trpgLocalMaterial *locMat, int index, char *data,int dataSize);
144 
145  /* Same as the one above, just fetch single mip levels
146  */
147  virtual bool GetMipLevelForLocalMat(int miplevel, const trpgLocalMaterial *locMat,char *data,int dataSize);
148 
149  /* Get mip levels for one of multiple images
150  */
151  virtual bool GetNthImageMipLevelForLocalMat(int miplevel, const trpgLocalMaterial *locMat, int index, char *data,int dataSize);
152 
153  /* Determine the full path of the image in the given
154  trpgTexture class.
155  Only useful for External images.
156  */
157  virtual bool GetImagePath(const trpgTexture *,char *,int len);
158 
159  virtual trpgrAppFileCache* GetNewRAppFileCache(const char *fullBase,const char *ext);
160 
162  {
163  return geotypCache;
164  }
165  void SetTexTable(trpgTexTable *texTable)
166  {
167  this->texTable = texTable;
168  }
169  protected:
170  char dir[1024];
174 
178 };
179 
180 /* Paging Archive (read version)
181  This just reads the first bits of the file (and the header)
182  and lets you parse from there.
183  {group:Archive Reading}
184 */
186 {
187 public:
188  trpgr_Archive(void);
189  virtual ~trpgr_Archive(void);
190 
191  virtual void SetDirectory(const char *);
192  virtual bool OpenFile(const char *);
193  virtual void CloseFile(void);
194  virtual bool ReadHeader(void);
195  //overload that lets you specify if you want to read all the blocks now,
196  //or defer reading them for later.
197  virtual bool ReadHeader(bool readAllBlocks);
198  bool ReadSubArchive(int row, int col, trpgEndian cpuNess);
200  virtual bool ReadTile(uint32 x, uint32 y, uint32 lod,trpgMemReadBuffer &);
201  virtual bool ReadTile(const trpgwAppAddress& addr, trpgMemReadBuffer &buf);
202  virtual bool ReadExternalTile(uint32 x,uint32 y,uint32 lod,trpgMemReadBuffer &buf);
203 
205  virtual const trpgHeader *GetHeader(void) const;
206  virtual const trpgMatTable *GetMaterialTable(void) const;
207  virtual trpgTexTable *GetTexTable(void) ;
208  virtual const trpgModelTable *GetModelTable(void) const;
209  virtual const trpgTileTable *GetTileTable(void) const;
210  virtual const trpgLightTable *GetLightTable(void) const;
211  virtual const trpgRangeTable *GetRangeTable(void) const;
212  virtual const trpgLabelPropertyTable *GetLabelPropertyTable() const;
213  virtual const trpgTextStyleTable *GetTextStyleTable() const;
214  virtual const trpgSupportStyleTable *GetSupportStyleTable() const;
215 
217  virtual bool trpgGetTileMBR(uint32 x,uint32 y,uint32 lod,
218  trpg3dPoint &ll,trpg3dPoint &ur) const;
219 
220  trpgEndian GetEndian(void) const;
221  char* getDir(void){return dir;};
222  virtual trpgrImageHelper* GetNewRImageHelper(trpgEndian ness,char *dir,const trpgMatTable &matTable,const trpgTexTable &texTable);
223  virtual trpgrAppFileCache* GetNewRAppFileCache(const char *fullBase, const char *ext);
224  virtual int32 GetHeaderData(char *dataPtr,int32 length,FILE *filehandle);
225  virtual int32 GetMagicNumber() {return TRPG_MAGIC;};
226 protected:
227  bool headerRead;
229  FILE *fp;
230  int fid;
232  char dir[1024];
243 
245 };
246 
247 class trpgSceneHelperPush;
248 class trpgSceneHelperPop;
249 class trpgSceneHelperDefault;
250 /* Scene Parser
251  This class assists in parsing a scene graph structure (tiles and models).
252  To use it, do an archive ReadTile and pass the resulting Read Buffer to this
253  parser.
254  {group:Archive Reading}
255 */
257 {
258  friend class trpgSceneHelperPush;
259  friend class trpgSceneHelperPop;
260  friend class trpgSceneHelperDefault;
261 public:
262  trpgSceneParser(void);
263  virtual ~trpgSceneParser(void);
264 protected:
266  virtual bool StartChildren(void *) { return true;};
267  virtual bool EndChildren(void *) { return true;};
268 
270  std::vector<void *> parents;
271 };
272 
273 #endif
Definition: trpage_write.h:155
Definition: trpage_geom.h:2951
trpgLabelPropertyTable labelPropertyTable
Definition: trpage_read.h:242
trpgrAppFileCache * texCache
Definition: trpage_read.h:175
void SetTexTable(trpgTexTable *texTable)
Definition: trpage_read.h:165
trpgLightTable lightTable
Definition: trpage_read.h:238
Definition: trpage_read.h:256
trpgrImageHelper()
Definition: trpage_read.h:102
trpgEndian
Used to specify machine endianess.
Definition: trpage_io.h:314
#define DT_DLL_osgdb_vrftxp
Contains DLL export macros.
Definition: osgdb_vrftxpDefines.h:25
Definition: trpage_geom.h:1763
trpgTextStyleTable textStyleTable
Definition: trpage_read.h:240
trpgSupportStyleTable supportStyleTable
Definition: trpage_read.h:241
trpgRangeTable rangeTable
Definition: trpage_read.h:239
Definition: trpage_io.h:697
char * getDir(void)
Definition: trpage_read.h:221
trpgHeader header
Definition: trpage_read.h:233
virtual ~trpgr_Callback(void)
Definition: trpage_read.h:35
trpgEndian ness
Definition: trpage_read.h:171
Definition: trpage_read.h:60
Definition: trpage_geom.h:1438
trpgr_Callback * cb
Constant token value.
Definition: trpage_read.h:51
const trpgMatTable * matTable
Definition: trpage_read.h:172
Definition: trpage_geom.h:1055
voidpf void * buf
Definition: ioapi.h:39
unsigned int uint32
Definition: trpage_sys.h:80
bool destroy
Callback when we hit this token.
Definition: trpage_read.h:52
Definition: trpage_geom.h:1616
trpgr_Token defCb
Definition: trpage_read.h:88
Definition: trpage_geom.h:1226
trpgrAppFileCache * geotypCache
Definition: trpage_read.h:176
Definition: trpage_read.h:185
{secret}
Definition: trpage_read.h:32
Definition: trpage_io.h:561
Definition: trpage_geom.h:2862
Definition: trpage_io.h:532
std::map< trpgToken, trpgr_Token, std::less< trpgToken > > tok_map
Note: Just how slow is a map&lt;&gt; anyway? This usage is self-contained and could be replaced with an arr...
Definition: trpage_read.h:85
const trpgTexTable * texTable
Definition: trpage_read.h:173
FILE * fp
Definition: trpage_read.h:229
trpgrAppFileCache * GetGeoTypCache()
Definition: trpage_read.h:161
Definition: trpage_io.h:632
int fid
Definition: trpage_read.h:230
#define TRPG_MAGIC
File header Magic Number.
Definition: trpage_io.h:44
Definition: trpage_geom.h:48
Definition: trpage_geom.h:3045
trpgTileTable tileTable
Definition: trpage_read.h:237
Definition: trpage_io.h:601
Definition: trpage_geom.h:903
Definition: trpage_geom.h:1680
trpgrAppFileCache * tileCache
Definition: trpage_read.h:244
tok_map tokenMap
Definition: trpage_read.h:87
trpgEndian ness
Definition: trpage_read.h:228
Definition: trpage_geom.h:345
trpgTexTable texTable
Definition: trpage_read.h:235
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
bool separateGeoTyp
Definition: trpage_read.h:177
int Token
Definition: trpage_read.h:50
trpgModelTable modelTable
Definition: trpage_read.h:236
Definition: trpage_geom.h:1119
Definition: trpage_read.h:99
#define TX_EXDECL
Goes before &quot;class&quot; to handle DLL export in windows.
Definition: trdll.h:69
Definition: trpage_io.h:452
virtual bool StartChildren(void *)
Start defining children for the given object.
Definition: trpage_read.h:266
trpgMatTable materialTable
Definition: trpage_read.h:234
void * lastObject
Check token validity.
Definition: trpage_read.h:78
Definition: trpage_io.h:285
short trpgToken
16 bit token definition value. These are values such as TRPGTEXTABLE or TRPG_ATTACH, etc...
Definition: trpage_io.h:61
Definition: trpage_read.h:43
virtual void * Parse(trpgToken, trpgReadBuffer &)
Definition: trpage_read.h:36

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)