From 145ba8e157f79db64203db9684af2e6ed33af075 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sun, 3 Sep 2017 20:45:52 +0500 Subject: 2017-09-03 --- src/AssetManager.hpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) (limited to 'src/AssetManager.hpp') 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 #include +#include #include #include @@ -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 Display; + + std::map 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 faces; + }; + + std::vector Elements; +}; + class AssetManager { Texture *textureAtlas; - std::map assetIds; + std::map assetIds; std::map assetTextures; std::map textureAtlasIndexes; + std::map models; public: AssetManager(); @@ -74,4 +143,8 @@ public: TextureCoordinates GetTextureByBlock(BlockTextureId block); static AssetManager& Instance(); + + const BlockModel *GetBlockModelByBlockId(BlockId block); + + void LoadBlockModels(); }; -- cgit v1.2.3