Utility/Algorithm: Fix GenerateBox plane rotation (Fix #114)

This commit is contained in:
Lynix 2016-11-14 00:02:01 +01:00
parent 06235aec98
commit 43f93141ac
2 changed files with 8 additions and 7 deletions

View File

@ -17,11 +17,11 @@ namespace Nz
{
/*!
* \ingroup math
* \ingroup math
* \class Nz::EulerAngles
* \brief Math class that represents an Euler angle. Those describe a rotation transformation by rotating an object on its various axes in specified amounts per axis, and a specified axis order
*
* \remark Rotation are "left-handed", it means that you take your left hand, put your thumb finger in the direction you want and you other fingers represent the way of rotating
* \remark Rotation are "right-handed", it means that you take your right hand, put your thumb finger in the direction you want and you other fingers represent the way of rotating
*/
/*!
@ -197,6 +197,7 @@ namespace Nz
template<typename T>
Quaternion<T> EulerAngles<T>::ToQuaternion() const
{
// XYZ
T c1 = std::cos(ToRadians(yaw) / F(2.0));
T c2 = std::cos(ToRadians(roll) / F(2.0));
T c3 = std::cos(ToRadians(pitch) / F(2.0));

View File

@ -742,7 +742,7 @@ namespace Nz
Vector3f halfLengths = lengths/2.f;
// Face +X
transform.MakeTransform(Vector3f::UnitX() * halfLengths.x, EulerAnglesf(-90.f, 0.f, -90.f));
transform.MakeTransform(Vector3f::UnitX() * halfLengths.x, EulerAnglesf(-90.f, -90.f, 180.f));
GeneratePlane(Vector2ui(subdivision.z, subdivision.y), Vector2f(lengths.z, lengths.y), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
indexOffset += xVertexCount;
indices += xIndexCount;
@ -776,7 +776,7 @@ namespace Nz
vertexPointers.uvPtr += yVertexCount;
// Face +Z
transform.MakeTransform(Vector3f::UnitZ() * halfLengths.z, EulerAnglesf(-90.f, 90.f, 90.f));
transform.MakeTransform(Vector3f::UnitZ() * halfLengths.z, EulerAnglesf(90.f, 0.f, 0.f));
GeneratePlane(Vector2ui(subdivision.x, subdivision.y), Vector2f(lengths.x, lengths.y), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
indexOffset += zVertexCount;
indices += zIndexCount;
@ -793,7 +793,7 @@ namespace Nz
vertexPointers.uvPtr += zVertexCount;
// Face -X
transform.MakeTransform(-Vector3f::UnitX() * halfLengths.x, EulerAnglesf(-90.f, 0.f, 90.f));
transform.MakeTransform(-Vector3f::UnitX() * halfLengths.x, EulerAnglesf(-90.f, 90.f, 180.f));
GeneratePlane(Vector2ui(subdivision.z, subdivision.y), Vector2f(lengths.z, lengths.y), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
indexOffset += xVertexCount;
indices += xIndexCount;
@ -810,7 +810,7 @@ namespace Nz
vertexPointers.uvPtr += xVertexCount;
// Face -Y
transform.MakeTransform(-Vector3f::UnitY() * halfLengths.y, EulerAnglesf(0.f, 0.f, 180.f));
transform.MakeTransform(-Vector3f::UnitY() * halfLengths.y, EulerAnglesf(0.f, 180.f, 180.f));
GeneratePlane(Vector2ui(subdivision.x, subdivision.z), Vector2f(lengths.x, lengths.z), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
indexOffset += yVertexCount;
indices += yIndexCount;
@ -827,7 +827,7 @@ namespace Nz
vertexPointers.uvPtr += yVertexCount;
// Face -Z
transform.MakeTransform(-Vector3f::UnitZ() * halfLengths.z, EulerAnglesf(-90.f, -90.f, 90.f));
transform.MakeTransform(-Vector3f::UnitZ() * halfLengths.z, EulerAnglesf(90.f, 180.f, 0.f));
GeneratePlane(Vector2ui(subdivision.x, subdivision.y), Vector2f(lengths.x, lengths.y), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
indexOffset += zVertexCount;
indices += zIndexCount;