Merge branch 'escape001' of gitea.fishrungames.com:salmon-engine-projects/space-game001 into escape001
This commit is contained in:
commit
c6bd5385e3
32 files changed
+8731
-21
No files matched your search
+2
-2
@@ -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
@@ -26,6 +26,7 @@ namespace ZL
|
||||
, inventory(iInventory)
|
||||
, locationId(locId)
|
||||
, roofObjectKey("")
|
||||
, azsRoofObjectKey("")
|
||||
{
|
||||
|
||||
}
|
||||
@@ -154,12 +155,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();
|
||||
@@ -168,14 +175,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},
|
||||
@@ -193,12 +193,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);
|
||||
@@ -219,7 +225,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";
|
||||
@@ -234,7 +283,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);
|
||||
@@ -276,7 +325,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");
|
||||
@@ -530,6 +579,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);
|
||||
}
|
||||
@@ -601,8 +653,8 @@ void Location::setup()
|
||||
for (auto& npc : npcs) npc->draw(renderer);
|
||||
|
||||
//#ifdef SHOW_PATH
|
||||
//drawDebugNavigation();
|
||||
//drawDebugForbidden();
|
||||
drawDebugNavigation();
|
||||
drawDebugForbidden();
|
||||
//#endif
|
||||
|
||||
renderer.PopMatrix();
|
||||
@@ -661,6 +713,9 @@ void Location::setup()
|
||||
if (name == roofObjectKey && !roofVisible) {
|
||||
continue;
|
||||
}
|
||||
if (name == azsRoofObjectKey && !azsRoofVisible) {
|
||||
continue;
|
||||
}
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
|
||||
@@ -756,6 +811,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);
|
||||
}
|
||||
@@ -933,6 +991,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());
|
||||
@@ -945,6 +1004,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)
|
||||
|
||||
@@ -165,6 +165,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;
|
||||
bool isPointInCarFootprint(const Eigen::Vector3f& point, const Eigen::Vector3f& center, float rotation) const;
|
||||
bool doesPlayerCarCollideWithNpcCar(const Eigen::Vector3f& center, float rotation) const;
|
||||
|
||||
Reference in new issue
Block a user