root/branches/Carsten_PtrWork2/Tools/osgBench/Nodes.h

Revision 213, 7.9 kB (checked in by dirk, 2 years ago)

Added simple benchmarking toolkit. Not for permanent use, just for now.

Line 
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
6  *                                                                           *
7  *                            www.opensg.org                                 *
8  *                                                                           *
9  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
10  *                                                                           *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13  *                                License                                    *
14  *                                                                           *
15  * This library is free software; you can redistribute it and/or modify it   *
16  * under the terms of the GNU Library General Public License as published    *
17  * by the Free Software Foundation, version 2.                               *
18  *                                                                           *
19  * This library is distributed in the hope that it will be useful, but       *
20  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
22  * Library General Public License for more details.                          *
23  *                                                                           *
24  * You should have received a copy of the GNU Library General Public         *
25  * License along with this library; if not, write to the Free Software       *
26  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
27  *                                                                           *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30  *                                Changes                                    *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35  *                                                                           *
36  *                                                                           *
37 \*---------------------------------------------------------------------------*/
38
39 #ifndef _NODES_H_
40 #define _NODES_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
44
45 #include <OpenSG/OSGConfig.h>
46 #include <OpenSG/OSGNode.h>
47 #include <OpenSG/OSGGroup.h>
48 #include <OpenSG/OSGTransform.h>
49 #include <OpenSG/OSGGeometry.h>
50 #include <OpenSG/OSGLight.h>
51
52 class NodeIterator;
53 class Geometry;
54 class Transform;
55
56 template<class type> class TypedNodeIterator;
57
58
59 class NodeBase
60 {
61      /*==========================  PUBLIC  =================================*/
62   public:
63  
64     NodeBase(void);
65  
66     NodeBase(const NodeBase &copy);
67  
68     NodeBase(OSG::NodePtr node);
69  
70     NodeBase(OSG::NodeCorePtr core);
71    
72     ~NodeBase();
73    
74     const char *getType(void);
75
76     static const char * getCoreName(void) { return "<none>"; }
77    
78     void dump(void);
79    
80     inline OSG::NodePtr getNode(void);
81
82     void save(const char * name);
83
84     NodeBase clone(void);
85    
86     NodeIterator iter(const char * name);
87    
88     TypedNodeIterator<Geometry>  geometries(void);
89     TypedNodeIterator<Transform> transforms(void);
90    
91     /*=========================  PROTECTED  ===============================*/
92   protected:
93
94     OSG::NodePtr _node;
95
96     /*==========================  PRIVATE  ================================*/
97   private:
98
99 };
100
101 class Group : public NodeBase
102 {
103     /*==========================  PUBLIC  =================================*/
104   public:
105  
106     Group(void);
107  
108     Group(const Group &copy);
109  
110     Group(OSG::NodePtr node);
111  
112     Group(OSG::GroupPtr group);
113    
114     ~Group();
115
116     static const char * getCoreName(void) { return "Group"; }
117    
118     void addChild(NodeBase &node);
119    
120     void subChild(NodeBase &node);
121          
122     /*=========================  PROTECTED  ===============================*/
123   protected:
124
125
126     /*==========================  PRIVATE  ================================*/
127   private:
128
129     OSG::GroupPtr _group;
130 };
131
132 class Transform : public Group
133 {
134     /*==========================  PUBLIC  =================================*/
135   public:
136  
137     Transform(void);
138  
139     Transform(const Transform &copy);
140  
141     Transform(OSG::NodePtr node);
142  
143     Transform(OSG::TransformPtr transform);
144    
145     ~Transform();
146
147     static const char * getCoreName(void) { return "Transform"; }
148    
149     void setTranslation(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z);   
150          
151     /*=========================  PROTECTED  ===============================*/
152   protected:
153
154
155     /*==========================  PRIVATE  ================================*/
156   private:
157
158     OSG::TransformPtr _transform;
159 };
160
161 class Light : public Group
162 {
163     /*==========================  PUBLIC  =================================*/
164   public:
165  
166     Light(void);
167  
168     Light(const Light &copy);
169  
170     Light(OSG::NodePtr node);
171  
172     Light(OSG::LightPtr light);
173    
174     ~Light();
175  
176     static const char * getCoreName(void) { return "Light"; }
177        
178     /*=========================  PROTECTED  ===============================*/
179   protected:
180
181
182     /*==========================  PRIVATE  ================================*/
183   private:
184
185     OSG::LightPtr _transform;
186 };
187
188 class Geometry : public NodeBase
189 {
190     /*==========================  PUBLIC  =================================*/
191   public:
192  
193     Geometry(void);
194
195     Geometry(const Geometry &node);
196
197     Geometry(OSG::NodePtr node);
198
199     Geometry(OSG::GeometryPtr node);
200    
201     ~Geometry();
202
203     static const char * getCoreName(void) { return "Geometry"; }
204
205     void translate(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z);
206
207     void scale(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z);
208    
209     void merge(Geometry &geo);
210    
211     void setDlistCache(bool cache);
212    
213     /*=========================  PROTECTED  ===============================*/
214   protected:
215
216
217     /*==========================  PRIVATE  ================================*/
218   private:
219
220     OSG::GeometryPtr _geometry;
221 };
222
223 class NodeIterator
224 {
225   public:
226  
227     NodeIterator(void);
228     NodeIterator(NodeBase &start, const char *name);
229     NodeIterator(const NodeIterator &copy);
230    
231     ~NodeIterator();
232    
233     NodeIterator __iter__(void);
234    
235     NodeBase next(void);
236
237   protected:
238  
239     OSG::FieldContainerType *_type;
240    
241   private:
242  
243     std::vector<OSG::NodePtr> _stack;
244 };
245
246 template <class type>
247 class TypedNodeIterator : public NodeIterator
248 {
249   public:
250    
251     TypedNodeIterator(void);
252
253     TypedNodeIterator(NodeBase &start);
254     TypedNodeIterator(const TypedNodeIterator<type> &copy);
255    
256     ~TypedNodeIterator();
257    
258     TypedNodeIterator<type> __iter__(void);
259    
260     type next(void);
261 };
262
263 // Functions
264
265 Geometry makeBox(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z,
266                  OSG::UInt16 hor, OSG::UInt16 vert, OSG::UInt16 depth);
267
268 Geometry makeTorus(OSG::Real32 inner, OSG::Real32 outer,
269                    OSG::UInt16 sides, OSG::UInt16 rings);
270
271 Geometry makeSphere(OSG::UInt16 latres, OSG::UInt16 longres,
272                     OSG::Real32 radius);
273
274 Geometry makePlane(OSG::Real32 x, OSG::Real32 y,
275                    OSG::UInt16 hor, OSG::UInt16 vert);
276
277 void addRef(NodeBase &node);
278
279 void subRef(NodeBase &node);
280
281 NodeBase makeShared(NodeBase &node);
282
283 NodeBase loadScene(char *filename);
284
285 #include "Nodes.inl"
286
287 #endif
Note: See TracBrowser for help on using the browser.