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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#pragma once
#include "inode.h"
#include "iscript.h"
#include "iscriptinterface.h"
#include "iscenegraph.h"
#include "math/AABB.h"
#include <pybind11/pybind11.h>
namespace script
{
class ScriptSceneNode
{
protected:
// The contained scene::INodePtr
const scene::INodeWeakPtr _node;
AABB _emptyAABB;
public:
ScriptSceneNode(const scene::INodePtr& node);
virtual ~ScriptSceneNode();
operator scene::INodePtr() const;
void removeFromParent();
void addToContainer(const ScriptSceneNode& container);
const AABB& getWorldAABB() const;
bool isNull() const;
ScriptSceneNode getParent();
std::string getNodeType();
void traverse(scene::NodeVisitor& visitor);
void traverseChildren(scene::NodeVisitor& visitor);
bool isSelected();
void setSelected(int selected);
void invertSelected();
};
// Wrap around the scene::NodeVisitor interface
class SceneNodeVisitorWrapper :
public scene::NodeVisitor
{
public:
bool pre(const scene::INodePtr& node) override
{
// Wrap this method to python
PYBIND11_OVERLOAD_PURE(
int, /* Return type */
NodeVisitor, /* Parent class */
pre, /* Name of function in C++ (must match Python name) */
ScriptSceneNode(node) /* Argument(s) */
);
}
void post(const scene::INodePtr& node) override
{
PYBIND11_OVERLOAD(
void, /* Return type */
NodeVisitor, /* Parent class */
post, /* Name of function in C++ (must match Python name) */
ScriptSceneNode(node) /* Argument(s) */
);
}
};
class SceneGraphInterface :
public IScriptInterface
{
public:
ScriptSceneNode root();
void registerInterface(py::module& scope, py::dict& globals) override;
};
} // namespace script
|