From 5d31d8421f63cc8c2c1b890c411e1c9ba4dac26b Mon Sep 17 00:00:00 2001 From: maka70vv <25.makarovv@gmail.com> Date: Sun, 2 Mar 2025 00:51:39 +0600 Subject: [PATCH] getting room texture by index --- GameObjectManager.cpp | 17 ++++++++++++++--- GameObjectManager.h | 3 +++ Room.h | 13 ++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/GameObjectManager.cpp b/GameObjectManager.cpp index 52abad1..38c7c95 100644 --- a/GameObjectManager.cpp +++ b/GameObjectManager.cpp @@ -2,7 +2,6 @@ #include "Environment.h" #include "ObjLoader.h" #include "Inventory.h" -#include "Room.h" #include "TextModel.h" // Add this include for LoadFromTextFile namespace ZL { @@ -12,6 +11,8 @@ const float GameObjectManager::INVENTORY_MARGIN = 10.0f; void GameObjectManager::initialize() { + current_room_index = 0; + std::cout << "Hello x1" << std::endl; coneTexturePtr = std::make_shared(CreateTextureDataFromBmp24("./conus.bmp")); @@ -63,6 +64,16 @@ void GameObjectManager::initialize() { ao1.activeObjectScreenMeshMutable.RefreshVBO(); activeObjects.push_back(ao1); + Room room_1; + room_1.roomTexture = std::make_shared(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")); +// room_1.objects = ao1; + rooms.push_back(room_1); + + Room room_2; + room_2.roomTexture = std::make_shared(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")); + rooms.push_back(room_2); + + std::cout << "Hello x5" << std::endl; @@ -95,8 +106,8 @@ void GameObjectManager::initialize() { std::cout << "Hello x8" << std::endl; - roomTexturePtr = std::make_shared(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")); - + roomTexturePtr = rooms[current_room_index].roomTexture; + std::cout << "Current room" << current_room_index << std::endl; } diff --git a/GameObjectManager.h b/GameObjectManager.h index a46028e..5ddd02b 100644 --- a/GameObjectManager.h +++ b/GameObjectManager.h @@ -5,6 +5,7 @@ #include #include #include "ActiveObject.h" +#include "Room.h" #include namespace ZL { @@ -37,6 +38,7 @@ public: ZL::VertexRenderStruct coneMeshMutable; std::vector activeObjects; + std::vector rooms; std::unique_ptr audioPlayer; ZL::VertexDataStruct inventoryIconMesh; @@ -49,6 +51,7 @@ private: int animationCounter = 0; int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши int lastMouseY = 0; + int current_room_index; bool isPointInObject(int screenX, int screenY, int objectScreenX, int objectScreenY) const; void worldToScreenCoordinates(Vector3f objectPos, // Добавляем метод Matrix4f projectionModelView, diff --git a/Room.h b/Room.h index 6759539..65dad7d 100644 --- a/Room.h +++ b/Room.h @@ -1,14 +1,13 @@ #pragma once -#include -#include -#include #include "TextureManager.h" -#include "Renderer.h" -#include "ObjLoader.h" -#include "Physics.h" +#include "Math.h" +#include #include "ActiveObject.h" namespace ZL { - +struct Room{ + std::shared_ptr roomTexture; + std::vector objects; +}; }