VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
trpage_scene.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_scene_h_
17 #define _txpage_scene_h_
19 
20 /* trpage_scene.h
21  Scene Graph definition.
22  This is a small scene graph we use for testing.
23  It's not intended to replace the scene graph you may already be using.
24  You do not need to translate from this scene graph structure to your own,
25  at run-time. Instead, use this file and trpage_scene.cpp as a guideline
26  for how to read TerraPage format into your own scene graph.
27  */
28 
30 
31 /*
32  {group:Demonstration Scene Graph}
33  */
35 public:
36  trpgMBR(void);
37  ~trpgMBR(void) { };
38  bool isValid(void) const;
39  void Reset(void);
40  void AddPoint(const trpg3dPoint &);
41  void AddPoint(double,double,double);
42  void GetMBR(trpg3dPoint &ll,trpg3dPoint &ur) const;
43  trpg3dPoint GetLL(void) const;
44  trpg3dPoint GetUR(void) const;
45  void Union(const trpgMBR &);
47  bool Overlap(const trpg2dPoint &ll, const trpg2dPoint &ur) const;
49  bool Within(const trpg2dPoint &) const;
50 protected:
51  inline bool inRange(double minv,double maxv,double val) const { return (val >= minv && val <= maxv); }
52  bool valid;
54 };
55 
60 public:
61  virtual ~trpgReadNode(void) { };
62  virtual bool isGroupType(void) = 0;
63  virtual int GetType(void) { return type; }
64  virtual trpgMBR GetMBR(void) const { return trpgMBR(); }
65 protected:
66  int type;
67 };
68 
73 public:
74  virtual ~trpgReadGroupBase(void) override;
75  void AddChild(trpgReadNode*);
76  virtual bool isGroupType(void) override { return true; }
77  int GetNumChildren(void) { return int(children.size()); }
78  trpgReadNode* GetChild(int i) { return children[i]; }
79  virtual trpgMBR GetMBR(void) const override;
80  void unRefChild(int i);
81  void unRefChildren(void);
82 protected:
84  void DeleteChildren(void);
85  std::vector<trpgReadNode *> children;
86 };
87 
92 public:
93  trpgReadGeometry(void) { type = TRPG_GEOMETRY; }
94  virtual ~trpgReadGeometry(void) override { };
95  virtual bool isGroupType(void) override { return false; }
96  trpgGeometry* GetData(void) { return &data; }
97  virtual trpgMBR GetMBR(void) const override;
98 protected:
101 };
102 
107 public:
109  virtual ~trpgReadTileHeader(void) override { };
110  virtual bool isGroupType(void) override { return false; }
111  trpgTileHeader* GetData(void) { return &data; }
112  virtual trpgMBR GetMBR(void) const override
113  { trpgMBR mbr; return mbr; };
114 protected:
115  trpgTileHeader data;
116 };
117 
122 public:
123  trpgReadGroup(void) { type = TRPG_GROUP; }
124  virtual ~trpgReadGroup(void) override { };
125  trpgGroup *GetData(void) { return &data; }
126 protected:
128 };
129 
134 public:
135  trpgReadAttach(void) { type = TRPG_ATTACH; }
136  virtual ~trpgReadAttach(void) override { };
137  trpgAttach *GetData(void) { return &data; }
138 protected:
140 };
141 
146 public:
147  trpgReadChildRef(void) { type = TRPG_CHILDREF; }
148  virtual ~trpgReadChildRef(void) override { };
149  virtual bool isGroupType(void) override { return false;}
150  trpgChildRef *GetData(void) { return &data; }
151 protected:
153 };
154 
158 public:
160  virtual ~trpgReadBillboard(void) override { };
161  trpgBillboard *GetData(void) { return &data; }
162 protected:
164 };
165 
169 public:
170  trpgReadLod(void) { type = TRPG_LOD; }
171  virtual ~trpgReadLod(void) override { };
172  trpgLod *GetData(void) { return &data; }
173 protected:
175 };
176 
180 public:
181  trpgReadLayer(void) { type = TRPG_LAYER; }
182  virtual ~trpgReadLayer(void) override { };
183  trpgLayer *GetData(void) { return &data; }
184 protected:
186 };
187 
191 public:
193  virtual ~trpgReadTransform(void) override { };
194  trpgTransform *GetData(void) { return &data; }
195 protected:
197 };
198 
202 public:
203  trpgReadModelRef(void) { type = TRPG_MODELREF; }
204  virtual ~trpgReadModelRef(void) override { };
205  trpgModelRef *GetData(void) { return &data; }
206 protected:
208 };
209 
210 /* Scene Graph Parser
211  Parses a read buffer and returns a full scenegraph.
212  You don't want to use this if you're reading into your own scenegraph.
213  Instead, you'll want to sublcass trpgSceneParser, which is a helper
214  class to keep track of pushes and pops and implement the same functionality
215  that trpgSceneGraphParser has for your own scene graph.
216  */
219 public:
220 #if defined(_WIN32)
221  typedef std::map<int,trpgReadGroupBase *> GroupMap;
222 #else
223  typedef std::map< int,trpgReadGroupBase *,std::less<int> > GroupMap;
224 #endif
225  trpgSceneGraphParser(void);
226  virtual ~trpgSceneGraphParser(void) override { };
229  trpgReadNode *ParseScene(trpgReadBuffer &,GroupMap &);
230  trpgReadGroupBase *GetCurrTop(void);
231  trpgReadTileHeader *GetTileHeaderRef(void);
232 
234  GroupMap *GetGroupMap(void);
235 protected:
236  virtual bool StartChildren(void*) override;
237  virtual bool EndChildren(void*) override;
242 };
243 
244 /* Test Archive
245  Utility function that loads and tests all tiles.
246  The only reason you'd want to call this is to test a TerraPage archive
247  you'd written.
248  */
251 
252 #endif
Read Attach Should be the top of a higher LOD tile {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:133
Definition: trpage_geom.h:2076
#define TRPG_MODELREF
{secret}
Definition: trpage_io.h:221
trpgReadBillboard(void)
Definition: trpage_scene.h:159
virtual bool isGroupType(void) override
Definition: trpage_scene.h:110
trpgReadTileHeader(void)
Definition: trpage_scene.h:108
#define TRPG_GROUP
{secret}
Definition: trpage_io.h:213
virtual int GetType(void)
Definition: trpage_scene.h:63
Definition: trpage_read.h:256
trpgBillboard * GetData(void)
Definition: trpage_scene.h:161
GroupMap * gmap
Top of everything.
Definition: trpage_scene.h:240
trpgGroup * GetData(void)
Definition: trpage_scene.h:125
virtual ~trpgReadTransform(void) override
Definition: trpage_scene.h:193
#define DT_DLL_osgdb_vrftxp
Contains DLL export macros.
Definition: osgdb_vrftxpDefines.h:25
trpgAttach * GetData(void)
Definition: trpage_scene.h:137
virtual ~trpgReadBillboard(void) override
Definition: trpage_scene.h:160
Definition: trpage_geom.h:2766
Read Tile Header One per tile. Info about what materials and models are used {group:Demonstration Sce...
Definition: trpage_scene.h:106
trpgTransform data
Definition: trpage_scene.h:196
Read Node Simple Scenegraph node used for read testing {group:Demonstration Scene Graph}...
Definition: trpage_scene.h:59
bool inRange(double minv, double maxv, double val) const
Definition: trpage_scene.h:51
trpgGeometry * GetData(void)
Definition: trpage_scene.h:96
#define TRPG_LOD
{secret}
Definition: trpage_io.h:217
trpgModelRef data
Definition: trpage_scene.h:207
trpgMBR mbr
Definition: trpage_scene.h:83
#define TRPG_GEOMETRY
{secret}
Definition: trpage_io.h:226
trpgReadTileHeader tileHead
Definition: trpage_scene.h:241
bool valid
Definition: trpage_scene.h:52
virtual ~trpgReadModelRef(void) override
Definition: trpage_scene.h:204
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
Read ChildRef Should point to a block tile {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:145
trpgReadTransform(void)
Definition: trpage_scene.h:192
trpgLayer data
Definition: trpage_scene.h:185
trpgReadModelRef(void)
Definition: trpage_scene.h:203
virtual bool isGroupType(void) override
Definition: trpage_scene.h:149
TX_CPPDECL bool trpgTestArchive(trpgr_Archive &)
{group:Demonstration Scene Graph}
trpgReadNode * GetChild(int i)
Definition: trpage_scene.h:78
Read Group Base Base class for all group nodes {group:Demonstration Scene Graph}. ...
Definition: trpage_scene.h:72
trpgReadNode * currTop
Definition: trpage_scene.h:238
Read Geometry The leaf for this scene graph {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:91
#define TRPG_LAYER
{secret}
Definition: trpage_io.h:223
trpgLod * GetData(void)
Definition: trpage_scene.h:172
trpgTileHeader * GetData(void)
Definition: trpage_scene.h:111
{group:Demonstration Scene Graph}
Definition: trpage_scene.h:218
Definition: trpage_geom.h:2476
trpgReadAttach(void)
Definition: trpage_scene.h:135
trpgReadGeometry(void)
Definition: trpage_scene.h:93
trpgGeometry data
Definition: trpage_scene.h:100
std::map< int, trpgReadGroupBase *, std::less< int > > GroupMap
Definition: trpage_scene.h:223
virtual ~trpgReadLayer(void) override
Definition: trpage_scene.h:182
trpgReadNode * top
Current parent group.
Definition: trpage_scene.h:239
Definition: trpage_geom.h:2340
Definition: trpage_io.h:265
virtual ~trpgReadAttach(void) override
Definition: trpage_scene.h:136
#define TX_CPPDECL
Exports a C++ function properly in a windows DLL.
Definition: trdll.h:71
Definition: trpage_read.h:185
virtual trpgMBR GetMBR(void) const
Definition: trpage_scene.h:64
Definition: trpage_geom.h:2533
Definition: trpage_geom.h:2626
trpgReadGroup(void)
Definition: trpage_scene.h:123
virtual ~trpgReadChildRef(void) override
Definition: trpage_scene.h:148
Definition: trpage_geom.h:2441
trpgAttach data
Definition: trpage_scene.h:139
virtual ~trpgReadLod(void) override
Definition: trpage_scene.h:171
trpgMBR mbr
Definition: trpage_scene.h:99
~trpgMBR(void)
Definition: trpage_scene.h:37
virtual ~trpgReadNode(void)
Definition: trpage_scene.h:61
#define TRPG_CHILDREF
{secret}
Definition: trpage_io.h:252
#define TRPG_TRANSFORM
{secret}
Definition: trpage_io.h:219
virtual trpgMBR GetMBR(void) const override
Definition: trpage_scene.h:112
virtual ~trpgSceneGraphParser(void) override
Definition: trpage_scene.h:226
Read LOD {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:168
Definition: trpage_geom.h:2722
virtual ~trpgReadGeometry(void) override
Definition: trpage_scene.h:94
trpgTransform * GetData(void)
Definition: trpage_scene.h:194
trpgModelRef * GetData(void)
Definition: trpage_scene.h:205
trpgReadLod(void)
Definition: trpage_scene.h:170
trpgLod data
Definition: trpage_scene.h:174
Read Transform {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:190
trpgBillboard data
Definition: trpage_scene.h:163
trpgGroup data
Definition: trpage_scene.h:127
trpgLayer * GetData(void)
Definition: trpage_scene.h:183
Definition: trpage_geom.h:1898
virtual bool isGroupType(void) override
Definition: trpage_scene.h:76
virtual bool EndChildren(void *)
Definition: trpage_read.h:267
Read Model Reference {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:201
trpgChildRef data
Definition: trpage_scene.h:152
#define TX_EXDECL
Goes before &quot;class&quot; to handle DLL export in windows.
Definition: trdll.h:69
Read billboard {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:157
#define TRPGTILEHEADER
{secret}
Definition: trpage_io.h:143
trpg3dPoint ur
Definition: trpage_scene.h:53
#define TRPG_BILLBOARD
{secret}
Definition: trpage_io.h:215
Definition: trpage_io.h:452
Read Layer {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:179
trpgReadChildRef(void)
Definition: trpage_scene.h:147
virtual ~trpgReadGroup(void) override
Definition: trpage_scene.h:124
virtual bool StartChildren(void *)
Start defining children for the given object.
Definition: trpage_read.h:266
virtual ~trpgReadTileHeader(void) override
Definition: trpage_scene.h:109
std::vector< trpgReadNode * > children
Definition: trpage_scene.h:85
trpgChildRef * GetData(void)
Definition: trpage_scene.h:150
Read Group Simple group structure {group:Demonstration Scene Graph}.
Definition: trpage_scene.h:121
#define TRPG_ATTACH
{secret}
Definition: trpage_io.h:249
{secret}
Definition: trpage_scene.h:34
Definition: trpage_io.h:285
virtual bool isGroupType(void) override
Definition: trpage_scene.h:95
int type
Definition: trpage_scene.h:66
trpgReadLayer(void)
Definition: trpage_scene.h:181
Definition: trpage_geom.h:2700
int GetNumChildren(void)
Definition: trpage_scene.h:77

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)