diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-09-03 17:45:52 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 03:39:31 +0100 |
commit | 145ba8e157f79db64203db9684af2e6ed33af075 (patch) | |
tree | ec524120eaf2dda746d662297483be51fe626367 /src/AssetManager.hpp | |
parent | 2017-08-29 (diff) | |
download | AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.tar AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.tar.gz AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.tar.bz2 AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.tar.lz AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.tar.xz AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.tar.zst AltCraft-145ba8e157f79db64203db9684af2e6ed33af075.zip |
Diffstat (limited to 'src/AssetManager.hpp')
-rw-r--r-- | src/AssetManager.hpp | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/src/AssetManager.hpp b/src/AssetManager.hpp index ca8bd35..96f9741 100644 --- a/src/AssetManager.hpp +++ b/src/AssetManager.hpp @@ -1,7 +1,7 @@ #pragma once -#include <experimental/filesystem> #include <map> +#include <optional> #include <GL/glew.h> #include <glm/vec4.hpp> @@ -9,6 +9,7 @@ #include "Block.hpp" #include "Texture.hpp" +#include "Vector.hpp" struct TextureCoordinates { TextureCoordinates(float x = -1, float y = -1, float w = -1, float h = -1) : x(x), y(y), w(w), h(h) {} @@ -25,6 +26,10 @@ struct TextureCoordinates { } double x, y, w, h; + + operator glm::vec4() const { + return glm::vec4(x, y, w, h); + } }; struct BlockTextureId { @@ -49,11 +54,75 @@ struct BlockTextureId { } }; +struct BlockModel { + bool AmbientOcclusion=true; + + enum DisplayVariants { + thirdperson_righthand, + thirdperson_lefthand, + firstperson_righthand, + firstperson_lefthand, + gui, + head, + ground, + fixed, + DisplayVariantsCount, + }; + struct DisplayData { + Vector rotation; + Vector translation; + Vector scale; + }; + std::map<DisplayVariants, DisplayData> Display; + + std::map<std::string, std::string> Textures; + + struct ElementData { + Vector from; + Vector to; + + Vector rotationOrigin = Vector(8, 8, 8); + enum Axis { + x, + y, + z, + } rotationAxis = Axis::x; + int rotationAngle = 0; + bool rotationRescale = false; + + bool shade = true; + + enum FaceDirection { + down, + up, + north, + south, + west, + east, + none, + }; + struct FaceData { + struct Uv { + int x1, y1, x2, y2; + } uv = { 0,0,0,0 }; + std::string texture; + FaceDirection cullface = FaceDirection::none; + int rotation = 0; + bool tintIndex = false; + + }; + std::map<FaceDirection, FaceData> faces; + }; + + std::vector<ElementData> Elements; +}; + class AssetManager { Texture *textureAtlas; - std::map<std::string, Block> assetIds; + std::map<std::string, BlockId> assetIds; std::map<std::string, TextureCoordinates> assetTextures; std::map<BlockTextureId,glm::vec4> textureAtlasIndexes; + std::map<std::string, BlockModel> models; public: AssetManager(); @@ -74,4 +143,8 @@ public: TextureCoordinates GetTextureByBlock(BlockTextureId block); static AssetManager& Instance(); + + const BlockModel *GetBlockModelByBlockId(BlockId block); + + void LoadBlockModels(); }; |