summaryrefslogtreecommitdiffstats
path: root/Tools/BiomeVisualiser
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2013-12-09 18:51:12 +0100
committerworktycho <work.tycho@gmail.com>2013-12-09 18:51:12 +0100
commit843605d59ebc128be0a578dc6f45ef8c05da6e79 (patch)
tree3ffebc6ba27baf7a9e1d4bc51501ffeea9b14226 /Tools/BiomeVisualiser
parentmerged makefile changes (diff)
parentFix Undefined behavior at Bindings/LuaWindow line 32 (diff)
downloadcuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.tar
cuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.tar.gz
cuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.tar.bz2
cuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.tar.lz
cuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.tar.xz
cuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.tar.zst
cuberite-843605d59ebc128be0a578dc6f45ef8c05da6e79.zip
Diffstat (limited to 'Tools/BiomeVisualiser')
-rw-r--r--Tools/BiomeVisualiser/.gitignore3
-rw-r--r--Tools/BiomeVisualiser/BiomeCache.cpp5
-rw-r--r--Tools/BiomeVisualiser/BiomeCache.h2
-rw-r--r--Tools/BiomeVisualiser/BiomeColors.cpp114
-rw-r--r--Tools/BiomeVisualiser/BiomeColors.h15
-rw-r--r--Tools/BiomeVisualiser/BiomeRenderer.cpp36
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.cpp23
-rw-r--r--Tools/BiomeVisualiser/BiomeViewWnd.h19
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.cpp4
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.h2
-rw-r--r--Tools/BiomeVisualiser/BiomeVisualiser.vcproj106
-rw-r--r--Tools/BiomeVisualiser/GeneratorBiomeSource.h2
12 files changed, 249 insertions, 82 deletions
diff --git a/Tools/BiomeVisualiser/.gitignore b/Tools/BiomeVisualiser/.gitignore
new file mode 100644
index 000000000..b4e15dc3c
--- /dev/null
+++ b/Tools/BiomeVisualiser/.gitignore
@@ -0,0 +1,3 @@
+Debug/
+logs/
+Release/
diff --git a/Tools/BiomeVisualiser/BiomeCache.cpp b/Tools/BiomeVisualiser/BiomeCache.cpp
index b3c308422..7d9301d8f 100644
--- a/Tools/BiomeVisualiser/BiomeCache.cpp
+++ b/Tools/BiomeVisualiser/BiomeCache.cpp
@@ -258,6 +258,11 @@ void cBiomeCache::FilterOutItems(cItems & a_Items, int a_MinChunkX, int a_MaxChu
void cBiomeCache::thrProcessQueueItem(void)
{
+ if (m_Source == NULL)
+ {
+ return;
+ }
+
cItem * Item = NULL;
{
cCSLock Lock(m_CS);
diff --git a/Tools/BiomeVisualiser/BiomeCache.h b/Tools/BiomeVisualiser/BiomeCache.h
index bf1503d4c..da4d6c761 100644
--- a/Tools/BiomeVisualiser/BiomeCache.h
+++ b/Tools/BiomeVisualiser/BiomeCache.h
@@ -17,7 +17,7 @@ While the area is being filled, requests for biomes may already come, such reque
#include "BiomeSource.h"
-#include "../source/OSSupport/IsThread.h"
+#include "../src/OSSupport/IsThread.h"
diff --git a/Tools/BiomeVisualiser/BiomeColors.cpp b/Tools/BiomeVisualiser/BiomeColors.cpp
new file mode 100644
index 000000000..1fd0cb7a0
--- /dev/null
+++ b/Tools/BiomeVisualiser/BiomeColors.cpp
@@ -0,0 +1,114 @@
+
+// BiomeColors.cpp
+
+// Implements the g_BiomeColors[] array preparation based on a stored biome-to-color map
+
+#include "Globals.h"
+#include "BiomeColors.h"
+
+
+
+
+
+int g_BiomeColors[256];
+
+
+
+
+
+static struct
+{
+ EMCSBiome Biome;
+ int Color;
+} g_BiomeColorMap[] =
+{
+ { biOcean, 0x000070 },
+ { biPlains, 0x8db360 },
+ { biDesert, 0xfa9418 },
+ { biExtremeHills, 0x606060 },
+ { biForest, 0x056621 },
+ { biTaiga, 0x0b6659 },
+ { biSwampland, 0x2fffda },
+ { biRiver, 0x3030af },
+ { biHell, 0x7f0000 },
+ { biSky, 0x007fff },
+ { biFrozenOcean, 0xa0a0df },
+ { biFrozenRiver, 0xa0a0ff },
+ { biIcePlains, 0xffffff },
+ { biIceMountains, 0xa0a0a0 },
+ { biMushroomIsland, 0xff00ff },
+ { biMushroomShore, 0xa000ff },
+ { biBeach, 0xfade55 },
+ { biDesertHills, 0xd25f12 },
+ { biForestHills, 0x22551c },
+ { biTaigaHills, 0x163933 },
+ { biExtremeHillsEdge, 0x7f8f7f },
+ { biJungle, 0x537b09 },
+ { biJungleHills, 0x2c4205 },
+
+ { biJungleEdge, 0x628b17 },
+ { biDeepOcean, 0x000030 },
+ { biStoneBeach, 0xa2a284 },
+ { biColdBeach, 0xfaf0c0 },
+ { biBirchForest, 0x307444 },
+ { biBirchForestHills, 0x1f5f32 },
+ { biRoofedForest, 0x40511a },
+ { biColdTaiga, 0x31554a },
+ { biColdTaigaHills, 0x597d72 },
+ { biMegaTaiga, 0x596651 },
+ { biMegaTaigaHills, 0x596659 },
+ { biExtremeHillsPlus, 0x507050 },
+ { biSavanna, 0xbdb25f },
+ { biSavannaPlateau, 0xa79d64 },
+ { biMesa, 0xd94515 },
+ { biMesaPlateauF, 0xb09765 },
+ { biMesaPlateau, 0xca8c65 },
+
+ // M variants:
+ { biSunflowerPlains, 0xb5db88 },
+ { biDesertM, 0xffbc40 },
+ { biExtremeHillsM, 0x888888 },
+ { biFlowerForest, 0x2d8e49 },
+ { biTaigaM, 0x338e81 },
+ { biSwamplandM, 0x07f9b2 },
+ { biIcePlainsSpikes, 0xb4dcdc },
+ { biJungleM, 0x7ba331 },
+ { biJungleEdgeM, 0x628b17 },
+ { biBirchForestM, 0x589c6c },
+ { biBirchForestHillsM, 0x47875a },
+ { biRoofedForestM, 0x687942 },
+ { biColdTaigaM, 0x243f36 },
+ { biMegaSpruceTaiga, 0x454f3e },
+ { biMegaSpruceTaigaHills, 0x454f4e },
+ { biExtremeHillsPlusM, 0x789878 },
+ { biSavannaM, 0xe5da87 },
+ { biSavannaPlateauM, 0xa79d74 },
+ { biMesaBryce, 0xff6d3d },
+ { biMesaPlateauFM, 0xd8bf8d },
+ { biMesaPlateauM, 0xf2b48d },
+} ;
+
+
+
+
+
+static class cBiomeColorsInitializer
+{
+public:
+ cBiomeColorsInitializer(void)
+ {
+ // Reset all colors to gray:
+ for (size_t i = 0; i < ARRAYCOUNT(g_BiomeColors); i++)
+ {
+ g_BiomeColors[i] = 0x7f7f7f;
+ }
+ for (size_t i = 0; i < ARRAYCOUNT(g_BiomeColorMap); i++)
+ {
+ g_BiomeColors[g_BiomeColorMap[i].Biome] = g_BiomeColorMap[i].Color;
+ }
+ }
+} g_Initializer;
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeColors.h b/Tools/BiomeVisualiser/BiomeColors.h
new file mode 100644
index 000000000..0cb0f578c
--- /dev/null
+++ b/Tools/BiomeVisualiser/BiomeColors.h
@@ -0,0 +1,15 @@
+
+// BiomeColors.h
+
+// Declares the g_BiomeColors[] array used for biome color lookup
+
+
+
+
+
+extern int g_BiomeColors[256];
+
+
+
+
+
diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp
index 98548179c..758eb4b48 100644
--- a/Tools/BiomeVisualiser/BiomeRenderer.cpp
+++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp
@@ -7,6 +7,7 @@
#include "BiomeRenderer.h"
#include "Pixmap.h"
#include "Timer.h"
+#include "BiomeColors.h"
@@ -96,40 +97,11 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap)
int cBiomeRenderer::GetBiomeColor(EMCSBiome a_Biome)
{
- if ((a_Biome < 0) || (a_Biome > biMaxBiome))
+ if ((a_Biome < 0) || (a_Biome >= ARRAYCOUNT(g_BiomeColors)))
{
- return 0xcfcfcf; // LtGray for unknown biomes
+ return 0xff0000;
}
-
- static int BiomeColor[] =
- {
- // RGB:
- 0x0000ff, /* Ocean */
- 0x00cf3f, /* Plains */
- 0xffff00, /* Desert */
- 0x7f7f7f, /* Extreme Hills */
- 0x00cf00, /* Forest */
- 0x007f3f, /* Taiga */
- 0x3f7f00, /* Swampland */
- 0x003fff, /* River */
- 0x7f0000, /* Hell */
- 0x007fff, /* Sky */
- 0x3f3fff, /* Frozen Ocean */
- 0x3f3fff, /* Frozen River */
- 0x7fffcf, /* Ice Plains */
- 0x3fcf7f, /* Ice Mountains */
- 0xcf00cf, /* Mushroom Island */
- 0x7f00ff, /* Mushroom Island Shore */
- 0xffff3f, /* Beach */
- 0xcfcf00, /* Desert Hills */
- 0x00cf3f, /* Forest Hills */
- 0x006f1f, /* Taiga Hills */
- 0x7f8f7f, /* Extreme Hills Edge */
- 0x004f00, /* Jungle */
- 0x003f00, /* Jungle Hills */
- } ;
-
- return BiomeColor[a_Biome];
+ return g_BiomeColors[a_Biome];
}
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
index 3dd1bb4e0..5c1240bc7 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp
@@ -7,7 +7,7 @@
#include "BiomeViewWnd.h"
#include "BiomeCache.h"
#include "GeneratorBiomeSource.h"
-#include "../iniFile/iniFile.h"
+#include "iniFile/iniFile.h"
@@ -34,6 +34,8 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
{
ASSERT(m_Wnd == NULL);
+ InitBiomeView();
+
// Create a regular STATIC window, then override its window procedure with our own. No need for obnoxious RegisterWindowClass() stuff.
m_Wnd = CreateWindow("STATIC", a_Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 400, 300, a_ParentWnd, NULL, GetModuleHandle(NULL), NULL);
if (m_Wnd == NULL)
@@ -43,11 +45,6 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
}
SetWindowLongPtr(m_Wnd, GWLP_WNDPROC, m_Thunk);
- cIniFile IniFile;
- cBiomeGen * BioGen = new cBioGenMultiStepMap(2);
- BioGen->Initialize(IniFile);
- m_Renderer.SetSource(new cGeneratorBiomeSource(BioGen));
-
return true;
}
@@ -55,6 +52,20 @@ bool cBiomeViewWnd::Create(HWND a_ParentWnd, LPCTSTR a_Title)
+void cBiomeViewWnd::InitBiomeView(void)
+{
+ cIniFile IniFile;
+ IniFile.ReadFile("world.ini");
+ int Seed = IniFile.GetValueSetI("Generator", "Seed", 0);
+ bool CacheOffByDefault = false;
+ m_BiomeGen = cBiomeGen::CreateBiomeGen(IniFile, Seed, CacheOffByDefault);
+ m_Renderer.SetSource(new cGeneratorBiomeSource(m_BiomeGen));
+ IniFile.WriteFile("world.ini");
+}
+
+
+
+
LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam)
{
diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.h b/Tools/BiomeVisualiser/BiomeViewWnd.h
index 88e808ab3..e3f70c7e6 100644
--- a/Tools/BiomeVisualiser/BiomeViewWnd.h
+++ b/Tools/BiomeVisualiser/BiomeViewWnd.h
@@ -3,6 +3,12 @@
// Declares the cBiomeViewWnd class representing the window that displays biomes
+
+
+
+
+#pragma once
+
#include "WndProcThunk.h"
#include "BiomeRenderer.h"
#include "BiomeCache.h"
@@ -12,6 +18,13 @@
+// fwd:
+class cBiomeGen;
+
+
+
+
+
class cBiomeViewWnd
{
public:
@@ -26,9 +39,15 @@ protected:
cBiomeRenderer m_Renderer;
cPixmap m_Pixmap;
+ /// The generator that is to be visualised
+ cBiomeGen * m_BiomeGen;
+
bool m_IsLButtonDown;
POINT m_MouseDown;
+
+ void InitBiomeView(void);
+
LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam);
// Message handlers:
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.cpp b/Tools/BiomeVisualiser/BiomeVisualiser.cpp
index e1d379f83..a36111d77 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.cpp
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.cpp
@@ -21,8 +21,8 @@ int WINAPI WinMain(HINSTANCE a_Instance, HINSTANCE a_PrevInstance, LPSTR a_CmdLi
-cBiomeVisualiser::cBiomeVisualiser(void)
- // : m_Logger(Printf("BiomeVisualiser_%08x", time(NULL)))
+cBiomeVisualiser::cBiomeVisualiser(void) :
+ m_Logger(new cMCLogger(Printf("BiomeVisualiser_%08x.log", time(NULL))))
{
}
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.h b/Tools/BiomeVisualiser/BiomeVisualiser.h
index 3fa90646b..4f8ce7513 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.h
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.h
@@ -23,7 +23,7 @@ public:
protected:
cBiomeViewWnd m_MainWnd;
- cMCLogger m_Logger;
+ cMCLogger * m_Logger;
} ;
diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
index 522606d60..e42870b13 100644
--- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
+++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="../../source"
+ AdditionalIncludeDirectories="../../src;../../lib"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -119,7 +119,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../../source"
+ AdditionalIncludeDirectories="../../src;../../lib"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
@@ -199,7 +199,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../../source"
+ AdditionalIncludeDirectories="../../src;../../lib"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
@@ -269,6 +269,10 @@
>
</File>
<File
+ RelativePath=".\BiomeColors.cpp"
+ >
+ </File>
+ <File
RelativePath=".\BiomeRenderer.cpp"
>
</File>
@@ -320,19 +324,35 @@
Name="Shared"
>
<File
- RelativePath="..\..\source\BlockID.cpp"
+ RelativePath="..\..\src\BlockID.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\BlockID.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\ChunkDef.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\Enchantments.cpp"
>
</File>
<File
- RelativePath="..\..\source\BlockID.h"
+ RelativePath="..\..\src\Enchantments.h"
>
</File>
<File
- RelativePath="..\..\source\ChunkDef.h"
+ RelativePath="..\..\src\WorldStorage\FastNBT.cpp"
>
</File>
<File
- RelativePath="..\..\source\Globals.cpp"
+ RelativePath="..\..\src\WorldStorage\FastNBT.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\Globals.cpp"
>
<FileConfiguration
Name="Debug|Win32"
@@ -360,90 +380,94 @@
</FileConfiguration>
</File>
<File
- RelativePath="..\..\source\Globals.h"
+ RelativePath="..\..\src\Globals.h"
>
</File>
<File
- RelativePath="..\..\source\Log.cpp"
+ RelativePath="..\..\src\Item.h"
>
</File>
<File
- RelativePath="..\..\source\Log.h"
+ RelativePath="..\..\src\Log.cpp"
>
</File>
<File
- RelativePath="..\..\source\MCLogger.cpp"
+ RelativePath="..\..\src\Log.h"
>
</File>
<File
- RelativePath="..\..\source\MCLogger.h"
+ RelativePath="..\..\src\MCLogger.cpp"
>
</File>
<File
- RelativePath="..\..\source\Noise.cpp"
+ RelativePath="..\..\src\MCLogger.h"
>
</File>
<File
- RelativePath="..\..\source\Noise.h"
+ RelativePath="..\..\src\Noise.cpp"
>
</File>
<File
- RelativePath="..\..\source\Noise.inc"
+ RelativePath="..\..\src\Noise.h"
>
</File>
<File
- RelativePath="..\..\source\StringUtils.cpp"
+ RelativePath="..\..\src\Noise.inc"
>
</File>
<File
- RelativePath="..\..\source\StringUtils.h"
+ RelativePath="..\..\src\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\StringUtils.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\VoronoiMap.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\VoronoiMap.h"
>
</File>
<Filter
Name="OSSupport"
>
<File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ RelativePath="..\..\src\OSSupport\CriticalSection.cpp"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ RelativePath="..\..\src\OSSupport\CriticalSection.h"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\Event.cpp"
+ RelativePath="..\..\src\OSSupport\Event.cpp"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\Event.h"
+ RelativePath="..\..\src\OSSupport\Event.h"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\File.cpp"
+ RelativePath="..\..\src\OSSupport\File.cpp"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\File.h"
+ RelativePath="..\..\src\OSSupport\File.h"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ RelativePath="..\..\src\OSSupport\IsThread.cpp"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\IsThread.h"
+ RelativePath="..\..\src\OSSupport\IsThread.h"
>
</File>
<File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\Sleep.h"
+ RelativePath="..\..\src\OSSupport\Sleep.h"
>
</File>
</Filter>
@@ -451,15 +475,15 @@
Name="Generating"
>
<File
- RelativePath="..\..\source\Generating\BioGen.cpp"
+ RelativePath="..\..\src\Generating\BioGen.cpp"
>
</File>
<File
- RelativePath="..\..\source\Generating\BioGen.h"
+ RelativePath="..\..\src\Generating\BioGen.h"
>
</File>
<File
- RelativePath="..\..\source\Generating\ComposableGenerator.h"
+ RelativePath="..\..\src\Generating\ComposableGenerator.h"
>
</File>
</Filter>
@@ -467,16 +491,20 @@
Name="iniFile"
>
<File
- RelativePath="..\..\iniFile\iniFile.cpp"
+ RelativePath="..\..\lib\iniFile\iniFile.cpp"
>
</File>
<File
- RelativePath="..\..\iniFile\iniFile.h"
+ RelativePath="..\..\lib\iniFile\iniFile.h"
>
</File>
</Filter>
</Filter>
</Filter>
+ <File
+ RelativePath=".\BiomeColors.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/Tools/BiomeVisualiser/GeneratorBiomeSource.h b/Tools/BiomeVisualiser/GeneratorBiomeSource.h
index 0b47e5f93..751aed245 100644
--- a/Tools/BiomeVisualiser/GeneratorBiomeSource.h
+++ b/Tools/BiomeVisualiser/GeneratorBiomeSource.h
@@ -3,7 +3,7 @@
// Declares the cGeneratorBiomeSource that adapts a cBiomeGen into a cBiomeSource
-#include "../source/Generating/BioGen.h"
+#include "../src/Generating/BioGen.h"
#include "BiomeSource.h"