added loca2
This commit is contained in:
1 parent
1bf54b5367
commit
01be8852c6
9 files changed
+1587
-15
No files matched your search
+4
-2
@@ -499,7 +499,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 = { "default", "forest" };
|
||||
locIndex = (locIndex + 1) % locations.size();
|
||||
changeLocation(locations[locIndex]);
|
||||
break;
|
||||
@@ -509,7 +509,9 @@ namespace ZL
|
||||
break;
|
||||
|
||||
case SDLK_e:
|
||||
currentLocation->dialogueSystem.startDialogue("test_cutscene_pan_dialogue");
|
||||
//currentLocation->dialogueSystem.startDialogue("test_cutscene_pan_dialogue");
|
||||
currentLocation->navigation.build({}, "resources/config2/navigation2.json", CONST_ZIP_FILE);
|
||||
currentLocation->buildDebugNavMeshes();
|
||||
break;
|
||||
|
||||
case SDLK_p:
|
||||
|
||||
+150
-11
@@ -116,7 +116,7 @@ namespace ZL
|
||||
|
||||
}*/
|
||||
|
||||
void Location::setup()
|
||||
/*void Location::setup()
|
||||
{
|
||||
std::string roomTexPath;
|
||||
std::string roomMeshPath;
|
||||
@@ -201,12 +201,145 @@ namespace ZL
|
||||
|
||||
dialogueSystem.init(renderer, CONST_ZIP_FILE);
|
||||
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
|
||||
}*/
|
||||
|
||||
void Location::setup()
|
||||
{
|
||||
if (locationId == "forest")
|
||||
{
|
||||
std::cout << "[LOCATION] Setting up FOREST location (custom models only)" << std::endl;
|
||||
|
||||
gameObjects.clear();
|
||||
interactiveObjects.clear();
|
||||
npcs.clear();
|
||||
debugNavMeshes.clear();
|
||||
|
||||
roomMesh.data = VertexDataStruct();
|
||||
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},
|
||||
{"resources/out/floor001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/roof001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/Walls001.txt", "resources/ghost_avatar.png", {0.0f, 2.0f, 0.0f}, 2.0f},
|
||||
{"resources/out/Price001.txt", "resources/w/blue.png", {0.0f, 1.0f, 5.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["forest_model_" + std::to_string(i)] = std::move(obj);
|
||||
}
|
||||
|
||||
auto playerTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/gg/IMG_20260413_182354_992.png", CONST_ZIP_FILE));
|
||||
player = std::make_unique<Character>();
|
||||
player->loadBinaryAnimation(AnimationState::STAND, "resources/w/gg/gg_stand_idle001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::WALK, "resources/w/gg/gg_walking001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::STAND_TO_ACTION, "resources/w/gg/gg_stand_to_action002.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::ACTION_ATTACK, "resources/w/gg/gg_action_attack001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::ACTION_IDLE, "resources/w/gg/gg_action_idle001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::ACTION_TO_STAND, "resources/w/gg/gg_action_to_stand001.anim", CONST_ZIP_FILE);
|
||||
player->setTexture(playerTexture);
|
||||
player->walkSpeed = 3.0f;
|
||||
player->rotationSpeed = 8.0f;
|
||||
player->modelScale = 1.f;
|
||||
player->modelCorrectionRotation = Eigen::Quaternionf(Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitY()));
|
||||
player->canAttack = true;
|
||||
player->isPlayer = true;
|
||||
|
||||
shadowMap = std::make_unique<ShadowMap>(2048, 40.0f, 0.1f, 100.0f);
|
||||
shadowMap->setLightDirection(Eigen::Vector3f(-0.5f, -1.0f, -0.3f));
|
||||
|
||||
setupNavigation();
|
||||
|
||||
scriptEngine.init(this, &inventory);
|
||||
dialogueSystem.init(renderer, CONST_ZIP_FILE);
|
||||
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
|
||||
|
||||
std::cout << "[FOREST] Setup complete, loaded " << gameObjects.size() << " custom models" << std::endl;
|
||||
}
|
||||
else // default
|
||||
{
|
||||
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";
|
||||
std::string interactiveObjectsPath = "resources/config2/gameobjects.json";
|
||||
std::string npcsPath = "resources/config2/npcs.json";
|
||||
|
||||
roomTexture = std::make_unique<Texture>(CreateTextureDataFromPng(roomTexPath.c_str(), CONST_ZIP_FILE));
|
||||
roomMesh.data = LoadFromTextFile02(roomMeshPath.c_str(), CONST_ZIP_FILE);
|
||||
roomMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
roomMesh.RefreshVBO();
|
||||
|
||||
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->loadBinaryAnimation(AnimationState::STAND, "resources/w/gg/gg_stand_idle001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::WALK, "resources/w/gg/gg_walking001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::STAND_TO_ACTION, "resources/w/gg/gg_stand_to_action002.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::ACTION_ATTACK, "resources/w/gg/gg_action_attack001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::ACTION_IDLE, "resources/w/gg/gg_action_idle001.anim", CONST_ZIP_FILE);
|
||||
player->loadBinaryAnimation(AnimationState::ACTION_TO_STAND, "resources/w/gg/gg_action_to_stand001.anim", CONST_ZIP_FILE);
|
||||
player->setTexture(playerTexture);
|
||||
player->walkSpeed = 3.0f;
|
||||
player->rotationSpeed = 8.0f;
|
||||
player->modelScale = 1.f;
|
||||
player->modelCorrectionRotation = Eigen::Quaternionf(Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitY()));
|
||||
player->canAttack = true;
|
||||
player->isPlayer = true;
|
||||
|
||||
auto ghostTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/ghost_skin001.png", CONST_ZIP_FILE));
|
||||
auto npc02 = std::make_unique<Character>();
|
||||
npc02->loadBinaryAnimation(AnimationState::STAND, "resources/w/default_float001.anim", CONST_ZIP_FILE);
|
||||
npc02->loadBinaryAnimation(AnimationState::WALK, "resources/w/default_float001.anim", CONST_ZIP_FILE);
|
||||
npc02->loadBinaryAnimation(AnimationState::ACTION_IDLE, "resources/w/float_attack003_cut.anim", CONST_ZIP_FILE);
|
||||
npc02->loadBinaryAnimation(AnimationState::ACTION_ATTACK, "resources/w/float_attack003.anim", CONST_ZIP_FILE);
|
||||
npc02->loadBinaryAnimation(AnimationState::STAND_TO_ACTION, "resources/w/default_float001_cut.anim", CONST_ZIP_FILE);
|
||||
npc02->loadBinaryAnimation(AnimationState::ACTION_TO_STAND, "resources/w/default_float001_cut.anim", CONST_ZIP_FILE);
|
||||
npc02->setTexture(ghostTexture);
|
||||
npc02->walkSpeed = 1.5f;
|
||||
npc02->rotationSpeed = 8.0f;
|
||||
npc02->modelScale = 0.01f;
|
||||
npc02->modelCorrectionRotation = Eigen::Quaternionf(Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitY()));
|
||||
npc02->position = Eigen::Vector3f(0.f, 0.f, -20.f);
|
||||
npc02->setTarget(npc02->position);
|
||||
npc02->canAttack = true;
|
||||
npc02->attackTarget = player.get();
|
||||
npcs.push_back(std::move(npc02));
|
||||
|
||||
shadowMap = std::make_unique<ShadowMap>(2048, 40.0f, 0.1f, 100.0f);
|
||||
shadowMap->setLightDirection(Eigen::Vector3f(-0.5f, -1.0f, -0.3f));
|
||||
|
||||
setupNavigation();
|
||||
scriptEngine.init(this, &inventory);
|
||||
dialogueSystem.init(renderer, CONST_ZIP_FILE);
|
||||
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
|
||||
}
|
||||
}
|
||||
|
||||
void Location::setupNavigation()
|
||||
{
|
||||
|
||||
std::vector<PathFinder::ObstacleMesh> obstacles;
|
||||
obstacles.reserve(gameObjects.size() + interactiveObjects.size());
|
||||
/*obstacles.reserve(gameObjects.size() + interactiveObjects.size());
|
||||
|
||||
for (const auto& item : gameObjects) {
|
||||
const LoadedGameObject& gameObj = item.second;
|
||||
@@ -218,13 +351,17 @@ namespace ZL
|
||||
continue;
|
||||
}
|
||||
obstacles.push_back({ &intObj.mesh.data, intObj.position });
|
||||
}*/
|
||||
|
||||
if (locationId == "forest") {
|
||||
navigation.build(obstacles, "resources/config2/navigation2.json", CONST_ZIP_FILE);
|
||||
}
|
||||
|
||||
navigation.build(obstacles, "resources/config2/navigation.json", CONST_ZIP_FILE);
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
else {
|
||||
navigation.build(obstacles, "resources/config2/navigation.json", CONST_ZIP_FILE);
|
||||
}
|
||||
//#ifdef SHOW_PATH
|
||||
buildDebugNavMeshes();
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
auto planner = [this](const Eigen::Vector3f& start, const Eigen::Vector3f& end) {
|
||||
return navigation.findPath(start, end);
|
||||
@@ -241,7 +378,7 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
//#ifdef SHOW_PATH
|
||||
void Location::buildDebugNavMeshes()
|
||||
{
|
||||
debugNavMeshes.clear();
|
||||
@@ -268,7 +405,7 @@ namespace ZL
|
||||
renderer.shaderManager.PopShader();
|
||||
renderer.SetMatrix();
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
InteractiveObject* Location::raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir) {
|
||||
@@ -400,9 +537,9 @@ namespace ZL
|
||||
if (player) player->draw(renderer);
|
||||
for (auto& npc : npcs) npc->draw(renderer);
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
//#ifdef SHOW_PATH
|
||||
drawDebugNavigation();
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
@@ -571,6 +708,8 @@ namespace ZL
|
||||
#endif
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
|
||||
drawDebugNavigation();
|
||||
|
||||
renderer.PopMatrix();
|
||||
renderer.PopProjectionMatrix();
|
||||
renderer.shaderManager.PopShader();
|
||||
|
||||
+2
-2
@@ -42,11 +42,11 @@ namespace ZL
|
||||
ScriptEngine scriptEngine;
|
||||
Dialogue::DialogueSystem dialogueSystem;
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
//#ifdef SHOW_PATH
|
||||
std::vector<VertexRenderStruct> debugNavMeshes;
|
||||
void buildDebugNavMeshes();
|
||||
void drawDebugNavigation();
|
||||
#endif
|
||||
//#endif
|
||||
bool rightMouseDown = false;
|
||||
int lastMouseX = 0;
|
||||
int lastMouseY = 0;
|
||||
|
||||
Reference in new issue
Block a user