Added darklands
This commit is contained in:
1 parent
4e9eef1863
commit
c086fe1ef0
16 files changed
+351
-4
No files matched your search
@@ -270,6 +270,77 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
bool Location::startDarklandsTransition()
|
||||
{
|
||||
if (darklandsFlashActive) return false;
|
||||
darklandsFlashActive = true;
|
||||
darklandsFlashFadingIn = true;
|
||||
darklandsFlashAlpha = 0.0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Location::updateDarklandsFlash(int64_t deltaMs)
|
||||
{
|
||||
if (!darklandsFlashActive) return;
|
||||
static constexpr float kFadeDurationMs = 500.0f;
|
||||
const float step = static_cast<float>(deltaMs) / kFadeDurationMs;
|
||||
|
||||
if (darklandsFlashFadingIn) {
|
||||
darklandsFlashAlpha = min(darklandsFlashAlpha + step, 1.0f);
|
||||
if (darklandsFlashAlpha >= 1.0f) {
|
||||
isDarklands = !isDarklands;
|
||||
darklandsFlashFadingIn = false;
|
||||
}
|
||||
} else {
|
||||
darklandsFlashAlpha = max(darklandsFlashAlpha - step, 0.0f);
|
||||
if (darklandsFlashAlpha <= 0.0f) {
|
||||
darklandsFlashAlpha = 0.0f;
|
||||
darklandsFlashActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Location::drawDarklandsFlash()
|
||||
{
|
||||
if (darklandsFlashAlpha <= 0.001f) return;
|
||||
|
||||
const float W = static_cast<float>(Environment::projectionWidth);
|
||||
const float H = static_cast<float>(Environment::projectionHeight);
|
||||
|
||||
if (darklandsFlashQuadW != W || darklandsFlashQuadH != H) {
|
||||
darklandsFlashQuadW = W;
|
||||
darklandsFlashQuadH = H;
|
||||
VertexDataStruct data;
|
||||
data.PositionData = {
|
||||
{0.f, 0.f, 0.f}, {0.f, H, 0.f}, {W, H, 0.f},
|
||||
{W, H, 0.f}, {W, 0.f, 0.f}, {0.f, 0.f, 0.f}
|
||||
};
|
||||
data.TexCoordData = {
|
||||
{0.f, 0.f}, {0.f, 1.f}, {1.f, 1.f},
|
||||
{1.f, 1.f}, {1.f, 0.f}, {0.f, 0.f}
|
||||
};
|
||||
darklandsFlashQuad.data = std::move(data);
|
||||
darklandsFlashQuad.RefreshVBO();
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
renderer.shaderManager.PushShader("darklands_flash");
|
||||
renderer.PushProjectionMatrix(0.0f, W, 0.0f, H, -10.0f, 10.0f);
|
||||
renderer.PushMatrix();
|
||||
renderer.LoadIdentity();
|
||||
|
||||
renderer.RenderUniform1f("uAlpha", darklandsFlashAlpha);
|
||||
renderer.DrawVertexRenderStruct(darklandsFlashQuad);
|
||||
|
||||
renderer.PopMatrix();
|
||||
renderer.PopProjectionMatrix();
|
||||
renderer.shaderManager.PopShader();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void Location::setupNavigation(const std::vector<std::string>& paths)
|
||||
{
|
||||
navigationMapPaths = paths;
|
||||
@@ -520,6 +591,12 @@ namespace ZL
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isDarklands) {
|
||||
if (!intObj.loadedObject.textureDarklands) continue;
|
||||
} else {
|
||||
if (!intObj.loadedObject.texture) continue;
|
||||
}
|
||||
|
||||
//std::cout << "[RAYCAST] Position: (" << intObj.position.x() << ", " << intObj.position.y() << ", "
|
||||
// << intObj.position.z() << "), Radius: " << intObj.interactionRadius << std::endl;
|
||||
|
||||
@@ -656,6 +733,7 @@ namespace ZL
|
||||
|
||||
renderer.RenderUniform1f("uAlpha", 1.0f);
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (!gameObj.texture) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
@@ -699,6 +777,7 @@ namespace ZL
|
||||
if (npc) npc->drawHealthBar(renderer, currentView, proj);
|
||||
}
|
||||
}
|
||||
drawDarklandsFlash();
|
||||
}
|
||||
|
||||
void Location::drawShadowDepthPass()
|
||||
@@ -835,6 +914,7 @@ namespace ZL
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
renderer.RenderUniform1f("uAlpha", 1.0f);
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (!gameObj.texture) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, gameObj.texture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
@@ -897,6 +977,77 @@ namespace ZL
|
||||
if (npc) npc->drawHealthBar(renderer, cameraViewMatrix, proj);
|
||||
}
|
||||
}
|
||||
drawDarklandsFlash();
|
||||
}
|
||||
|
||||
void Location::drawGameDarklands()
|
||||
{
|
||||
glClearColor(0.05f, 0.05f, 0.2f, 1.0f);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
|
||||
renderer.shaderManager.PushShader("darklands_fog");
|
||||
renderer.RenderUniform1i(textureUniformName, 0);
|
||||
const float playerEyePos[3] = { 0.0f, 0.0f, -Environment::zoom };
|
||||
renderer.RenderUniform3fv("uPlayerEyePos", playerEyePos);
|
||||
|
||||
renderer.PushPerspectiveProjectionMatrix(1.0 / 1.5,
|
||||
static_cast<float>(Environment::width) / static_cast<float>(Environment::height),
|
||||
Environment::CONST_Z_NEAR, Environment::CONST_Z_FAR);
|
||||
renderer.PushMatrix();
|
||||
|
||||
renderer.LoadIdentity();
|
||||
renderer.TranslateMatrix({ 0, 0, -1.0f * Environment::zoom });
|
||||
|
||||
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(cameraInclination, Eigen::Vector3f::UnitX())).toRotationMatrix());
|
||||
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(cameraAzimuth, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
const Eigen::Vector3f& camTarget = player ? player->position : Eigen::Vector3f::Zero();
|
||||
renderer.TranslateMatrix({ -camTarget.x(), -camTarget.y(), -camTarget.z() });
|
||||
|
||||
renderer.RenderUniform1f("uAlpha", 1.0f);
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (!gameObj.textureDarklands) continue;
|
||||
glBindTexture(GL_TEXTURE_2D, gameObj.textureDarklands->getTexID());
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
|
||||
for (auto& intObj : interactiveObjects) {
|
||||
if (intObj.isActive) {
|
||||
intObj.drawDarklands(renderer);
|
||||
}
|
||||
}
|
||||
renderer.RenderUniform1f("uAlpha", 1.0f);
|
||||
const Eigen::Matrix4f currentView = renderer.GetCurrentModelViewMatrix();
|
||||
if (player) player->prepareHitSparksForDraw(currentView);
|
||||
for (auto& npc : npcs) npc->prepareHitSparksForDraw(currentView);
|
||||
for (auto& tz : teleportZones) tz.prepareForDraw(currentView);
|
||||
|
||||
if (player) player->draw(renderer);
|
||||
for (auto& npc : npcs) npc->draw(renderer);
|
||||
|
||||
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
|
||||
if (navigationEditorMode) {
|
||||
navigationEditorDrawNavigation();
|
||||
navigationEditorDrawPoints();
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
renderer.PopProjectionMatrix();
|
||||
renderer.shaderManager.PopShader();
|
||||
|
||||
if (npcNameText) {
|
||||
Eigen::Matrix4f proj = MakePerspectiveMatrix(1.0f / 1.5f,
|
||||
static_cast<float>(Environment::width) / static_cast<float>(Environment::height),
|
||||
Environment::CONST_Z_NEAR, Environment::CONST_Z_FAR);
|
||||
for (auto& npc : npcs) {
|
||||
if (npc) npc->drawName(*npcNameText, currentView, proj);
|
||||
}
|
||||
if (player) player->drawHealthBar(renderer, currentView, proj);
|
||||
for (auto& npc : npcs) {
|
||||
if (npc) npc->drawHealthBar(renderer, currentView, proj);
|
||||
}
|
||||
}
|
||||
drawDarklandsFlash();
|
||||
}
|
||||
|
||||
bool Location::setNavigationAreaAvailable(const std::string& areaName, bool available)
|
||||
@@ -1057,6 +1208,8 @@ namespace ZL
|
||||
|
||||
void Location::update(int64_t delta)
|
||||
{
|
||||
updateDarklandsFlash(delta);
|
||||
|
||||
for (auto& intObj : interactiveObjects) {
|
||||
intObj.update(delta);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user