diff --git a/examples/ExampleApps/CubesExampleApp.cpp b/examples/ExampleApps/CubesExampleApp.cpp index d77ad3e..d0dbf52 100644 --- a/examples/ExampleApps/CubesExampleApp.cpp +++ b/examples/ExampleApps/CubesExampleApp.cpp @@ -18,6 +18,7 @@ #include "Math/Math.hpp" #include "Base/EngineConfiguration.hpp" #include "Controller/FreeCamCameraController.hpp" +#include #pragma clang diagnostic push #pragma ide diagnostic ignored "cert-msc50-cpp" @@ -47,6 +48,14 @@ namespace OpenVulkano UI::SimpleUi m_ui; std::shared_ptr m_perfInfo; + std::mt19937 random; + std::uniform_real_distribution<> randDistPos {-5.0, 5.0}; + + Math::Vector3f_SIMD RandomPos() + { + return { randDistPos(random), randDistPos(random), randDistPos(random) }; + } + public: void Init() override { @@ -63,12 +72,13 @@ namespace OpenVulkano shader.AddVertexInputDescription(Vertex::GetVertexInputDescription()); drawablesPool.resize(GEOS); m_geos.reserve(GEOS); + std::uniform_real_distribution<> randDistSize(0.1f, 1.1f); + std::uniform_real_distribution<> randDistColor(0, 1); for (uint32_t i = 0; i < GEOS; i++) { - m_geos.push_back(GeometryFactory::MakeCube( - std::rand() % 1000 / 1000.0f + 0.01f, std::rand() % 1000 / 1000.0f + 0.01f, - std::rand() % 1000 / 1000.0f + 0.01f, - Vector4f((std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, 1))); + m_geos.push_back(GeometryFactory::MakeCube(randDistSize(random), randDistSize(random), randDistSize(random), + Vector4f(randDistColor(random), randDistColor(random), randDistColor(random), 1.0f) + )); drawablesPool[i].Init(&shader, &m_geos[i], &mat); } nodesPool.resize(OBJECTS); @@ -78,7 +88,7 @@ namespace OpenVulkano scene.GetRoot()->AddChild(&nodesPool[i]); if (i < DYNAMIC) nodesPool[i].SetUpdateFrequency(UpdateFrequency::Always); nodesPool[i].AddDrawable(&drawablesPool[std::rand() % GEOS]); - nodesPool[i].SetMatrix(translate(glm::mat4x4(1), Vector3f((std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5))); + nodesPool[i].SetMatrix(Math::Utils::translate(Math::Matrix4f(1), RandomPos())); } GetGraphicsAppManager()->GetRenderer()->SetScene(&scene); @@ -96,7 +106,7 @@ namespace OpenVulkano { for (uint32_t i = 0; i < DYNAMIC; i++) { - nodesPool[i].SetMatrix(translate(glm::mat4x4(1), glm::vec3((std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5))); + nodesPool[i].SetMatrix(Math::Utils::translate(Math::Matrix4f(1), RandomPos())); } camController.Tick();