Voltray Engine Docs
Loading...
Searching...
No Matches
SceneObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Math/Transform.h"
4#include "../Math/Vec3.h"
5#include "Graphics/Mesh.h"
6#include "Graphics/Shader.h"
7#include <memory>
8#include <string>
9
19{
20public:
25 explicit SceneObject(const std::string &name = "SceneObject");
26
32 SceneObject(std::shared_ptr<Mesh> mesh, const std::string &name = "SceneObject");
33
37 virtual ~SceneObject() = default; // Transform operations
39 const Transform &GetTransform() const { return m_Transform; }
40
45 void SetRelativePivot(const Vec3 &relativePivot);
46
51 Vec3 GetRelativePivot() const; // Mesh operations
52 void SetMesh(std::shared_ptr<Mesh> mesh)
53 {
54 m_Mesh = mesh;
55 UpdatePivotFromMesh();
56 }
57 std::shared_ptr<Mesh> GetMesh() const { return m_Mesh; }
58
59 // Properties
60 const std::string &GetName() const { return m_Name; }
61 void SetName(const std::string &name) { m_Name = name; }
62 bool IsVisible() const { return m_Visible; }
63 void SetVisible(bool visible) { m_Visible = visible; }
64 bool IsSelected() const { return m_Selected; }
65 void SetSelected(bool selected) { m_Selected = selected; }
66
67 // Material properties
68 const Vec3 &GetMaterialColor() const { return m_MaterialColor; }
69 void SetMaterialColor(const Vec3 &color) { m_MaterialColor = color; }
70
76
82 void GetWorldBounds(Vec3 &minBounds, Vec3 &maxBounds) const;
83
88 virtual void Update(float deltaTime) { (void)deltaTime; }
89
93 virtual void OnRender() {}
94
95private:
99 void UpdatePivotFromMesh();
100
101protected:
102 std::string m_Name;
104 std::shared_ptr<Mesh> m_Mesh;
105 bool m_Visible = true;
106 bool m_Selected = false;
107 // Default material color is white
108 Vec3 m_MaterialColor{1.0f, 1.0f, 1.0f};
109 // Store relative pivot offset from mesh center (0,0,0 = center)
110 Vec3 m_RelativePivot{0.0f, 0.0f, 0.0f};
111};
Base class for objects in the 3D scene.
Definition SceneObject.h:19
virtual ~SceneObject()=default
Virtual destructor.
std::shared_ptr< Mesh > m_Mesh
Definition SceneObject.h:104
bool IsSelected() const
Definition SceneObject.h:64
const Transform & GetTransform() const
Definition SceneObject.h:39
Vec3 m_RelativePivot
Definition SceneObject.h:110
bool IsVisible() const
Definition SceneObject.h:62
void SetVisible(bool visible)
Definition SceneObject.h:63
void SetMaterialColor(const Vec3 &color)
Definition SceneObject.h:69
std::shared_ptr< Mesh > GetMesh() const
Definition SceneObject.h:57
void SetName(const std::string &name)
Definition SceneObject.h:61
const Vec3 & GetMaterialColor() const
Definition SceneObject.h:68
void SetRelativePivot(const Vec3 &relativePivot)
Sets the relative pivot point where (0,0,0) represents the mesh center.
Definition SceneObject.cpp:80
Vec3 GetRelativePivot() const
Gets the relative pivot point where (0,0,0) represents the mesh center.
Definition SceneObject.cpp:86
Mat4 GetModelMatrix() const
Gets the model matrix for rendering.
Definition SceneObject.h:75
Transform & GetTransform()
Definition SceneObject.h:38
bool m_Visible
Definition SceneObject.h:105
virtual void OnRender()
Virtual method called before rendering - can be overridden.
Definition SceneObject.h:93
Transform m_Transform
Definition SceneObject.h:103
void GetWorldBounds(Vec3 &minBounds, Vec3 &maxBounds) const
Gets the axis-aligned bounding box in world space.
Definition SceneObject.cpp:18
bool m_Selected
Definition SceneObject.h:106
Vec3 m_MaterialColor
Definition SceneObject.h:108
std::string m_Name
Definition SceneObject.h:102
virtual void Update(float deltaTime)
Virtual update method - can be overridden for custom behavior.
Definition SceneObject.h:88
void SetMesh(std::shared_ptr< Mesh > mesh)
Definition SceneObject.h:52
void SetSelected(bool selected)
Definition SceneObject.h:65
const std::string & GetName() const
Definition SceneObject.h:60
Represents a 3D transformation with position, rotation, and scale.
Definition Transform.h:15
Mat4 GetMatrix() const
Gets the transformation matrix.
Definition Transform.cpp:155
4x4 Matrix structure for 3D transformations and projections.
Definition Mat4.h:16
Definition Vec3.h:5