summaryrefslogtreecommitdiffstats
path: root/src/core/AssetManager.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-28 16:16:05 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-28 16:16:05 +0200
commitd93c2073896e63aca5a859fe7182ba24dbe84cd3 (patch)
tree6144aaf7e01854fe245011ca4f4735974366febb /src/core/AssetManager.cpp
parent2017-05-26 (diff)
downloadAltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.gz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.bz2
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.lz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.xz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.zst
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.zip
Diffstat (limited to 'src/core/AssetManager.cpp')
-rw-r--r--src/core/AssetManager.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/core/AssetManager.cpp b/src/core/AssetManager.cpp
index 9913c18..003f2f0 100644
--- a/src/core/AssetManager.cpp
+++ b/src/core/AssetManager.cpp
@@ -1,5 +1,4 @@
-#include <easylogging++.h>
-#include <nlohmann/json.hpp>
+
#include "AssetManager.hpp"
namespace fs = std::experimental::filesystem;
@@ -24,7 +23,7 @@ void AssetManager::LoadIds() {
int id = it["type"].get<int>();
int state = it["meta"].get<int>();
std::string blockName = it["text_type"].get<std::string>();
- assetIds[blockName] = Block(id, state, 0);
+ assetIds[blockName] = Block(id, 0, state);
}
LOG(INFO) << "Loaded " << assetIds.size() << " ids";
}
@@ -43,14 +42,13 @@ void AssetManager::LoadTextureResources() {
auto frame = it["frame"];
TextureCoord coord;
coord.x = frame["x"].get<int>();
- coord.y = frame["y"].get<int>();
+ coord.y = frame["y"].get<int>();;
coord.w = frame["w"].get<int>();
coord.h = frame["h"].get<int>();
std::string assetName = it["filename"].get<std::string>();
- assetName.insert(0,"minecraft/textures/");
- assetName.erase(assetName.length()-4);
- LOG(ERROR)<<assetName;
- assetTextures[assetName]=coord;
+ assetName.insert(0, "minecraft/textures/");
+ assetName.erase(assetName.length() - 4);
+ assetTextures[assetName] = coord;
}
textureAtlas = new Texture(filename);
@@ -58,11 +56,27 @@ void AssetManager::LoadTextureResources() {
}
TextureCoord AssetManager::GetTextureByAssetName(std::string AssetName) {
- return TextureCoord{0, 0, 0, 0};
+ return assetTextures[AssetName];
}
std::string AssetManager::GetTextureAssetNameByBlockId(unsigned short BlockId, unsigned char BlockSide) {
+ //Block sides: 0 - bottom, 1 - top, 2 - north, 3 - south, 4 - west, 5 - east
+ std::map<Block, std::string> lookupTable = {
+ {Block(0), "minecraft/textures/blocks/air"},
+ {Block(1, 0), "minecraft/textures/blocks/stone"},
+ {Block(1, 1), "minecraft/textures/blocks/stone_granite"},
+
+ {Block(2, 0, 0), "minecraft/textures/blocks/dirt"},
+ {Block(2, 0, 1), "minecraft/textures/blocks/grass_top"},
+ {Block(2, 0, 2), "minecraft/textures/blocks/grass_side"},
+ {Block(2, 0, 3), "minecraft/textures/blocks/grass_side"},
+ {Block(2, 0, 4), "minecraft/textures/blocks/grass_side"},
+ {Block(2, 0, 5), "minecraft/textures/blocks/grass_side"},
+ {Block(3), "minecraft/textures/blocks/dirt"},
+ {Block(4), "minecraft/textures/blocks/cobblestone"},
+ };
+ return lookupTable[Block(BlockId, BlockSide)];
}
const GLuint AssetManager::GetTextureAtlas() {