Merge branch 'salmon' of github.com:mephi1984/ZeptoLabTest1 into Albert
This commit is contained in:
commit
0aff255379
@ -25,6 +25,8 @@ public:
|
|||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::thread worker;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<AudioPlayer> audioPlayer;
|
std::unique_ptr<AudioPlayer> audioPlayer;
|
||||||
//std::mutex audioPlayerMutex;
|
//std::mutex audioPlayerMutex;
|
||||||
@ -35,9 +37,6 @@ private:
|
|||||||
std::string latestSoundName;
|
std::string latestSoundName;
|
||||||
std::string latestMusicName;
|
std::string latestMusicName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::thread worker;
|
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
std::condition_variable cv;
|
std::condition_variable cv;
|
||||||
std::queue<std::function<void()>> taskQueue;
|
std::queue<std::function<void()>> taskQueue;
|
||||||
|
|||||||
@ -40,4 +40,6 @@ bool Environment::showMouse = false;
|
|||||||
|
|
||||||
bool Environment::exitGameLoop = false;
|
bool Environment::exitGameLoop = false;
|
||||||
|
|
||||||
|
bool Environment::gameIsLoading = true;
|
||||||
|
|
||||||
} // namespace ZL
|
} // namespace ZL
|
||||||
|
|||||||
@ -44,6 +44,8 @@ public:
|
|||||||
static bool showMouse;
|
static bool showMouse;
|
||||||
static bool exitGameLoop;
|
static bool exitGameLoop;
|
||||||
|
|
||||||
|
static bool gameIsLoading;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
30
Game.cpp
30
Game.cpp
@ -72,6 +72,24 @@ void Game::drawScene() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::processTickCount() {
|
void Game::processTickCount() {
|
||||||
|
|
||||||
|
if (Environment::gameIsLoading)
|
||||||
|
{
|
||||||
|
if (gameObjects.loadingFunctions.size() != 0)
|
||||||
|
{
|
||||||
|
bool result = gameObjects.loadingFunctions.begin()->operator()();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
gameObjects.loadingFunctions.erase(gameObjects.loadingFunctions.begin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Environment::gameIsLoading = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (lastTickCount == 0) {
|
if (lastTickCount == 0) {
|
||||||
lastTickCount = SDL_GetTicks64();
|
lastTickCount = SDL_GetTicks64();
|
||||||
return;
|
return;
|
||||||
@ -105,9 +123,19 @@ void Game::update() {
|
|||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
if (event.type == SDL_QUIT) {
|
if (event.type == SDL_QUIT) {
|
||||||
|
if (gameObjects.loadingThread.joinable())
|
||||||
|
{
|
||||||
|
gameObjects.loadingThread.join();
|
||||||
|
}
|
||||||
|
gameObjects.audioPlayerAsync.exit();
|
||||||
Environment::exitGameLoop = true;
|
Environment::exitGameLoop = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Environment::gameIsLoading)
|
||||||
|
{
|
||||||
|
gameObjects.handleEvent(event);
|
||||||
}
|
}
|
||||||
gameObjects.handleEvent(event);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
render();
|
render();
|
||||||
|
|||||||
@ -10,173 +10,166 @@ namespace ZL {
|
|||||||
const float GameObjectManager::INVENTORY_ICON_SIZE = 64.0f;
|
const float GameObjectManager::INVENTORY_ICON_SIZE = 64.0f;
|
||||||
const float GameObjectManager::INVENTORY_MARGIN = 10.0f;
|
const float GameObjectManager::INVENTORY_MARGIN = 10.0f;
|
||||||
|
|
||||||
|
void GameObjectManager::initializeLoadingScreen()
|
||||||
|
{
|
||||||
|
loadingScreenTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./loading.bmp"));
|
||||||
|
|
||||||
|
loadingScreenMesh = CreateRect2D(
|
||||||
|
{ Environment::width / 2.f, Environment::height / 2.f },
|
||||||
|
{ Environment::width / 2.f, Environment::height / 2.f },
|
||||||
|
0.5f
|
||||||
|
);
|
||||||
|
loadingScreenMeshMutable.AssignFrom(loadingScreenMesh);
|
||||||
|
loadingScreenMeshMutable.RefreshVBO();
|
||||||
|
}
|
||||||
|
|
||||||
void GameObjectManager::initialize() {
|
void GameObjectManager::initialize() {
|
||||||
|
|
||||||
current_room_index = 0;
|
initializeLoadingScreen();
|
||||||
objects_in_inventory = 0;
|
|
||||||
|
std::function<bool()> loadingFunction1 = [this]()
|
||||||
|
{
|
||||||
|
|
||||||
coneTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./conus.bmp"));
|
current_room_index = 0;
|
||||||
|
objects_in_inventory = 0;
|
||||||
|
|
||||||
// Load models
|
coneTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./conus.bmp"));
|
||||||
colorCubeMesh = CreateCube3D(5.0);
|
|
||||||
colorCubeMeshMutable.data = CreateCube3D(5.0);
|
|
||||||
colorCubeMeshMutable.RefreshVBO();
|
|
||||||
|
|
||||||
testObjMesh = LoadFromObjFile("./chair_01.obj");
|
// Load models
|
||||||
testObjMesh.Scale(10);
|
/*
|
||||||
testObjMesh.SwapZandY();
|
colorCubeMesh = CreateCube3D(5.0);
|
||||||
testObjMeshMutable.data = testObjMesh;
|
colorCubeMeshMutable.data = CreateCube3D(5.0);
|
||||||
testObjMeshMutable.RefreshVBO();
|
colorCubeMeshMutable.RefreshVBO();
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
//textMesh = ZL::LoadFromTextFile("./textures/mesh_first_room.txt");
|
|
||||||
textMesh = ZL::LoadFromTextFile("./oneroom001.txt");
|
loadingThread = std::thread([this]() {
|
||||||
textMesh.Scale(10);
|
|
||||||
textMesh.SwapZandY();
|
textMesh = ZL::LoadFromTextFile("./oneroom001.txt");
|
||||||
textMesh.RotateByMatrix(QuatToMatrix(QuatFromRotateAroundX(M_PI * 0.5)));
|
violaIdleModel.LoadFromFile("./idleviola001.txt");
|
||||||
textMesh.Move(Vector3f{0, 93, 0});
|
violaWalkModel.LoadFromFile("./walkviolla001.txt");
|
||||||
|
sideThreadLoadingCompleted = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
std::function<bool()> loadingFunction2 = [this]()
|
||||||
|
{
|
||||||
|
return sideThreadLoadingCompleted;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::function<bool()> loadingFunction3 = [this]()
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
testObjMesh = LoadFromObjFile("./chair_01.obj");
|
||||||
|
testObjMesh.Scale(10);
|
||||||
|
testObjMesh.SwapZandY();
|
||||||
|
testObjMeshMutable.data = testObjMesh;
|
||||||
|
testObjMeshMutable.RefreshVBO();*/
|
||||||
|
|
||||||
|
|
||||||
|
textMesh.Scale(10);
|
||||||
|
textMesh.SwapZandY();
|
||||||
|
textMesh.RotateByMatrix(QuatToMatrix(QuatFromRotateAroundX(M_PI * 0.5)));
|
||||||
|
textMesh.Move(Vector3f{ 0, 93, 0 });
|
||||||
|
|
||||||
coneMesh = ZL::LoadFromTextFile("./cone001.txt"); // Add ZL:: namespace
|
coneMesh = ZL::LoadFromTextFile("./cone001.txt"); // Add ZL:: namespace
|
||||||
coneMesh.Scale(200);
|
coneMesh.Scale(200);
|
||||||
|
|
||||||
textMeshMutable.AssignFrom(textMesh);
|
|
||||||
textMeshMutable.RefreshVBO();
|
|
||||||
coneMeshMutable.AssignFrom(coneMesh);
|
|
||||||
coneMeshMutable.RefreshVBO();
|
|
||||||
|
|
||||||
// Load bone animations
|
textMeshMutable.AssignFrom(textMesh);
|
||||||
//bx.LoadFromFile("./violetta001.txt");
|
textMeshMutable.RefreshVBO();
|
||||||
violaIdleModel.LoadFromFile("./idleviola001.txt");
|
//coneMeshMutable.AssignFrom(coneMesh);
|
||||||
violaWalkModel.LoadFromFile("./walkviolla001.txt");
|
//coneMeshMutable.RefreshVBO();
|
||||||
|
|
||||||
// Create active object
|
|
||||||
ActiveObject ao1;
|
|
||||||
ao1.name = "book";
|
|
||||||
ao1.activeObjectMesh = ZL::LoadFromTextFile("./book001.txt"); // Add ZL:: namespace
|
|
||||||
ao1.activeObjectMesh.Scale(4);
|
|
||||||
ao1.activeObjectMeshMutable.AssignFrom(ao1.activeObjectMesh);
|
|
||||||
ao1.activeObjectMeshMutable.RefreshVBO();
|
|
||||||
ao1.objectPos = Vector3f{50, 0, -300};
|
|
||||||
ao1.activeObjectTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./book03.bmp"));
|
|
||||||
ao1.activeObjectScreenTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./aoscreen01.bmp"));
|
|
||||||
ao1.activeObjectScreenMesh = CreateRect2D({ 0.f, 0.f }, { 64.f, 64.f }, 0.5);
|
|
||||||
ao1.activeObjectScreenMeshMutable.AssignFrom(ao1.activeObjectScreenMesh);
|
|
||||||
ao1.activeObjectScreenMeshMutable.RefreshVBO();
|
|
||||||
|
|
||||||
/*
|
// Create active object
|
||||||
ActiveObject ao2;
|
|
||||||
ao2.name = "superchair001";
|
|
||||||
ao2.activeObjectMesh = ZL::LoadFromTextFile("./superchair001.txt"); // Add ZL:: namespace
|
|
||||||
ao2.activeObjectMesh.Scale(400);
|
|
||||||
ao2.activeObjectMesh.SwapZandY();
|
|
||||||
ao2.activeObjectMeshMutable.AssignFrom(ao2.activeObjectMesh);
|
|
||||||
ao2.activeObjectMeshMutable.RefreshVBO();
|
|
||||||
ao2.objectPos = Vector3f{ 0, 0, 0 };
|
|
||||||
ao2.activeObjectTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./chair_01_Base_Color.bmp"));
|
|
||||||
|
|
||||||
ao2.activeObjectScreenTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./aoscreen01.bmp"));
|
ActiveObject ao1;
|
||||||
ao2.activeObjectScreenMesh = CreateRect2D({ 0.f, 0.f }, { 64.f, 64.f }, 0.5);
|
ao1.name = "book";
|
||||||
ao2.activeObjectScreenMeshMutable.AssignFrom(ao2.activeObjectScreenMesh);
|
ao1.activeObjectMesh = ZL::LoadFromTextFile("./book001.txt"); // Add ZL:: namespace
|
||||||
ao2.activeObjectScreenMeshMutable.RefreshVBO();
|
ao1.activeObjectMesh.Scale(4);
|
||||||
*/
|
ao1.activeObjectMeshMutable.AssignFrom(ao1.activeObjectMesh);
|
||||||
|
ao1.activeObjectMeshMutable.RefreshVBO();
|
||||||
|
ao1.objectPos = Vector3f{ 50, 0, -300 };
|
||||||
|
ao1.activeObjectTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./book03.bmp"));
|
||||||
|
ao1.activeObjectScreenTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./aoscreen01.bmp"));
|
||||||
|
ao1.activeObjectScreenMesh = CreateRect2D({ 0.f, 0.f }, { 64.f, 64.f }, 0.5);
|
||||||
|
ao1.activeObjectScreenMeshMutable.AssignFrom(ao1.activeObjectScreenMesh);
|
||||||
|
ao1.activeObjectScreenMeshMutable.RefreshVBO();
|
||||||
|
|
||||||
Room room_1;
|
/*
|
||||||
room_1.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Material_Base_color_1001.bmp"));
|
ActiveObject ao2;
|
||||||
room_1.objects.push_back(ao1);
|
ao2.name = "superchair001";
|
||||||
room_1.sound_name = "Symphony No.6 (1st movement).ogg";
|
ao2.activeObjectMesh = ZL::LoadFromTextFile("./superchair001.txt"); // Add ZL:: namespace
|
||||||
room_1.roomLogic = createRoom1Logic();
|
ao2.activeObjectMesh.Scale(400);
|
||||||
rooms.push_back(room_1);
|
ao2.activeObjectMesh.SwapZandY();
|
||||||
aoMgr.addActiveObject(ao1);
|
ao2.activeObjectMeshMutable.AssignFrom(ao2.activeObjectMesh);
|
||||||
|
ao2.activeObjectMeshMutable.RefreshVBO();
|
||||||
|
ao2.objectPos = Vector3f{ 0, 0, 0 };
|
||||||
|
ao2.activeObjectTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./chair_01_Base_Color.bmp"));
|
||||||
|
|
||||||
Room room_2;
|
ao2.activeObjectScreenTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./aoscreen01.bmp"));
|
||||||
room_2.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./background.bmp"));
|
ao2.activeObjectScreenMesh = CreateRect2D({ 0.f, 0.f }, { 64.f, 64.f }, 0.5);
|
||||||
room_2.sound_name = "Symphony No.6 (1st movement).ogg";
|
ao2.activeObjectScreenMeshMutable.AssignFrom(ao2.activeObjectScreenMesh);
|
||||||
room_2.roomLogic = createRoom1Logic();
|
ao2.activeObjectScreenMeshMutable.RefreshVBO();
|
||||||
rooms.push_back(room_2);
|
*/
|
||||||
|
|
||||||
activeObjects = rooms[current_room_index].objects;
|
|
||||||
|
|
||||||
// Initialize audio
|
|
||||||
/*
|
|
||||||
audioPlayer = std::make_unique<AudioPlayer>();
|
|
||||||
if (audioPlayer) {
|
|
||||||
audioPlayer->playMusic(rooms[current_room_index].sound_name);
|
|
||||||
}*/
|
|
||||||
audioPlayerAsync.resetAsync();
|
|
||||||
audioPlayerAsync.playMusicAsync(rooms[current_room_index].sound_name);
|
|
||||||
|
|
||||||
// Initialize inventory
|
Room room_1;
|
||||||
inventoryIconMesh = CreateRect2D(
|
room_1.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Material_Base_color_1001.bmp"));
|
||||||
{0.0f, 40.0f},
|
room_1.objects.push_back(ao1);
|
||||||
{INVENTORY_ICON_SIZE/2, INVENTORY_ICON_SIZE/2},
|
room_1.sound_name = "Symphony No.6 (1st movement).ogg";
|
||||||
0.5f
|
room_1.roomLogic = createRoom1Logic();
|
||||||
);
|
rooms.push_back(room_1);
|
||||||
inventoryIconMeshMutable.AssignFrom(inventoryIconMesh);
|
aoMgr.addActiveObject(ao1);
|
||||||
inventoryIconMeshMutable.RefreshVBO();
|
|
||||||
|
|
||||||
roomTexturePtr = rooms[current_room_index].roomTexture;
|
Room room_2;
|
||||||
|
room_2.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./background.bmp"));
|
||||||
|
room_2.sound_name = "Symphony No.6 (1st movement).ogg";
|
||||||
|
room_2.roomLogic = createRoom2Logic();
|
||||||
|
rooms.push_back(room_2);
|
||||||
|
|
||||||
AddItemToInventory("book1", std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")), objects_in_inventory+1);
|
activeObjects = rooms[current_room_index].objects;
|
||||||
objects_in_inventory++;
|
|
||||||
AddItemToInventory("book2", std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")), objects_in_inventory+1);
|
|
||||||
objects_in_inventory++;
|
|
||||||
|
|
||||||
//SDL_ShowCursor(SDL_DISABLE);
|
// Initialize audio
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
/*
|
||||||
|
audioPlayer = std::make_unique<AudioPlayer>();
|
||||||
|
if (audioPlayer) {
|
||||||
|
audioPlayer->playMusic(rooms[current_room_index].sound_name);
|
||||||
|
}*/
|
||||||
|
audioPlayerAsync.resetAsync();
|
||||||
|
audioPlayerAsync.playMusicAsync(rooms[current_room_index].sound_name);
|
||||||
|
|
||||||
// Устанавливаем границы комнаты 800x800
|
// Initialize inventory
|
||||||
collisionMgr.setRoomBoundary(800.0f, 800.0f);
|
inventoryIconMesh = CreateRect2D(
|
||||||
|
{ 0.0f, 40.0f },
|
||||||
|
{ INVENTORY_ICON_SIZE / 2, INVENTORY_ICON_SIZE / 2 },
|
||||||
|
0.5f
|
||||||
|
);
|
||||||
|
inventoryIconMeshMutable.AssignFrom(inventoryIconMesh);
|
||||||
|
inventoryIconMeshMutable.RefreshVBO();
|
||||||
|
|
||||||
// Создаем стены комнаты (толстые коллизии вдоль границ)
|
roomTexturePtr = rooms[current_room_index].roomTexture;
|
||||||
auto wallNorth = std::make_shared<CircleCollider>(Vector3f{0, 0, -350}, 50.0f);
|
|
||||||
auto wallSouth = std::make_shared<CircleCollider>(Vector3f{0, 0, 350}, 50.0f);
|
|
||||||
auto wallEast = std::make_shared<CircleCollider>(Vector3f{350, 0, 0}, 50.0f);
|
|
||||||
auto wallWest = std::make_shared<CircleCollider>(Vector3f{-350, 0, 0}, 50.0f);
|
|
||||||
|
|
||||||
collisionMgr.addCollider(wallNorth);
|
AddItemToInventory("book1", std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")), objects_in_inventory + 1);
|
||||||
collisionMgr.addCollider(wallSouth);
|
objects_in_inventory++;
|
||||||
collisionMgr.addCollider(wallEast);
|
AddItemToInventory("book2", std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp")), objects_in_inventory + 1);
|
||||||
collisionMgr.addCollider(wallWest);
|
objects_in_inventory++;
|
||||||
|
|
||||||
// Создаем точки коллизии
|
|
||||||
auto point1 = std::make_shared<CircleCollider>(Vector3f{125.0f, 0.0f, -214.0f}, 30.0f);
|
|
||||||
auto point2 = std::make_shared<CircleCollider>(Vector3f{380.0f, 0.0f, -206.0f}, 30.0f);
|
|
||||||
auto point3 = std::make_shared<CircleCollider>(Vector3f{385.0f, 0.0f, -377.0f}, 30.0f);
|
|
||||||
auto point4 = std::make_shared<CircleCollider>(Vector3f{112.0f, 0.0f, -377.0f}, 30.0f);
|
|
||||||
|
|
||||||
collisionMgr.addCollider(point1);
|
//SDL_ShowCursor(SDL_DISABLE);
|
||||||
collisionMgr.addCollider(point2);
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
collisionMgr.addCollider(point3);
|
|
||||||
collisionMgr.addCollider(point4);
|
|
||||||
|
|
||||||
// Создаем коллизию для кровати как прямоугольник
|
return true;
|
||||||
// Используем точки как границы прямоугольника
|
|
||||||
// Vector3f bedMin{112.0f, 0.0f, -377.0f}; // Минимальные координаты
|
|
||||||
// Vector3f bedMax{385.0f, 0.0f, 390.0f}; // Максимальные координаты
|
|
||||||
// auto bedCollider = std::make_shared<RectangleCollider>(bedMin, bedMax);
|
|
||||||
// collisionMgr.addCollider(bedCollider);
|
|
||||||
|
|
||||||
// Создаем линию коллизии по X (горизонтальная)
|
};
|
||||||
const float step = 20.0f; // Расстояние между точками коллизии
|
|
||||||
for(float x = 98.0f; x < 400.0f; x += step) {
|
|
||||||
auto point = std::make_shared<CircleCollider>(Vector3f{x, 0.0f, -200.0f}, 10.0f);
|
|
||||||
collisionMgr.addCollider(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Создаем линию коллизии по Z (вертикальная)
|
loadingFunctions.push_back(loadingFunction1);
|
||||||
for(float z = -200.0f; z > -400.0f; z -= step) {
|
loadingFunctions.push_back(loadingFunction2);
|
||||||
auto point = std::make_shared<CircleCollider>(Vector3f{400.0f, 0.0f, z}, 10.0f);
|
loadingFunctions.push_back(loadingFunction3);
|
||||||
collisionMgr.addCollider(point);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Добавляем линию коллизии от (105, 0, -235) до (105, 0, -350)
|
|
||||||
const float lineStartZ = -235.0f;
|
|
||||||
const float lineEndZ = -350.0f;
|
|
||||||
const float stepLine = 5.0f; // Шаг между коллайдерами
|
|
||||||
const float colliderRadius = 5.0f; // Радиус каждого коллайдера
|
|
||||||
for (float z = lineStartZ; z >= lineEndZ; z -= stepLine) {
|
|
||||||
auto lineCollider = std::make_shared<CircleCollider>(Vector3f{105.0f, 0.0f, z}, colliderRadius);
|
|
||||||
collisionMgr.addCollider(lineCollider);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameObjectManager::switch_room(int index){
|
void GameObjectManager::switch_room(int index){
|
||||||
@ -254,6 +247,11 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
|
|||||||
|
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
case SDLK_q:
|
case SDLK_q:
|
||||||
|
if (loadingThread.joinable())
|
||||||
|
{
|
||||||
|
loadingThread.join();
|
||||||
|
}
|
||||||
|
audioPlayerAsync.exit();
|
||||||
Environment::exitGameLoop = true;
|
Environment::exitGameLoop = true;
|
||||||
break;
|
break;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace ZL {
|
|||||||
|
|
||||||
class GameObjectManager {
|
class GameObjectManager {
|
||||||
public:
|
public:
|
||||||
|
void initializeLoadingScreen();
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
void switch_room(int index);
|
void switch_room(int index);
|
||||||
@ -29,11 +30,11 @@ public:
|
|||||||
std::shared_ptr<ZL::Texture> roomTexturePtr;
|
std::shared_ptr<ZL::Texture> roomTexturePtr;
|
||||||
std::shared_ptr<ZL::Texture> coneTexturePtr;
|
std::shared_ptr<ZL::Texture> coneTexturePtr;
|
||||||
|
|
||||||
ZL::VertexDataStruct colorCubeMesh;
|
//ZL::VertexDataStruct colorCubeMesh;
|
||||||
ZL::VertexRenderStruct colorCubeMeshMutable;
|
//ZL::VertexRenderStruct colorCubeMeshMutable;
|
||||||
|
|
||||||
ZL::VertexDataStruct testObjMesh;
|
//ZL::VertexDataStruct testObjMesh;
|
||||||
ZL::VertexRenderStruct testObjMeshMutable;
|
//ZL::VertexRenderStruct testObjMeshMutable;
|
||||||
|
|
||||||
ZL::BoneSystem violaIdleModel;
|
ZL::BoneSystem violaIdleModel;
|
||||||
ZL::VertexRenderStruct violaIdleModelMutable;
|
ZL::VertexRenderStruct violaIdleModelMutable;
|
||||||
@ -44,8 +45,8 @@ public:
|
|||||||
ZL::VertexDataStruct textMesh;
|
ZL::VertexDataStruct textMesh;
|
||||||
ZL::VertexRenderStruct textMeshMutable;
|
ZL::VertexRenderStruct textMeshMutable;
|
||||||
|
|
||||||
ZL::VertexDataStruct coneMesh;
|
//ZL::VertexDataStruct coneMesh;
|
||||||
ZL::VertexRenderStruct coneMeshMutable;
|
//ZL::VertexRenderStruct coneMeshMutable;
|
||||||
|
|
||||||
std::vector<ZL::ActiveObject> activeObjects;
|
std::vector<ZL::ActiveObject> activeObjects;
|
||||||
std::vector<ZL::Room> rooms;
|
std::vector<ZL::Room> rooms;
|
||||||
@ -60,7 +61,15 @@ public:
|
|||||||
ActiveObjectManager aoMgr;
|
ActiveObjectManager aoMgr;
|
||||||
int objects_in_inventory;
|
int objects_in_inventory;
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<ZL::Texture> loadingScreenTexturePtr;
|
||||||
|
|
||||||
|
ZL::VertexDataStruct loadingScreenMesh;
|
||||||
|
ZL::VertexRenderStruct loadingScreenMeshMutable;
|
||||||
|
|
||||||
|
std::list<std::function<bool()>> loadingFunctions;
|
||||||
|
std::thread loadingThread;
|
||||||
|
bool sideThreadLoadingCompleted = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//int animationCounter = 0;
|
//int animationCounter = 0;
|
||||||
|
|||||||
BIN
Material_Base_color_1001.bmp
Normal file
BIN
Material_Base_color_1001.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 MiB |
@ -26,20 +26,16 @@ void RenderSystem::drawScene(GameObjectManager& gameObjects) {
|
|||||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
glViewport(0, 0, Environment::width, Environment::height);
|
glViewport(0, 0, Environment::width, Environment::height);
|
||||||
/*
|
|
||||||
renderer.shaderManager.PushShader(defaultShaderName);
|
|
||||||
renderer.RenderUniform1i(textureUniformName, 0);
|
|
||||||
|
|
||||||
renderer.EnableVertexAttribArray(vPositionName);
|
if (Environment::gameIsLoading)
|
||||||
renderer.EnableVertexAttribArray(vTexCoordName);
|
{
|
||||||
*/
|
drawLoadingScreen(gameObjects);
|
||||||
drawWorld(gameObjects);
|
}
|
||||||
drawUI(gameObjects);
|
else
|
||||||
|
{
|
||||||
/*renderer.DisableVertexAttribArray(vPositionName);
|
drawWorld(gameObjects);
|
||||||
renderer.DisableVertexAttribArray(vTexCoordName);
|
drawUI(gameObjects);
|
||||||
renderer.shaderManager.PopShader();*/
|
}
|
||||||
|
|
||||||
CheckGlError();
|
CheckGlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +273,35 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
|
|||||||
renderer.shaderManager.PopShader();
|
renderer.shaderManager.PopShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderSystem::drawLoadingScreen(const GameObjectManager& gameObjects)
|
||||||
|
{
|
||||||
|
renderer.shaderManager.PushShader("default");
|
||||||
|
|
||||||
|
// Если шейдер ожидает атрибуты вершин, их нужно включить
|
||||||
|
static const std::string vPositionName = "vPosition";
|
||||||
|
static const std::string vTexCoordName = "vTexCoord";
|
||||||
|
renderer.EnableVertexAttribArray(vPositionName);
|
||||||
|
renderer.EnableVertexAttribArray(vTexCoordName);
|
||||||
|
|
||||||
|
renderer.PushProjectionMatrix(static_cast<float>(Environment::width),
|
||||||
|
static_cast<float>(Environment::height));
|
||||||
|
renderer.PushMatrix();
|
||||||
|
renderer.LoadIdentity();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, gameObjects.loadingScreenTexturePtr->getTexID());
|
||||||
|
renderer.DrawVertexRenderStruct(gameObjects.loadingScreenMeshMutable);
|
||||||
|
|
||||||
|
renderer.PopMatrix();
|
||||||
|
renderer.PopProjectionMatrix();
|
||||||
|
|
||||||
|
// Выключаем атрибуты, чтобы сохранить баланс
|
||||||
|
renderer.DisableVertexAttribArray(vPositionName);
|
||||||
|
renderer.DisableVertexAttribArray(vTexCoordName);
|
||||||
|
|
||||||
|
// Снимаем шейдер, тем самым балансируя стек
|
||||||
|
renderer.shaderManager.PopShader();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void RenderSystem::worldToScreenCoordinates(Vector3f objectPos,
|
void RenderSystem::worldToScreenCoordinates(Vector3f objectPos,
|
||||||
Matrix4f projectionModelView,
|
Matrix4f projectionModelView,
|
||||||
|
|||||||
@ -24,6 +24,8 @@ private:
|
|||||||
|
|
||||||
void drawViola(GameObjectManager& gameObjects);
|
void drawViola(GameObjectManager& gameObjects);
|
||||||
|
|
||||||
|
void drawLoadingScreen(const GameObjectManager& gameObjects);
|
||||||
|
|
||||||
Renderer renderer;
|
Renderer renderer;
|
||||||
ShaderManager shaderManager;
|
ShaderManager shaderManager;
|
||||||
Matrix4f currentProjectionModelView; // Добавлено для хранения матрицы между drawWorld и drawUI
|
Matrix4f currentProjectionModelView; // Добавлено для хранения матрицы между drawWorld и drawUI
|
||||||
|
|||||||
BIN
loading.bmp
Normal file
BIN
loading.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 768 KiB |
4833
oneroom001.txt
Normal file
4833
oneroom001.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user