Utility: Handle vertex color loading
This commit is contained in:
@@ -294,8 +294,11 @@ namespace Nz
|
||||
const OBJParser::FaceVertex& vertexIndices = vertexPair.first;
|
||||
unsigned int index = vertexPair.second;
|
||||
|
||||
const Vector4f& vec = positions[vertexIndices.position-1];
|
||||
posPtr[index] = Vector3f(parameters.matrix * vec);
|
||||
if (posPtr)
|
||||
{
|
||||
const Vector4f& vec = positions[vertexIndices.position - 1];
|
||||
posPtr[index] = Vector3f(parameters.matrix * vec);
|
||||
}
|
||||
|
||||
if (hasNormals)
|
||||
{
|
||||
@@ -319,6 +322,13 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
// Official .obj files have no vertex color, fill it with white
|
||||
if (auto colorPtr = vertexMapper.GetComponentPtr<Color>(VertexComponent::Color))
|
||||
{
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
colorPtr[i] = Nz::Color::White;
|
||||
}
|
||||
|
||||
vertexMapper.Unmap();
|
||||
|
||||
std::shared_ptr<StaticMesh> subMesh = std::make_shared<StaticMesh>(std::move(vertexBuffer), indexBuffer);
|
||||
|
||||
Reference in New Issue
Block a user