MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / GenerateBox

Function GenerateBox

src/Nazara/Utility/AlgorithmUtility.cpp:734–853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732 /**********************************Generate*********************************/
733
734 void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, unsigned int indexOffset)
735 {
736 unsigned int xIndexCount, yIndexCount, zIndexCount;
737 unsigned int xVertexCount, yVertexCount, zVertexCount;
738
739 ComputePlaneIndexVertexCount(Vector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount);
740 ComputePlaneIndexVertexCount(Vector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount);
741 ComputePlaneIndexVertexCount(Vector2ui(subdivision.x, subdivision.y), &zIndexCount, &zVertexCount);
742
743 Matrix4f transform;
744 Vector3f halfLengths = lengths/2.f;
745
746 // Face +X
747 transform.MakeTransform(Vector3f::UnitX() * halfLengths.x, EulerAnglesf(-90.f, -90.f, 180.f));
748 GeneratePlane(Vector2ui(subdivision.z, subdivision.y), Vector2f(lengths.z, lengths.y), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
749 indexOffset += xVertexCount;
750 indices += xIndexCount;
751
752 vertexPointers.positionPtr += xVertexCount;
753
754 if (vertexPointers.normalPtr)
755 vertexPointers.normalPtr += xVertexCount;
756
757 if (vertexPointers.tangentPtr)
758 vertexPointers.tangentPtr += xVertexCount;
759
760 if (vertexPointers.uvPtr)
761 vertexPointers.uvPtr += xVertexCount;
762
763 // Face +Y
764 transform.MakeTransform(Vector3f::UnitY() * halfLengths.y, EulerAnglesf(0.f, 0.f, 0.f));
765 GeneratePlane(Vector2ui(subdivision.x, subdivision.z), Vector2f(lengths.x, lengths.z), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
766 indexOffset += yVertexCount;
767 indices += yIndexCount;
768
769 vertexPointers.positionPtr += yVertexCount;
770
771 if (vertexPointers.normalPtr)
772 vertexPointers.normalPtr += yVertexCount;
773
774 if (vertexPointers.tangentPtr)
775 vertexPointers.tangentPtr += yVertexCount;
776
777 if (vertexPointers.uvPtr)
778 vertexPointers.uvPtr += yVertexCount;
779
780 // Face +Z
781 transform.MakeTransform(Vector3f::UnitZ() * halfLengths.z, EulerAnglesf(90.f, 0.f, 0.f));
782 GeneratePlane(Vector2ui(subdivision.x, subdivision.y), Vector2f(lengths.x, lengths.y), Matrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertexPointers, indices, nullptr, indexOffset);
783 indexOffset += zVertexCount;
784 indices += zIndexCount;
785
786 vertexPointers.positionPtr += zVertexCount;
787
788 if (vertexPointers.normalPtr)
789 vertexPointers.normalPtr += zVertexCount;
790
791 if (vertexPointers.tangentPtr)

Callers 2

BuildSubMeshMethod · 0.85
GenerateCubicSphereFunction · 0.85

Calls 4

GeneratePlaneFunction · 0.85
TransformMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected