VR-Forces 4.1.1 Class Documentation
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 
18 #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);
75  void AddChild(trpgReadNode *);
76  bool isGroupType(void) { return true; }
77  int GetNumChildren(void) { return int(children.size()); }
78  trpgReadNode *GetChild(int i) { return children[i]; }
79  trpgMBR GetMBR(void) const;
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  ~trpgReadGeometry(void) { };
95  bool isGroupType(void) { return false; }
96  trpgGeometry *GetData(void) { return &data; }
97  trpgMBR GetMBR(void) const;
98 protected:
101 };
102 
107 public:
110  bool isGroupType(void) { return false; }
111  trpgTileHeader *GetData(void) { return &data; }
112  trpgMBR GetMBR(void) const { trpgMBR mbr; return mbr; };
113 protected:
114  trpgTileHeader data;
115 };
116 
121 public:
122  trpgReadGroup(void) { type = TRPG_GROUP; }
123  ~trpgReadGroup(void) { };
124  trpgGroup *GetData(void) { return &data; }
125 protected:
127 };
128 
133 public:
134  trpgReadAttach(void) { type = TRPG_ATTACH; }
135  ~trpgReadAttach(void) { };
136  trpgAttach *GetData(void) { return &data; }
137 protected:
139 };
140 
145 public:
146  trpgReadChildRef(void) { type = TRPG_CHILDREF; }
147  ~trpgReadChildRef(void) { };
148  bool isGroupType(void) { return false;}
149  trpgChildRef *GetData(void) { return &data; }
150 protected:
152 };
153 
157 public:
160  trpgBillboard *GetData(void) { return &data; }
161 protected:
163 };
164 
168 public:
169  trpgReadLod(void) { type = TRPG_LOD; }
170  ~trpgReadLod(void) { };
171  trpgLod *GetData(void) { return &data; }
172 protected:
174 };
175 
179 public:
180  trpgReadLayer(void) { type = TRPG_LAYER; }
181  ~trpgReadLayer(void) { };
182  trpgLayer *GetData(void) { return &data; }
183 protected:
185 };
186 
190 public:
193  trpgTransform *GetData(void) { return &data; }
194 protected:
196 };
197 
201 public:
202  trpgReadModelRef(void) { type = TRPG_MODELREF; }
203  ~trpgReadModelRef(void) { };
204  trpgModelRef *GetData(void) { return &data; }
205 protected:
207 };
208 
209 /* Scene Graph Parser
210  Parses a read buffer and returns a full scenegraph.
211  You don't want to use this if you're reading into your own scenegraph.
212  Instead, you'll want to sublcass trpgSceneParser, which is a helper
213  class to keep track of pushes and pops and implement the same functionality
214  that trpgSceneGraphParser has for your own scene graph.
215  */
218 public:
219 #if defined(_WIN32)
220  typedef std::map<int,trpgReadGroupBase *> GroupMap;
221 #else
222  typedef std::map< int,trpgReadGroupBase *,std::less<int> > GroupMap;
223 #endif
224  trpgSceneGraphParser(void);
225  virtual ~trpgSceneGraphParser(void) { };
228  trpgReadNode *ParseScene(trpgReadBuffer &,GroupMap &);
229  trpgReadGroupBase *GetCurrTop(void);
230  trpgReadTileHeader *GetTileHeaderRef(void);
231 
233  GroupMap *GetGroupMap(void);
234 protected:
235  bool StartChildren(void *);
236  bool EndChildren(void *);
241 };
242 
243 /* Test Archive
244  Utility function that loads and tests all tiles.
245  The only reason you'd want to call this is to test a TerraPage archive
246  you'd written.
247  */
250 
251 #endif

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)