diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-08-11 03:10:33 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-08-11 03:10:33 +0200 |
commit | 809c4766ba13e85546a747fe5e0dbd82e1e6d549 (patch) | |
tree | 28c807512b8f76fe3f4555858a9492ff5b6cad39 /src/AssetManager.cpp | |
parent | Support rotation in BlockStates (diff) | |
download | AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.tar AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.tar.gz AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.tar.bz2 AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.tar.lz AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.tar.xz AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.tar.zst AltCraft-809c4766ba13e85546a747fe5e0dbd82e1e6d549.zip |
Diffstat (limited to 'src/AssetManager.cpp')
-rw-r--r-- | src/AssetManager.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 482a028..2329e8d 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -505,6 +505,7 @@ BlockFaces &AssetManager::GetBlockModelByBlockId(BlockId block) { BlockFaces blockFaces; blockFaces.faces = GetAsset<AssetBlockModel>("/minecraft/models/block/error")->blockModel.parsedFaces; blockFaces.isBlock = GetAsset<AssetBlockModel>("/minecraft/models/block/error")->blockModel.IsBlock; + blockFaces.direction = FaceDirection::none; blockIdToBlockFaces.insert(std::make_pair(block, blockFaces)); return blockIdToBlockFaces.find(block)->second; } @@ -530,16 +531,82 @@ BlockFaces &AssetManager::GetBlockModelByBlockId(BlockId block) { BlockFaces blockFaces; blockFaces.faces = assetModel->blockModel.parsedFaces; blockFaces.isBlock = assetModel->blockModel.IsBlock; + blockFaces.direction = FaceDirection::west; if (model.x != 0) { blockFaces.transform = glm::translate(blockFaces.transform, glm::vec3(0.0f, 0.5f, 0.5f)); blockFaces.transform = glm::rotate(blockFaces.transform, glm::radians((float)model.x), glm::vec3(1.0f, 0.0f, 0.0f)); blockFaces.transform = glm::translate(blockFaces.transform, glm::vec3(0.0f, -0.5f, -0.5f)); + switch (model.x) { + case 90: + blockFaces.direction = FaceDirection::down; + break; + case 180: + blockFaces.direction = FaceDirection::east; + break; + case 270: + blockFaces.direction = FaceDirection::up; + break; + default: + break; + } } if (model.y != 0) { blockFaces.transform = glm::translate(blockFaces.transform, glm::vec3(0.5f, 0.0f, 0.5f)); blockFaces.transform = glm::rotate(blockFaces.transform, glm::radians((float)model.y), glm::vec3(0.0f, 1.0f, 0.0f)); blockFaces.transform = glm::translate(blockFaces.transform, glm::vec3(-0.5f, 0.0f, -0.5f)); + switch (model.y) { + case 90: + switch (blockFaces.direction) { + case FaceDirection::west: + blockFaces.direction = FaceDirection::north; + break; + case FaceDirection::up: + blockFaces.direction = FaceDirection::up; + break; + case FaceDirection::east: + blockFaces.direction = FaceDirection::south; + break; + case FaceDirection::down: + blockFaces.direction = FaceDirection::down; + break; + } + break; + case 180: + switch (blockFaces.direction) { + case FaceDirection::west: + blockFaces.direction = FaceDirection::east; + break; + case FaceDirection::up: + blockFaces.direction = FaceDirection::up; + break; + case FaceDirection::east: + blockFaces.direction = FaceDirection::west; + break; + case FaceDirection::down: + blockFaces.direction = FaceDirection::down; + break; + } + break; + case 270: + switch (blockFaces.direction) { + case FaceDirection::west: + blockFaces.direction = FaceDirection::south; + break; + case FaceDirection::up: + blockFaces.direction = FaceDirection::up; + break; + case FaceDirection::east: + blockFaces.direction = FaceDirection::north; + break; + case FaceDirection::down: + blockFaces.direction = FaceDirection::down; + break; + } + break; + default: + break; + } } blockIdToBlockFaces.insert(std::make_pair(block, blockFaces)); |