fix some / loca 1

This commit is contained in:
Vlad committed 2026-04-19 00:57:22 +06:00
1 parent 0d7d430909
commit bc62c34cf7
32 files changed
+8731 -21

No files matched your search

+2 -2
View File
@@ -144,7 +144,7 @@ namespace ZL
std::cout << "Load resurces step 4" << std::endl;
currentLocation = std::make_unique<Location>(renderer, inventory, "forest");
currentLocation = std::make_unique<Location>(renderer, inventory, "default");
currentLocation->setup();
@@ -507,7 +507,7 @@ namespace ZL
{
std::cout << "[GAME] Location change triggered by key press" << std::endl;
static size_t locIndex = 0;
static std::vector<std::string> locations = { "default", "forest" };
static std::vector<std::string> locations = {"forest", "default"};
locIndex = (locIndex + 1) % locations.size();
changeLocation(locations[locIndex]);
break;
+90 -18
View File
@@ -26,6 +26,7 @@ namespace ZL
, inventory(iInventory)
, locationId(locId)
, roofObjectKey("")
, azsRoofObjectKey("")
{
}
@@ -145,12 +146,18 @@ void Location::setup()
//girlfriend->canAttack = true;
//player->isPlayer = true;
struct ModelAsset {
const char* meshPath;
const char* texPath;
Eigen::Vector3f position;
float scale;
};
if (locationId == "forest")
{
std::cout << "[LOCATION] Setting up FOREST location (custom models only)" << std::endl;
gameObjects.clear();
/* gameObjects.clear();
interactiveObjects.clear();
npcs.clear();
debugNavMeshes.clear();
@@ -159,14 +166,7 @@ void Location::setup()
//roomMesh.data = LoadFromTextFile02("resources/w/road001.txt", CONST_ZIP_FILE);
//roomMesh.RefreshVBO();
roomTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/w/room005.png", CONST_ZIP_FILE));
struct ModelAsset {
const char* meshPath;
const char* texPath;
Eigen::Vector3f position;
float scale;
};
*/
std::vector<ModelAsset> models = {
{"resources/out/AzsBase001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
{"resources/out/AzsRoof001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
@@ -184,12 +184,18 @@ void Location::setup()
obj.mesh.data.Move(m.position);
obj.mesh.RefreshVBO();
obj.texture = std::make_shared<Texture>(CreateTextureDataFromPng(m.texPath, CONST_ZIP_FILE));
//gameObjects["forest_model_" + std::to_string(i)] = std::move(obj);
roofHideZones.clear();
roofHideZones.emplace_back(Eigen::Vector2f(-9.3f, -5.0f), Eigen::Vector2f(2.5f, 1.7f));
if (i == 3) {
if (std::string(m.meshPath) == "resources/out/AzsRoof001.txt") {
gameObjects["azsRoof"] = std::move(obj);
azsRoofObjectKey = "azsRoof";
azsRoofHideZones.clear();
azsRoofHideZones.emplace_back(Eigen::Vector2f(-7.0f, -14.0f), Eigen::Vector2f(0.1f, -8.5f));
}
else if (std::string(m.meshPath) == "resources/out/roof001.txt") {
gameObjects["roof"] = std::move(obj);
roofObjectKey = "roof";
roofHideZones.clear();
roofHideZones.emplace_back(Eigen::Vector2f(-9.3f, -5.0f), Eigen::Vector2f(2.5f, 1.7f));
}
else {
gameObjects["forest_model_" + std::to_string(i)] = std::move(obj);
@@ -210,7 +216,50 @@ void Location::setup()
}
else // default
{
std::cout << "[LOCATION] Setting up DEFAULT location" << std::endl;
std::vector<ModelAsset> models = {
{"resources/out/main/birch-1.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-11.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-2.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-22.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-3.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-33.txt", "resources/w/blue.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-4.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-44.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-5.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-55.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-6.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/birch-66.txt", "resources/w/blue.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube1.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube2.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube3.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube4.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube5.txt", "resources/w/blue.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube6.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube7.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube8.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube9.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube10.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube11.txt", "resources/w/blue.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube12.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube13.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube14.txt", "resources/ghost_avatar.png", {0.0f, 0.0f, 0.0f}, 2.0f},
{"resources/out/main/cube15.txt", "resources/w/blue.png", {0.0f, 0.0f, 0.0f}, 2.0f}
};
for (size_t i = 0; i < models.size(); ++i) {
const auto& m = models[i];
LoadedGameObject obj;
obj.mesh.data = LoadFromTextFile02(m.meshPath, CONST_ZIP_FILE);
obj.mesh.data.Scale(m.scale);
obj.mesh.data.Move(m.position);
obj.mesh.RefreshVBO();
obj.texture = std::make_shared<Texture>(CreateTextureDataFromPng(m.texPath, CONST_ZIP_FILE));
gameObjects["default_model_" + std::to_string(i)] = std::move(obj);
}
/*std::cout << "[LOCATION] Setting up DEFAULT location" << std::endl;
std::string roomTexPath = "resources/w/room005.png";
std::string roomMeshPath = "resources/w/room001.txt";
std::string gameObjectsPath = "resources/config2/gameobjects.json";
@@ -225,7 +274,7 @@ void Location::setup()
gameObjects = GameObjectLoader::loadAndCreateGameObjects(gameObjectsPath, renderer, CONST_ZIP_FILE);
interactiveObjects = GameObjectLoader::loadAndCreateInteractiveObjects(interactiveObjectsPath, renderer, CONST_ZIP_FILE);
npcs = GameObjectLoader::loadAndCreateNpcs(npcsPath, CONST_ZIP_FILE);
/*
auto playerTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/gg/IMG_20260413_182354_992.png", CONST_ZIP_FILE));
player = std::make_unique<Character>();
player->loadAnimation(AnimationState::STAND, "resources/e/woman_stand_idle003.txt", CONST_ZIP_FILE);
@@ -267,7 +316,7 @@ void Location::setup()
shadowMap = std::make_unique<ShadowMap>(2048, 40.0f, 0.1f, 100.0f);
shadowMap->setLightDirection(Eigen::Vector3f(-0.5f, -1.0f, -0.3f));
setupNavigation();
//setupNavigation();
scriptEngine.init(this, &inventory);
dialogueSystem.init(renderer, CONST_ZIP_FILE);
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
@@ -490,6 +539,9 @@ void Location::setup()
if (name == roofObjectKey && !roofVisible) {
continue;
}
if (name == azsRoofObjectKey && !azsRoofVisible) {
continue;
}
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
renderer.DrawVertexRenderStruct(gameObj.mesh);
}
@@ -558,8 +610,8 @@ void Location::setup()
for (auto& npc : npcs) npc->draw(renderer);
//#ifdef SHOW_PATH
//drawDebugNavigation();
//drawDebugForbidden();
drawDebugNavigation();
drawDebugForbidden();
//#endif
renderer.PopMatrix();
@@ -618,6 +670,9 @@ void Location::setup()
if (name == roofObjectKey && !roofVisible) {
continue;
}
if (name == azsRoofObjectKey && !azsRoofVisible) {
continue;
}
renderer.DrawVertexRenderStruct(gameObj.mesh);
}
@@ -713,6 +768,9 @@ void Location::setup()
if (name == roofObjectKey && !roofVisible) {
continue;
}
if (name == azsRoofObjectKey && !azsRoofVisible) {
continue;
}
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
renderer.DrawVertexRenderStruct(gameObj.mesh);
}
@@ -802,6 +860,7 @@ void Location::setup()
}
player->update(delta);
dialogueSystem.update(static_cast<int>(delta), player->position);
if (!roofObjectKey.empty()) {
bool insideAnyZone = false;
const Eigen::Vector2f playerPos2d(player->position.x(), player->position.z());
@@ -814,6 +873,19 @@ void Location::setup()
const float maxHeightForHide = 3.0f;
roofVisible = !(insideAnyZone && player->position.y() < maxHeightForHide);
}
if (!azsRoofObjectKey.empty()) {
bool insideAnyZone = false;
const Eigen::Vector2f playerPos2d(player->position.x(), player->position.z());
for (const auto& zone : azsRoofHideZones) {
if (zone.contains(playerPos2d)) {
insideAnyZone = true;
break;
}
}
const float maxHeightForHide = 3.0f;
azsRoofVisible = !(insideAnyZone && player->position.y() < maxHeightForHide);
}
}
if (girlfriend)
+4
View File
@@ -126,6 +126,10 @@ namespace ZL
bool roofVisible = true;
std::vector<Eigen::AlignedBox<float, 2>> roofHideZones;
std::string azsRoofObjectKey;
bool azsRoofVisible = true;
std::vector<Eigen::AlignedBox<float, 2>> azsRoofHideZones;
bool isCarFootprintWalkable(const Eigen::Vector3f& center, float rotation) const;
};