| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 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 |
|
|---|
| 62 |
public: |
|---|
| 63 |
|
|---|
| 64 |
NodeBase(void); |
|---|
| 65 |
|
|---|
| 66 |
NodeBase(const NodeBase ©); |
|---|
| 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 |
|
|---|
| 92 |
protected: |
|---|
| 93 |
|
|---|
| 94 |
OSG::NodePtr _node; |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
private: |
|---|
| 98 |
|
|---|
| 99 |
}; |
|---|
| 100 |
|
|---|
| 101 |
class Group : public NodeBase |
|---|
| 102 |
{ |
|---|
| 103 |
|
|---|
| 104 |
public: |
|---|
| 105 |
|
|---|
| 106 |
Group(void); |
|---|
| 107 |
|
|---|
| 108 |
Group(const Group ©); |
|---|
| 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 |
|
|---|
| 123 |
protected: |
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
private: |
|---|
| 128 |
|
|---|
| 129 |
OSG::GroupPtr _group; |
|---|
| 130 |
}; |
|---|
| 131 |
|
|---|
| 132 |
class Transform : public Group |
|---|
| 133 |
{ |
|---|
| 134 |
|
|---|
| 135 |
public: |
|---|
| 136 |
|
|---|
| 137 |
Transform(void); |
|---|
| 138 |
|
|---|
| 139 |
Transform(const Transform ©); |
|---|
| 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 |
|
|---|
| 152 |
protected: |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
private: |
|---|
| 157 |
|
|---|
| 158 |
OSG::TransformPtr _transform; |
|---|
| 159 |
}; |
|---|
| 160 |
|
|---|
| 161 |
class Light : public Group |
|---|
| 162 |
{ |
|---|
| 163 |
|
|---|
| 164 |
public: |
|---|
| 165 |
|
|---|
| 166 |
Light(void); |
|---|
| 167 |
|
|---|
| 168 |
Light(const Light ©); |
|---|
| 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 |
|
|---|
| 179 |
protected: |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
private: |
|---|
| 184 |
|
|---|
| 185 |
OSG::LightPtr _transform; |
|---|
| 186 |
}; |
|---|
| 187 |
|
|---|
| 188 |
class Geometry : public NodeBase |
|---|
| 189 |
{ |
|---|
| 190 |
|
|---|
| 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 |
|
|---|
| 214 |
protected: |
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 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 ©); |
|---|
| 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> ©); |
|---|
| 255 |
|
|---|
| 256 |
~TypedNodeIterator(); |
|---|
| 257 |
|
|---|
| 258 |
TypedNodeIterator<type> __iter__(void); |
|---|
| 259 |
|
|---|
| 260 |
type next(void); |
|---|
| 261 |
}; |
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 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 |
|---|