Hello,
I have made a basic scenegraph, with a Scene and SceneNodes. The Scene has a root SceneNode and each SceneNode has a parent and a number of child nodes. Each SceneNode has a transform related to its parent aswell.
/* Scene definition */
class Scene
{
public:
Scene(const std::string& sceneName);
~Scene();
Camera& GetSceneCamera();
SceneNode& GetRootNode();
const std::string& GetSceneName() const;
bool operator==(const Scene& s1);
bool operator==(const std::string& sceneName);
private:
const std::string mName;
size_t mHashedID;
Camera mSceneCamera;
SceneNode mRootNode;
};
/* SceneNode definition */
class SceneNode
{
public:
SceneNode(const std::string& nodeName);
~SceneNode();
SceneNode* CreateChildNode(const std::string& nodeName);
SceneNode* FindChildNode(const std::string& nodeName);
bool DeleteChildNode(const std::string& nodeName);
bool DeleteChildNode(SceneNode* node);
void Scale(const Vec3& scaleVec);
void Translate(const Vec3& translateVec);
void Rotate(const float angle, const Vec3& rotateVec);
void UpdateModelMatrix(const Mat4& parentModelMatrix);
const Mat4& GetModelMatrix() const;
const std::string& GetNodeName() const;
const vector<SceneNode*>& GetChildNodes() const;
bool operator==(const SceneNode& s1);
bool operator==(const std::string& nodeName);
private:
const std::string mName;
size_t mHashedID;
vector<SceneNode*> mChildNodes;
IMemoryAllocator& mMemoryAllocator;
Mat4 mModelMatrix;
Quaternion mOrientation;
Vec3 mScale;
Vec3 mTranslation;
};
Now I want to start adding things like meshes (and later lights all such things), but I'm unsure how to best structure it. For example should I add components like meshes directly into the SceneNodes themselves, or should I keep them in the Scene and have them refer to a SceneNode? What is the best practice when it comes to this?
Also, what is an 'entity' and how is it generally used?