From 214b9a467446b4aa13d8ebacbcda7e39d62f06ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Wed, 26 May 2021 15:43:42 +0200 Subject: [PATCH] systems whould work but i don't know how to put my entity in a scene --- .../System/Renderer/RenderScreenSystem.hpp | 1 + sources/main.cpp | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/sources/System/Renderer/RenderScreenSystem.hpp b/sources/System/Renderer/RenderScreenSystem.hpp index 9549133d..bcb83a13 100644 --- a/sources/System/Renderer/RenderScreenSystem.hpp +++ b/sources/System/Renderer/RenderScreenSystem.hpp @@ -30,6 +30,7 @@ namespace BBM //! @note render on screen here void onSelfUpdate() override { + std::cout << "render" << std::endl; this->_window.unuseCamera(); this->_window.setDrawingState(RAY::Window::IDLE); this->_camera.update(); diff --git a/sources/main.cpp b/sources/main.cpp index f1725a1a..f6041ccd 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -78,6 +78,73 @@ int demo() window.close(); + /* + * const int screenWidth = 800; + const int screenHeight = 450; + auto iterator = textures.begin(); + const std::string modelPath = "assets/player/player.obj"; + const std::string texturePath = "assets/player/blue.png"; + //const std::string animationPath = "assets/guy.iqm"; + RAY::TraceLog::setLevel(LOG_WARNING); + RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE); + RAY::Image icon("assets/icon.png"); + window.setIcon(icon); + RAY::Model model(modelPath); + RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f), + RAY::Vector3(0.0f, 0.0f, 0.0f), + RAY::Vector3(0.0f, 1.0f, 0.0f), + 45.0f, CAMERA_PERSPECTIVE + ); + WAL::Entity entityPlayer("roger"); + RAY::Drawables::Drawables3D::Circle circle({300, 300, 300}, 50, 0XFFFFFFF, {0, 0, 0}, 0); + BBM::Drawable3DComponent circleComponent(entityPlayer, circle); + + BBM::Renderer3DSystem circleSystem(window); + + wal.addSystem(circleSystem); + entityPlayer.addComponent(circleComponent); + + RAY::Texture texture(get_full_path(*iterator)); + //RAY::ModelAnimations animations(modelPath); + RAY::Drawables::Drawables3D::Grid grid(10, 1.0f); + RAY::Drawables::Drawables2D::Text instructionText("PRESS SPACE to PLAY MODEL ANIMATION", 10, {10, 20} , MAROON); + model.setTextureToMaterial(MAP_DIFFUSE, texture); + + RAY::Vector3 position(0.0f, 0.0f, 0.0f); // Set model position + + camera.setMode(CAMERA_FREE); // Set free camera mode + + float y_rotation = 0; + window.setFPS(60); + + while (!window.shouldClose()) + { + camera.update(); + + if (RAY::Controller::Keyboard::isReleased(KEY_SPACE)) + { + ++iterator; + if (iterator == textures.end()) + iterator = textures.begin(); + texture.unload(); + texture.load(get_full_path(*iterator)); + model.setTextureToMaterial(MAP_DIFFUSE, texture); + //animations[0].incrementFrameCounter(); + //model.setAnimation(animations[0]); + } + window.setDrawingState(RAY::Window::DRAWING); + window.clear(); + window.useCamera(camera); + window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 5.0f, 5.0f, 5.0f )); + window.draw(grid); + window.unuseCamera(); + window.draw(instructionText); + window.setDrawingState(RAY::Window::IDLE); + } + + window.close(); + */ + return 0; }