|
@@ -1,5 +1,5 @@
|
|
|
-#ifndef _NODE_H_
|
|
|
|
|
-#define _NODE_H_
|
|
|
|
|
|
|
+#ifndef SCENE_NODE_H
|
|
|
|
|
+#define SCENE_NODE_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
#include <memory>
|
|
|
#include "Common.h"
|
|
#include "Common.h"
|
|
@@ -12,11 +12,13 @@ class Material;
|
|
|
class Controller;
|
|
class Controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
-/// Scene node
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * The backbone of scene
|
|
|
|
|
+ */
|
|
|
class SceneNode
|
|
class SceneNode
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- enum NodeType
|
|
|
|
|
|
|
+ enum Type
|
|
|
{
|
|
{
|
|
|
NT_GHOST,
|
|
NT_GHOST,
|
|
|
NT_LIGHT,
|
|
NT_LIGHT,
|
|
@@ -33,25 +35,32 @@ class SceneNode
|
|
|
public:
|
|
public:
|
|
|
SceneNode* parent;
|
|
SceneNode* parent;
|
|
|
Vec<SceneNode*> childs;
|
|
Vec<SceneNode*> childs;
|
|
|
- NodeType type;
|
|
|
|
|
|
|
+ Type type;
|
|
|
bvolume_t* bvolumeLspace;
|
|
bvolume_t* bvolumeLspace;
|
|
|
bvolume_t* bvolumeWspace;
|
|
bvolume_t* bvolumeWspace;
|
|
|
bool isCompound;
|
|
bool isCompound;
|
|
|
|
|
|
|
|
- SceneNode(NodeType type_);
|
|
|
|
|
- SceneNode(NodeType type_, SceneNode* parent);
|
|
|
|
|
|
|
+ SceneNode(Type type_);
|
|
|
|
|
+ SceneNode(Type type_, SceneNode* parent);
|
|
|
virtual ~SceneNode();
|
|
virtual ~SceneNode();
|
|
|
virtual void render() = 0;
|
|
virtual void render() = 0;
|
|
|
virtual void init(const char*) = 0; ///< init using a script
|
|
virtual void init(const char*) = 0; ///< init using a script
|
|
|
virtual void deinit() = 0;
|
|
virtual void deinit() = 0;
|
|
|
virtual void updateWorldStuff() { updateWorldTransform(); } ///< This update happens only when the object gets moved. Override it if you want more
|
|
virtual void updateWorldStuff() { updateWorldTransform(); } ///< This update happens only when the object gets moved. Override it if you want more
|
|
|
void updateWorldTransform();
|
|
void updateWorldTransform();
|
|
|
- void rotateLocalX(float angDegrees) { localTransform.getRotation().rotateXAxis(angDegrees); }
|
|
|
|
|
- void rotateLocalY(float angDegrees) { localTransform.getRotation().rotateYAxis(angDegrees); }
|
|
|
|
|
- void rotateLocalZ(float angDegrees) { localTransform.getRotation().rotateZAxis(angDegrees); }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @name Local transform
|
|
|
|
|
+ */
|
|
|
|
|
+ /**@{*/
|
|
|
|
|
+ void rotateLocalX(float angDegrees);
|
|
|
|
|
+ void rotateLocalY(float angDegrees);
|
|
|
|
|
+ void rotateLocalZ(float angDegrees);
|
|
|
void moveLocalX(float distance);
|
|
void moveLocalX(float distance);
|
|
|
void moveLocalY(float distance);
|
|
void moveLocalY(float distance);
|
|
|
void moveLocalZ(float distance);
|
|
void moveLocalZ(float distance);
|
|
|
|
|
+ /**@}*/
|
|
|
|
|
+
|
|
|
void addChild(SceneNode* node);
|
|
void addChild(SceneNode* node);
|
|
|
void removeChild(SceneNode* node);
|
|
void removeChild(SceneNode* node);
|
|
|
|
|
|
|
@@ -60,14 +69,14 @@ class SceneNode
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
-inline SceneNode::SceneNode(NodeType type_):
|
|
|
|
|
|
|
+inline SceneNode::SceneNode(Type type_):
|
|
|
type(type_)
|
|
type(type_)
|
|
|
{
|
|
{
|
|
|
commonConstructorCode();
|
|
commonConstructorCode();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-inline SceneNode::SceneNode(NodeType type_, SceneNode* parent):
|
|
|
|
|
|
|
+inline SceneNode::SceneNode(Type type_, SceneNode* parent):
|
|
|
type(type_)
|
|
type(type_)
|
|
|
{
|
|
{
|
|
|
commonConstructorCode();
|
|
commonConstructorCode();
|
|
@@ -75,4 +84,22 @@ inline SceneNode::SceneNode(NodeType type_, SceneNode* parent):
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+inline void SceneNode::rotateLocalX(float angDegrees)
|
|
|
|
|
+{
|
|
|
|
|
+ localTransform.getRotation().rotateXAxis(angDegrees);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+inline void SceneNode::rotateLocalY(float angDegrees)
|
|
|
|
|
+{
|
|
|
|
|
+ localTransform.getRotation().rotateYAxis(angDegrees);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+inline void SceneNode::rotateLocalZ(float angDegrees)
|
|
|
|
|
+{
|
|
|
|
|
+ localTransform.getRotation().rotateZAxis(angDegrees);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
#endif
|
|
#endif
|