Skip to content

Commit

Permalink
setup mask editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaysmito101 committed Nov 19, 2023
1 parent b119c29 commit e471cef
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions TerraForge3D/include/Generators/BiomeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Generators/BiomeCustomBaseShape.h"
#include "Generators/GeneratorData.h"
#include "Generators/GeneratorTexture.h"
#include "Generators/MaskEditor.h"
#include "Base/Base.h"

class ApplicationState;
Expand Down Expand Up @@ -65,6 +66,8 @@ class BiomeManager
std::vector<int> m_Filters;
std::shared_ptr<DEMBaseShapeGenerator> m_DEMBaseShapeGenerator;

std::shared_ptr<MaskEditor> m_MaskEditor;

std::vector<std::shared_ptr<BiomeBaseShapeGenerator>> m_BaseShapeGenerators;
std::shared_ptr<BiomeBaseNoiseGenerator> m_BaseNoiseGenerator;
std::shared_ptr< BiomeCustomBaseShape> m_CustomBaseShape;
Expand Down
29 changes: 29 additions & 0 deletions TerraForge3D/include/Generators/MaskEditor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "Base/Base.h"
#include "Utils/Utils.h"
#include "Generators/GeneratorData.h"
#include "Generators/GeneratorTexture.h"
#include "Exporters/Serializer.h"
#include "Misc/CustomInspector.h"

class ApplicationState;

class MaskEditor
{
public:

MaskEditor(ApplicationState* state);
~MaskEditor();

void Resize(int size);

bool ShowSettings();

private:
ApplicationState* m_AppState = nullptr;

std::shared_ptr<GeneratorTexture> m_GeneratorTexture;
int m_Size = 256;
bool m_RequireUpdation = true;
};
6 changes: 6 additions & 0 deletions TerraForge3D/src/Generators/BiomeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bool BiomeManager::LoadUpResources()
m_BaseNoiseGenerator = std::make_shared<BiomeBaseNoiseGenerator>(m_AppState);
m_DEMBaseShapeGenerator = std::make_shared<DEMBaseShapeGenerator>(m_AppState);
m_CustomBaseShape = std::make_shared<BiomeCustomBaseShape>(m_AppState);
m_MaskEditor = std::make_shared<MaskEditor>(m_AppState);
return true;
}

Expand Down Expand Up @@ -62,6 +63,7 @@ void BiomeManager::Resize()
auto size = m_AppState->mainMap.tileResolution * m_AppState->mainMap.tileResolution * sizeof(float);
m_Data->Resize(size);
m_CustomBaseShape->Resize();
m_MaskEditor->Resize(m_AppState->mainMap.tileResolution);
m_RequireUpdation = true;
}

Expand Down Expand Up @@ -151,6 +153,10 @@ bool BiomeManager::ShowGeneralSettings()
ImGui::InputText("Biome Name", m_BiomeName, sizeof(m_BiomeName));
BIOME_UI_PROPERTY(ImGui::Checkbox("Enabled", &m_IsEnabled));
ImGui::ColorEdit3("Biome Color", reinterpret_cast<float*>(&m_Color));

BIOME_UI_PROPERTY(m_MaskEditor->ShowSettings());


if (ImGui::CollapsingHeader("Statistics"))
{
ImGui::Text("Time Taken: %f", m_CalculationTime);
Expand Down
28 changes: 28 additions & 0 deletions TerraForge3D/src/Generators/MaskEditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Generators/MaskEditor.h"
#include "Data/ApplicationState.h"

MaskEditor::MaskEditor(ApplicationState* state)
{
m_AppState = state;
m_GeneratorTexture = std::make_shared<GeneratorTexture>(m_Size, m_Size);
}

MaskEditor::~MaskEditor()
{
}

void MaskEditor::Resize(int size)
{

}

bool MaskEditor::ShowSettings()
{
ImGui::Separator();
ImGui::Text("Mask Editor");

ImGui::Image(m_GeneratorTexture->GetTextureID(), ImVec2(256, 256));

ImGui::Separator();
return false;
}

0 comments on commit e471cef

Please sign in to comment.