fixed: auto_ptr -> unique_ptr
[opensg.git] / Tools / osgBench / Nodes.h
blob5124358ccc7390b13c0e2e5b0f41fb69dfcca3e3
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 \*---------------------------------------------------------------------------*/
39 #ifndef _NODES_H_
40 #define _NODES_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
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>
52 class NodeIterator;
53 class Geometry;
54 class Transform;
56 template<class type> class TypedNodeIterator;
59 class NodeBase
61 /*========================== PUBLIC =================================*/
62 public:
64 NodeBase(void);
66 NodeBase(const NodeBase &copy);
68 NodeBase(OSG::NodePtr node);
70 NodeBase(OSG::NodeCorePtr core);
72 ~NodeBase();
74 const char *getType(void);
76 static const char * getCoreName(void) { return "<none>"; }
78 void dump(void);
80 inline OSG::NodePtr getNode(void);
82 void save(const char * name);
84 NodeBase clone(void);
86 NodeIterator iter(const char * name);
88 TypedNodeIterator<Geometry> geometries(void);
89 TypedNodeIterator<Transform> transforms(void);
91 /*========================= PROTECTED ===============================*/
92 protected:
94 OSG::NodePtr _node;
96 /*========================== PRIVATE ================================*/
97 private:
101 class Group : public NodeBase
103 /*========================== PUBLIC =================================*/
104 public:
106 Group(void);
108 Group(const Group &copy);
110 Group(OSG::NodePtr node);
112 Group(OSG::GroupPtr group);
114 ~Group();
116 static const char * getCoreName(void) { return "Group"; }
118 void addChild(NodeBase &node);
120 void subChild(NodeBase &node);
122 /*========================= PROTECTED ===============================*/
123 protected:
126 /*========================== PRIVATE ================================*/
127 private:
129 OSG::GroupPtr _group;
132 class Transform : public Group
134 /*========================== PUBLIC =================================*/
135 public:
137 Transform(void);
139 Transform(const Transform &copy);
141 Transform(OSG::NodePtr node);
143 Transform(OSG::TransformPtr transform);
145 ~Transform();
147 static const char * getCoreName(void) { return "Transform"; }
149 void setTranslation(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z);
151 /*========================= PROTECTED ===============================*/
152 protected:
155 /*========================== PRIVATE ================================*/
156 private:
158 OSG::TransformPtr _transform;
161 class Light : public Group
163 /*========================== PUBLIC =================================*/
164 public:
166 Light(void);
168 Light(const Light &copy);
170 Light(OSG::NodePtr node);
172 Light(OSG::LightPtr light);
174 ~Light();
176 static const char * getCoreName(void) { return "Light"; }
178 /*========================= PROTECTED ===============================*/
179 protected:
182 /*========================== PRIVATE ================================*/
183 private:
185 OSG::LightPtr _transform;
188 class Geometry : public NodeBase
190 /*========================== PUBLIC =================================*/
191 public:
193 Geometry(void);
195 Geometry(const Geometry &node);
197 Geometry(OSG::NodePtr node);
199 Geometry(OSG::GeometryPtr node);
201 ~Geometry();
203 static const char * getCoreName(void) { return "Geometry"; }
205 void translate(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z);
207 void scale(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z);
209 void merge(Geometry &geo);
211 void setDlistCache(bool cache);
213 /*========================= PROTECTED ===============================*/
214 protected:
217 /*========================== PRIVATE ================================*/
218 private:
220 OSG::GeometryPtr _geometry;
223 class NodeIterator
225 public:
227 NodeIterator(void);
228 NodeIterator(NodeBase &start, const char *name);
229 NodeIterator(const NodeIterator &copy);
231 ~NodeIterator();
233 NodeIterator __iter__(void);
235 NodeBase next(void);
237 protected:
239 OSG::FieldContainerType *_type;
241 private:
243 std::vector<OSG::NodePtr> _stack;
246 template <class type>
247 class TypedNodeIterator : public NodeIterator
249 public:
251 TypedNodeIterator(void);
253 TypedNodeIterator(NodeBase &start);
254 TypedNodeIterator(const TypedNodeIterator<type> &copy);
256 ~TypedNodeIterator();
258 TypedNodeIterator<type> __iter__(void);
260 type next(void);
263 // Functions
265 Geometry makeBox(OSG::Real32 x, OSG::Real32 y, OSG::Real32 z,
266 OSG::UInt16 hor, OSG::UInt16 vert, OSG::UInt16 depth);
268 Geometry makeTorus(OSG::Real32 inner, OSG::Real32 outer,
269 OSG::UInt16 sides, OSG::UInt16 rings);
271 Geometry makeSphere(OSG::UInt16 latres, OSG::UInt16 longres,
272 OSG::Real32 radius);
274 Geometry makePlane(OSG::Real32 x, OSG::Real32 y,
275 OSG::UInt16 hor, OSG::UInt16 vert);
277 void addRef(NodeBase &node);
279 void subRef(NodeBase &node);
281 NodeBase makeShared(NodeBase &node);
283 NodeBase loadScene(char *filename);
285 #include "Nodes.inl"
287 #endif