aboutsummaryrefslogtreecommitdiff
path: root/source/SceneThings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/SceneThings.cpp')
-rw-r--r--source/SceneThings.cpp72
1 files changed, 62 insertions, 10 deletions
diff --git a/source/SceneThings.cpp b/source/SceneThings.cpp
index 894ea58..2a25fb6 100644
--- a/source/SceneThings.cpp
+++ b/source/SceneThings.cpp
@@ -1,19 +1,71 @@
#include "SceneThings.hpp"
-void BuildingObject::SetMeshMaterial(Material* material) {
- mMaterial.Attach(material);
- // TODO update render
+#include "CommonVertexIndex.hpp"
+#include "Rect.hpp"
+
+#include <utility>
+
+SimpleGeometryObject::SimpleGeometryObject(GameWorld* world)
+ : GameObject(KD_SimpleGeometry, world)
+ , mRenderObject()
+ , mSize{ 20.0f, 20.0f }
+ , mColor(60, 60, 60) {
+ mRenderObject.SetMaterial(gDefaultMaterial.Get());
+ mRenderObject.SetFormat(gVformatStandardPacked.Get(), Tags::IT_16Bit);
+ mRenderObject.RebuildIfNecessary();
+}
+
+void SimpleGeometryObject::SetSize(glm::vec2 size) {
+ mSize = size;
+}
+
+void SimpleGeometryObject::SetColor(RgbaColor color) {
+ mColor = color;
+}
+
+std::span<const RenderObject> SimpleGeometryObject::GetRenderObjects() const {
+ return { &mRenderObject, 1 };
}
-const Material* BuildingObject::GetMeshMaterial() const {
- return mMaterial.Get();
+void SimpleGeometryObject::UpdateRenderObject() {
+ using namespace Tags;
+
+ uint16_t indices[6];
+ Index_U16::Assign(indices, 0);
+ mRenderObject.GetIndexBuffer()->Upload((const std::byte*)indices, IT_16Bit, std::size(indices));
+
+ Vertex_PTC vertices[4];
+ Vertex_PTC::Assign(vertices, Rect<float>{ GetPos(), mSize });
+ Vertex_PTC::Assign(vertices, 0.0f);
+ Vertex_PTC::Assign(vertices, mColor);
+ mRenderObject.GetVertexBufferBindings().bindings[0]->Upload((const std::byte*)vertices, sizeof(vertices));
}
-void BuildingObject::SetMesh(GpuMesh* mesh) {
- mMesh.Attach(mesh);
- // TODO update render
+BuildingObject::BuildingObject(GameWorld* world)
+ : GameObject(KD_Building, world) {
+ mRenderObject.SetMaterial(gDefaultMaterial.Get());
+ mRenderObject.SetFormat(gVformatStandardPacked.Get(), Tags::IT_32Bit);
+ mRenderObject.RebuildIfNecessary();
}
-const GpuMesh* BuildingObject::GetMesh() const {
- return mMesh.Get();
+// void BuildingObject::SetMeshMaterial(Material* material) {
+// mMaterial.Attach(material);
+// // TODO update render
+// }
+
+// const Material* BuildingObject::GetMeshMaterial() const {
+// return mMaterial.Get();
+// }
+
+// void BuildingObject::SetMesh(GpuMesh* mesh) {
+// mMesh.Attach(mesh);
+// // TODO update render
+// }
+
+// const GpuMesh* BuildingObject::GetMesh() const {
+// return mMesh.Get();
+// }
+
+std::span<const RenderObject> BuildingObject::GetRenderObjects() const {
+ return { &mRenderObject, 1 };
}