1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
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>
56 template<class type
> class TypedNodeIterator
;
61 /*========================== PUBLIC =================================*/
66 NodeBase(const NodeBase
©
);
68 NodeBase(OSG::NodePtr node
);
70 NodeBase(OSG::NodeCorePtr core
);
74 const char *getType(void);
76 static const char * getCoreName(void) { return "<none>"; }
80 inline OSG::NodePtr
getNode(void);
82 void save(const char * name
);
86 NodeIterator
iter(const char * name
);
88 TypedNodeIterator
<Geometry
> geometries(void);
89 TypedNodeIterator
<Transform
> transforms(void);
91 /*========================= PROTECTED ===============================*/
96 /*========================== PRIVATE ================================*/
101 class Group
: public NodeBase
103 /*========================== PUBLIC =================================*/
108 Group(const Group
©
);
110 Group(OSG::NodePtr node
);
112 Group(OSG::GroupPtr group
);
116 static const char * getCoreName(void) { return "Group"; }
118 void addChild(NodeBase
&node
);
120 void subChild(NodeBase
&node
);
122 /*========================= PROTECTED ===============================*/
126 /*========================== PRIVATE ================================*/
129 OSG::GroupPtr _group
;
132 class Transform
: public Group
134 /*========================== PUBLIC =================================*/
139 Transform(const Transform
©
);
141 Transform(OSG::NodePtr node
);
143 Transform(OSG::TransformPtr transform
);
147 static const char * getCoreName(void) { return "Transform"; }
149 void setTranslation(OSG::Real32 x
, OSG::Real32 y
, OSG::Real32 z
);
151 /*========================= PROTECTED ===============================*/
155 /*========================== PRIVATE ================================*/
158 OSG::TransformPtr _transform
;
161 class Light
: public Group
163 /*========================== PUBLIC =================================*/
168 Light(const Light
©
);
170 Light(OSG::NodePtr node
);
172 Light(OSG::LightPtr light
);
176 static const char * getCoreName(void) { return "Light"; }
178 /*========================= PROTECTED ===============================*/
182 /*========================== PRIVATE ================================*/
185 OSG::LightPtr _transform
;
188 class Geometry
: public NodeBase
190 /*========================== PUBLIC =================================*/
195 Geometry(const Geometry
&node
);
197 Geometry(OSG::NodePtr node
);
199 Geometry(OSG::GeometryPtr node
);
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 ===============================*/
217 /*========================== PRIVATE ================================*/
220 OSG::GeometryPtr _geometry
;
228 NodeIterator(NodeBase
&start
, const char *name
);
229 NodeIterator(const NodeIterator
©
);
233 NodeIterator
__iter__(void);
239 OSG::FieldContainerType
*_type
;
243 std::vector
<OSG::NodePtr
> _stack
;
246 template <class type
>
247 class TypedNodeIterator
: public NodeIterator
251 TypedNodeIterator(void);
253 TypedNodeIterator(NodeBase
&start
);
254 TypedNodeIterator(const TypedNodeIterator
<type
> ©
);
256 ~TypedNodeIterator();
258 TypedNodeIterator
<type
> __iter__(void);
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
,
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
);