heightmap previews
This commit is contained in:
@@ -400,7 +400,7 @@ namespace Game
|
||||
auto& staticCard = isValid ? staticCards[card.RefCard.Idx] : staticCards[0];
|
||||
|
||||
// World Tile
|
||||
tile.EData.Visible = IsActive;
|
||||
tile.EData.Visible = true;
|
||||
tile.EData.ModelH = staticCard.BaseModelHandle;
|
||||
tile.EData.TextureHandle = staticCard.ModelTextureHandle;
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace Game
|
||||
{
|
||||
cardPos = {x * Puzzle::Config::CardScaleWorld, -5.0f, y * Puzzle::Config::CardScaleWorld};
|
||||
}
|
||||
tile.EData.Transform.Position = cardPos;
|
||||
tile.EData.Transform.Position = cardPos + WorldPosition;
|
||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||
|
||||
// Covers
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Global.h"
|
||||
#include "Log.h"
|
||||
#include "Mesh.h"
|
||||
#include "bgfx/bgfx.h"
|
||||
#include "bx/bx.h"
|
||||
#include "bx/error.h"
|
||||
#include "bx/file.h"
|
||||
@@ -11,6 +12,7 @@
|
||||
#include "rendering/Rendering.h"
|
||||
|
||||
#include "Instance.h"
|
||||
#include <cstdint>
|
||||
|
||||
#define TINYGLTF_IMPLEMENTATION
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
@@ -21,6 +23,7 @@ namespace Game
|
||||
{
|
||||
bool LoadMesh(Model& mesh, const char* path, bool isBinary)
|
||||
{
|
||||
bx::strCopy(mesh.Name, sizeof(mesh.Name), path);
|
||||
mesh.VertLayout.begin()
|
||||
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Normal, 3, bgfx::AttribType::Float)
|
||||
@@ -94,6 +97,17 @@ namespace Game
|
||||
mesh.VertexBuffer = bgfx::createVertexBuffer(vbMem, mesh.VertLayout);
|
||||
}
|
||||
|
||||
for (uint32_t y = 0; y < HeightMap::Height; ++y)
|
||||
{
|
||||
for (uint32_t x = 0; x < HeightMap::Width; ++x)
|
||||
{
|
||||
mesh.Height.Values[y * HeightMap::Width + x] = (uint8_t)(((float)x / HeightMap::Width) * UINT8_MAX);
|
||||
}
|
||||
}
|
||||
const bgfx::Memory* mem = bgfx::makeRef(&mesh.Height.Values[0], sizeof(mesh.Height.Values));
|
||||
mesh.HeightMapTexture =
|
||||
bgfx::createTexture2D(HeightMap::Width, HeightMap::Height, false, 1, bgfx::TextureFormat::R8, 0, mem);
|
||||
|
||||
for (auto& node : model.nodes)
|
||||
{
|
||||
if (bx::strFindI(node.name.c_str(), "_slot_").getLength() > 0)
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
#include "Puzzle.h"
|
||||
#include "Tools.h"
|
||||
|
||||
#include "bgfx/bgfx.h"
|
||||
#include "bx/filepath.h"
|
||||
#include "bx/string.h"
|
||||
#include "bx/timer.h"
|
||||
#include "rendering/Rendering.h"
|
||||
#include <imgui.h>
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
@@ -269,10 +271,6 @@ namespace Tools
|
||||
{
|
||||
ImGui::TextColored({0.9f, 0.2f, 0.2f, 1.0f}, "Shader load Failiure!");
|
||||
}
|
||||
if (ImGui::Button("Reload Meshes"))
|
||||
{
|
||||
LoadModels(rendering.Models, rendering.ModelCount);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reload Level"))
|
||||
{
|
||||
@@ -395,6 +393,33 @@ namespace Tools
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void RenderModelsUI(Game::GameRendering& rendering)
|
||||
{
|
||||
if (ImGui::Begin("Models"))
|
||||
{
|
||||
if (ImGui::Button("Reload"))
|
||||
{
|
||||
LoadModels(rendering.Models, rendering.ModelCount);
|
||||
}
|
||||
for (int32_t i = 0; i < rendering.ModelCount; ++i)
|
||||
{
|
||||
auto& mdl = rendering.Models[i];
|
||||
if (bgfx::isValid(mdl.HeightMapTexture))
|
||||
{
|
||||
ImGui::Text("%s", mdl.Name);
|
||||
ImGui::Image(mdl.HeightMapTexture.idx,
|
||||
ImVec2{(float)Game::HeightMap::Height, (float)Game::HeightMap::Width});
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Invalid Handle!");
|
||||
}
|
||||
ImGui::Spacing();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void RenderPuzzlesUI()
|
||||
{
|
||||
auto& debug = Game::GetInstance().DebugData;
|
||||
@@ -405,6 +430,7 @@ namespace Tools
|
||||
char nameBuf[64]{0};
|
||||
for (int32_t i = 0; i < BX_COUNTOF(level.Puzzles); ++i)
|
||||
{
|
||||
ImGui::PushID(i);
|
||||
auto& puzzleData = level.Puzzles[i].Data;
|
||||
|
||||
bool isSelected = debug.SelectedDebugLevel == i;
|
||||
@@ -414,6 +440,9 @@ namespace Tools
|
||||
{
|
||||
debug.SelectedDebugLevel = isSelected ? UINT16_MAX : i;
|
||||
}
|
||||
ImGui::DragFloat3("Pos", &level.Puzzles[i].WorldPosition.x);
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
@@ -593,7 +622,7 @@ namespace Tools
|
||||
ImGui::Text("FPS: %.0f", 1.0 / time.Delta);
|
||||
|
||||
constexpr ImVec2 FpsPlotSize{200, 60};
|
||||
if (ImGui::BeginChild("FpsPlot", FpsPlotSize))
|
||||
if (ImGui::BeginChild("FpsPlot", FpsPlotSize, 0, ImGuiWindowFlags_NoInputs))
|
||||
{
|
||||
auto& drawList = *ImGui::GetWindowDrawList();
|
||||
ImVec2 pos = ImGui::GetWindowPos();
|
||||
@@ -659,6 +688,7 @@ namespace Tools
|
||||
RenderLogUI();
|
||||
RenderRenderSettingsUI(rendering);
|
||||
RenderTexturesUI(rendering);
|
||||
RenderModelsUI(rendering);
|
||||
RenderPuzzlesUI();
|
||||
RenderCardsUI(rendering);
|
||||
RenderEntitiesUI();
|
||||
|
||||
@@ -40,6 +40,13 @@ namespace Game
|
||||
char Name[MaxSocketNameLength]{};
|
||||
};
|
||||
|
||||
struct HeightMap
|
||||
{
|
||||
static constexpr uint32_t Width = 64;
|
||||
static constexpr uint32_t Height = 64;
|
||||
uint8_t Values[Width * Height]{0};
|
||||
};
|
||||
|
||||
struct Model
|
||||
{
|
||||
static constexpr uint16_t MaxSocketCount = 16;
|
||||
@@ -49,6 +56,9 @@ namespace Game
|
||||
Gen::ModelHandle Handle;
|
||||
uint16_t SocketCount = 0;
|
||||
ModelSocket Sockets[MaxSocketCount];
|
||||
HeightMap Height;
|
||||
bgfx::TextureHandle HeightMapTexture = {bgfx::kInvalidHandle};
|
||||
char Name[128]{0};
|
||||
};
|
||||
|
||||
struct Material
|
||||
|
||||
Reference in New Issue
Block a user