| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "inode.h" |
| 4 |
#include "iscript.h" |
| 5 |
#include "iscriptinterface.h" |
| 6 |
#include "iscenegraph.h" |
| 7 |
#include "math/AABB.h" |
| 8 |
|
| 9 |
#include <pybind11/pybind11.h> |
| 10 |
|
| 11 |
namespace script |
| 12 |
{ |
| 13 |
|
| 14 |
class ScriptSceneNode |
| 15 |
{ |
| 16 |
protected: |
| 17 |
// The contained scene::INodePtr |
| 18 |
const scene::INodeWeakPtr _node; |
| 19 |
|
| 20 |
AABB _emptyAABB; |
| 21 |
public: |
| 22 |
ScriptSceneNode(const scene::INodePtr& node); |
| 23 |
|
| 24 |
virtual ~ScriptSceneNode(); |
| 25 |
|
| 26 |
operator scene::INodePtr() const; |
| 27 |
|
| 28 |
void removeFromParent(); |
| 29 |
void addToContainer(const ScriptSceneNode& container); |
| 30 |
|
| 31 |
const AABB& getWorldAABB() const; |
| 32 |
|
| 33 |
bool isNull() const; |
| 34 |
|
| 35 |
ScriptSceneNode getParent(); |
| 36 |
|
| 37 |
std::string getNodeType(); |
| 38 |
|
| 39 |
void traverse(scene::NodeVisitor& visitor); |
| 40 |
|
| 41 |
void traverseChildren(scene::NodeVisitor& visitor); |
| 42 |
|
| 43 |
bool isSelected(); |
| 44 |
|
| 45 |
void setSelected(int selected); |
| 46 |
|
| 47 |
void invertSelected(); |
| 48 |
}; |
| 49 |
|
| 50 |
// Wrap around the scene::NodeVisitor interface |
| 51 |
class SceneNodeVisitorWrapper : |
| 52 |
public scene::NodeVisitor |
| 53 |
{ |
| 54 |
public: |
| 55 |
bool pre(const scene::INodePtr& node) override |
| 56 |
{ |
| 57 |
// Wrap this method to python |
| 58 |
PYBIND11_OVERLOAD_PURE( |
| 59 |
int, /* Return type */ |
| 60 |
NodeVisitor, /* Parent class */ |
| 61 |
pre, /* Name of function in C++ (must match Python name) */ |
| 62 |
ScriptSceneNode(node) /* Argument(s) */ |
| 63 |
); |
| 64 |
} |
| 65 |
|
| 66 |
void post(const scene::INodePtr& node) override |
| 67 |
{ |
| 68 |
PYBIND11_OVERLOAD( |
| 69 |
void, /* Return type */ |
| 70 |
NodeVisitor, /* Parent class */ |
| 71 |
post, /* Name of function in C++ (must match Python name) */ |
| 72 |
ScriptSceneNode(node) /* Argument(s) */ |
| 73 |
); |
| 74 |
} |
| 75 |
}; |
| 76 |
|
| 77 |
class SceneGraphInterface : |
| 78 |
public IScriptInterface |
| 79 |
{ |
| 80 |
public: |
| 81 |
ScriptSceneNode root(); |
| 82 |
|
| 83 |
void registerInterface(py::module& scope, py::dict& globals) override; |
| 84 |
}; |
| 85 |
|
| 86 |
} // namespace script |