Working on new locations
This commit is contained in:
1 parent
fb7b42ddf9
commit
7e94009217
57 files changed
+732417
-528
No files matched your search
+2
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace ZL {
|
||||
|
||||
const float ATTACK_COOLDOWN_TIME = 2.3f;
|
||||
const float ATTACK_COOLDOWN_TIME = 1.6f;
|
||||
extern float x;
|
||||
extern float y;
|
||||
const float ATTACK_RANGE = 1.25f;
|
||||
@@ -99,6 +99,7 @@ void Character::forceReplan()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const Eigen::Vector3f normalizedTarget(requestedWalkTarget.x(), 0.f, requestedWalkTarget.z());
|
||||
pathWaypoints = pathPlanner(position, normalizedTarget);
|
||||
currentWaypointIndex = 0;
|
||||
|
||||
+42
-7
@@ -166,28 +166,42 @@ namespace ZL
|
||||
params1.dialoguesJsonPath = "resources/dialogue/sample_dialogues.json";
|
||||
params1.navigationJsonPath = "resources/config2/navigation.json";
|
||||
params1.scriptPath = "resources/start.lua";
|
||||
params1.playerPosition = Eigen::Vector3f::Zero();
|
||||
params1.teleportPosition = Eigen::Vector3f(-2.03001f, 0.f, -4.95618f);
|
||||
params1.playerPosition = Eigen::Vector3f(0.942694, 0, -9.63104);
|
||||
params1.teleportPosition = Eigen::Vector3f(2.64621, 0, -9.37259);
|
||||
params1.teleportRadius = 1.5f;
|
||||
|
||||
location1 = std::make_shared<Location>(renderer, inventory);
|
||||
location1->setup(params1);
|
||||
|
||||
|
||||
LocationSetup params2 = params1;
|
||||
params2.roomMeshPath = "resources/w/exterior/Segmented_Plane002.txt";
|
||||
params2.roomTexturePath = "resources/w/exterior/Segmented_Plane002.png";
|
||||
params2.gameObjectsJsonPath = "resources/config2/gameobjects2.json";
|
||||
params2.navigationJsonPath = "resources/config2/navigation2.json";
|
||||
params2.scriptPath = "resources/start2.lua";
|
||||
params2.playerPosition = Eigen::Vector3f(7.f, 0.f, 27.f);
|
||||
params2.playerPosition = Eigen::Vector3f(5, 0, -18.4);
|
||||
|
||||
params2.npcsJsonPath = "resources/config2/npcs2.json";
|
||||
params2.teleportPosition = Eigen::Vector3f(-6.45, 0.0, 7.82);
|
||||
params2.teleportPosition = Eigen::Vector3f(8.2, 0, -9.9);
|
||||
params2.teleportRadius = 1.5f;
|
||||
location2 = std::make_shared<Location>(renderer, inventory);
|
||||
location2->setup(params2);
|
||||
|
||||
LocationSetup params_dorm;
|
||||
params_dorm.roomMeshPath = "";
|
||||
params_dorm.roomTexturePath = "";
|
||||
params_dorm.gameObjectsJsonPath = "resources/config2/gameobjects_dorm.json";
|
||||
params_dorm.npcsJsonPath = "resources/config2/npcs_dorm.json";
|
||||
params_dorm.dialoguesJsonPath = "resources/dialogue/sample_dialogues.json";
|
||||
params_dorm.navigationJsonPath = "resources/config2/navigation_dorm.json";
|
||||
params_dorm.scriptPath = "resources/start_dorm.lua";
|
||||
params_dorm.playerPosition = Eigen::Vector3f(6.0357, 0, -16.0581);
|
||||
params_dorm.teleportPosition = Eigen::Vector3f(-8.32343, 0, -0.152264);
|
||||
params_dorm.teleportRadius = 1.5f;
|
||||
|
||||
location_dorm = std::make_shared<Location>(renderer, inventory);
|
||||
location_dorm->setup(params_dorm);
|
||||
|
||||
// Teleport callbacks: stepping into a location's zone hands the player
|
||||
// to the other location at *its* teleport position. We pre-arm the
|
||||
// destination's playerInTeleportZone so the player must walk out and
|
||||
@@ -211,7 +225,17 @@ namespace ZL
|
||||
currentLocation->playerInTeleportZone = true;
|
||||
};
|
||||
|
||||
currentLocation = location2;
|
||||
location_dorm->onTeleport = [this]() {
|
||||
std::cout << "[TELEPORT] location 2 -> location 1" << std::endl;
|
||||
currentLocation = location2;
|
||||
if (currentLocation->player) {
|
||||
currentLocation->player->position = currentLocation->teleportPosition;
|
||||
currentLocation->player->setTarget(currentLocation->teleportPosition);
|
||||
}
|
||||
currentLocation->playerInTeleportZone = true;
|
||||
};
|
||||
|
||||
currentLocation = location_dorm;
|
||||
|
||||
std::cout << "Load resurces step 5" << std::endl;
|
||||
|
||||
@@ -220,11 +244,18 @@ namespace ZL
|
||||
// Shadow mapping shaders
|
||||
#ifdef EMSCRIPTEN
|
||||
renderer.shaderManager.AddShaderFromFiles("shadow_depth", "resources/shaders/shadow_depth.vertex", "resources/shaders/shadow_depth_web.fragment", CONST_ZIP_FILE);
|
||||
std::cout << "Load resurces step 12x1" << std::endl;
|
||||
renderer.shaderManager.AddShaderFromFiles("shadow_depth_skinning", "resources/shaders/shadow_depth_skinning.vertex", "resources/shaders/shadow_depth_web.fragment", CONST_ZIP_FILE);
|
||||
std::cout << "Load resurces step 12x2" << std::endl;
|
||||
renderer.shaderManager.AddShaderFromFiles("default_shadow", "resources/shaders/default_shadow.vertex", "resources/shaders/default_shadow_web.fragment", CONST_ZIP_FILE);
|
||||
std::cout << "Load resurces step 12x3" << std::endl;
|
||||
renderer.shaderManager.AddShaderFromFiles("skinning_shadow", "resources/shaders/skinning_shadow.vertex", "resources/shaders/default_shadow_web.fragment", CONST_ZIP_FILE);
|
||||
std::cout << "Load resurces step 12x4" << std::endl;
|
||||
renderer.shaderManager.AddShaderFromFiles("fog_shadow", "resources/shaders/fog_shadow.vertex", "resources/shaders/fog_shadow_web.fragment", CONST_ZIP_FILE);
|
||||
std::cout << "Load resurces step 12x5" << std::endl;
|
||||
renderer.shaderManager.AddShaderFromFiles("fog_skinning_shadow", "resources/shaders/fog_skinning_shadow.vertex", "resources/shaders/fog_shadow_web.fragment", CONST_ZIP_FILE);
|
||||
std::cout << "Load resurces step 12x6" << std::endl;
|
||||
|
||||
#else
|
||||
renderer.shaderManager.AddShaderFromFiles("shadow_depth", "resources/shaders/shadow_depth.vertex", "resources/shaders/shadow_depth_desktop.fragment", CONST_ZIP_FILE);
|
||||
renderer.shaderManager.AddShaderFromFiles("shadow_depth_skinning", "resources/shaders/shadow_depth_skinning.vertex", "resources/shaders/shadow_depth_desktop.fragment", CONST_ZIP_FILE);
|
||||
@@ -496,12 +527,16 @@ namespace ZL
|
||||
|
||||
case SDLK_o:
|
||||
//y = y + 0.002;
|
||||
currentLocation->player->hp = 200;
|
||||
//currentLocation->player->hp = 200;
|
||||
//currentLocation->npcs[3]->walkSpeed += 0.02f;
|
||||
//std::cout << "Walk speed: " << currentLocation->npcs[3]->walkSpeed << std::endl;
|
||||
break;
|
||||
|
||||
case SDLK_k:
|
||||
//y = y - 0.002;
|
||||
std::cout << "Player pos: " << currentLocation->player->position.transpose() << std::endl;
|
||||
//currentLocation->npcs[3]->walkSpeed -= 0.02f;
|
||||
//std::cout << "Walk speed: " << currentLocation->npcs[3]->walkSpeed << std::endl;
|
||||
break;
|
||||
|
||||
case SDLK_p:
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace ZL {
|
||||
|
||||
std::shared_ptr<Location> location1;
|
||||
std::shared_ptr<Location> location2;
|
||||
std::shared_ptr<Location> location_dorm;
|
||||
|
||||
std::shared_ptr<Location> currentLocation;
|
||||
|
||||
Inventory inventory;
|
||||
|
||||
+12
-7
@@ -49,10 +49,11 @@ namespace ZL
|
||||
|
||||
void Location::setup(const LocationSetup& params)
|
||||
{
|
||||
/*
|
||||
roomTexture = renderer.textureManager.LoadFromPng(params.roomTexturePath, CONST_ZIP_FILE);
|
||||
roomMesh.data = LoadFromTextFile02(params.roomMeshPath, CONST_ZIP_FILE);
|
||||
roomMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
roomMesh.RefreshVBO();
|
||||
roomMesh.RefreshVBO();*/
|
||||
|
||||
// Load static game objects
|
||||
gameObjects = GameObjectLoader::loadAndCreateGameObjects(params.gameObjectsJsonPath, renderer, CONST_ZIP_FILE);
|
||||
@@ -349,6 +350,10 @@ namespace ZL
|
||||
std::cout << "[RAYCAST_NPC] Starting raycast with " << npcs.size() << " npcs" << std::endl;
|
||||
|
||||
for (auto& npc : npcs) {
|
||||
if (npc->hp <= 0.f) {
|
||||
std::cout << "[RAYCAST_NPC] " << npc->npcId << " is dead, skipping" << std::endl;
|
||||
continue;
|
||||
}
|
||||
const float dx = rayOrigin.x() - npc->position.x();
|
||||
const float dz = rayOrigin.z() - npc->position.z();
|
||||
const float a = rayDir.x() * rayDir.x() + rayDir.z() * rayDir.z();
|
||||
@@ -425,8 +430,8 @@ namespace ZL
|
||||
const Eigen::Vector3f& camTarget = player ? player->position : Eigen::Vector3f::Zero();
|
||||
renderer.TranslateMatrix({ -camTarget.x(), -camTarget.y(), -camTarget.z() });
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, roomTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(roomMesh);
|
||||
//glBindTexture(GL_TEXTURE_2D, roomTexture->getTexID());
|
||||
//renderer.DrawVertexRenderStruct(roomMesh);
|
||||
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
|
||||
@@ -517,7 +522,7 @@ namespace ZL
|
||||
renderer.PushSpecialMatrix(lightView);
|
||||
|
||||
// Draw static geometry
|
||||
renderer.DrawVertexRenderStruct(roomMesh);
|
||||
//renderer.DrawVertexRenderStruct(roomMesh);
|
||||
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
@@ -603,8 +608,8 @@ namespace ZL
|
||||
#endif
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
glBindTexture(GL_TEXTURE_2D, roomTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(roomMesh);
|
||||
//glBindTexture(GL_TEXTURE_2D, roomTexture->getTexID());
|
||||
//renderer.DrawVertexRenderStruct(roomMesh);
|
||||
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
@@ -958,7 +963,7 @@ namespace ZL
|
||||
|
||||
// Check if we clicked on an NPC
|
||||
Character* clickedNpc = raycastNpcs(camPos, rayDir);
|
||||
if (clickedNpc && player && clickedNpc->hp > 0) {
|
||||
if (clickedNpc && player) {
|
||||
float distance = (player->position - clickedNpc->position).norm();
|
||||
int npcIndex = -1;
|
||||
for (size_t i = 0; i < npcs.size(); ++i) {
|
||||
|
||||
+2
-2
@@ -38,8 +38,8 @@ namespace ZL
|
||||
Location(Renderer& iRenderer, Inventory& iInventory);
|
||||
|
||||
|
||||
std::shared_ptr<Texture> roomTexture;
|
||||
VertexRenderStruct roomMesh;
|
||||
//std::shared_ptr<Texture> roomTexture;
|
||||
//VertexRenderStruct roomMesh;
|
||||
|
||||
std::unordered_map<std::string, LoadedGameObject> gameObjects;
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace ZL {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "ShaderManager",
|
||||
"Failed to compile vertex shader: %s", infoLog);
|
||||
#endif
|
||||
std::cout << "Vertex shader compilation failed: " << infoLog << std::endl;
|
||||
throw std::runtime_error("Failed to compile vertex shader code!");
|
||||
}
|
||||
|
||||
@@ -57,6 +58,8 @@ namespace ZL {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "ShaderManager",
|
||||
"Failed to compile fragment shader: %s", infoLog);
|
||||
#endif
|
||||
std::cout << "Fragment shader compilation failed: " << infoLog << std::endl;
|
||||
|
||||
throw std::runtime_error("Failed to compile fragment shader code!");
|
||||
}
|
||||
|
||||
|
||||
@@ -407,6 +407,7 @@ namespace ZL
|
||||
fileArr = !ZIPFileName.empty() ? readFileFromZIP(fullFileName, ZIPFileName) : readFile(fullFileName);
|
||||
|
||||
if (fileArr.empty()) {
|
||||
std::cout << "Could not read file data into memory: " << fullFileName << " zip file name: " << ZIPFileName << std::endl;
|
||||
throw std::runtime_error("Could not read file data into memory");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user