diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-10-09 18:39:48 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 03:39:32 +0100 |
commit | a81bcb1942ddad5989115061338e72211443e633 (patch) | |
tree | cb1cc6feadb7dfb49f96cbc9b2a4f2bfb9ad8488 /src/RendererSection.cpp | |
parent | 2017-10-07 (diff) | |
download | AltCraft-a81bcb1942ddad5989115061338e72211443e633.tar AltCraft-a81bcb1942ddad5989115061338e72211443e633.tar.gz AltCraft-a81bcb1942ddad5989115061338e72211443e633.tar.bz2 AltCraft-a81bcb1942ddad5989115061338e72211443e633.tar.lz AltCraft-a81bcb1942ddad5989115061338e72211443e633.tar.xz AltCraft-a81bcb1942ddad5989115061338e72211443e633.tar.zst AltCraft-a81bcb1942ddad5989115061338e72211443e633.zip |
Diffstat (limited to 'src/RendererSection.cpp')
-rw-r--r-- | src/RendererSection.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp index c813071..55761f7 100644 --- a/src/RendererSection.cpp +++ b/src/RendererSection.cpp @@ -227,7 +227,30 @@ void RendererSectionData::AddFacesByBlockModel(const std::vector<Vector> §io Vector t = element.to - element.from; VectorF elementSize(VectorF(t.x,t.y,t.z) / 16.0f); VectorF elementOrigin(VectorF(element.from.x,element.from.y,element.from.z) / 16.0f); - elementTransform = glm::translate(transform, elementOrigin.glm()); + elementTransform = transform; + + /*if (element.rotationAngle != 0) { + const glm::vec3 xAxis(1.0f, 0.0f, 0.0f); + const glm::vec3 yAxis(0.0f, 1.0f, 0.0f); + const glm::vec3 zAxis(0.0f, 0.0f, 1.0f); + const glm::vec3 *targetAxis = nullptr; + switch (element.rotationAxis) { + case BlockModel::ElementData::Axis::x: + targetAxis = &xAxis; + break; + case BlockModel::ElementData::Axis::y: + targetAxis = &yAxis; + break; + case BlockModel::ElementData::Axis::z: + targetAxis = &zAxis; + break; + } + VectorF rotateOrigin(VectorF(element.rotationOrigin.x, element.rotationOrigin.y, element.rotationOrigin.z) / 16.0f); + elementTransform = glm::translate(elementTransform, -rotateOrigin.glm()); + elementTransform = glm::rotate(elementTransform, glm::radians(float(45)), yAxis); + elementTransform = glm::translate(elementTransform, rotateOrigin.glm()); + }*/ + elementTransform = glm::translate(elementTransform, elementOrigin.glm()); elementTransform = glm::scale(elementTransform, elementSize.glm()); for (const auto& face : element.faces) { @@ -301,6 +324,24 @@ void RendererSectionData::AddFacesByBlockModel(const std::vector<Vector> §io textureName = model.Textures.find(std::string(textureName.begin()+1,textureName.end()))->second; } glm::vec4 texture = AssetManager::Instance().GetTextureByAssetName("minecraft/textures/" + textureName); + + if (!(face.second.uv == BlockModel::ElementData::FaceData::Uv{ 0,16,0,16 }) && !(face.second.uv == BlockModel::ElementData::FaceData::Uv{ 0,0,0,0 }) + && !(face.second.uv == BlockModel::ElementData::FaceData::Uv{ 0,0,16,16 })) { + double x = face.second.uv.x1; + double y = face.second.uv.x1; + double w = face.second.uv.x2 - face.second.uv.x1; + double h = face.second.uv.y2 - face.second.uv.y1; + x /= 16.0; + y /= 16.0; + w /= 16.0; + h /= 16.0; + double X = texture.x; + double Y = texture.y; + double W = texture.z; + double H = texture.w; + + texture = glm::vec4{ X + x * W, Y + y * H, w * W , h * H }; + } textures.push_back(texture); if (face.second.tintIndex) colors.push_back(glm::vec3(0.275, 0.63, 0.1)); |