INNER CODE UNIT · C++
colorIndex
mosra/magnum-integration · src/Magnum/DartIntegration/ConvertShapeNode.cpp:275
Int colorIndex = (UnsignedInt(meshShape->getColorIndex()) >= meshData->vertexCount()) ? meshData->vertexCount() - 1 : meshShape->getColorIndex();
/* Assuming AssimpImporter, which always returns
colors as Color4 */
CORRADE_INTERNAL_ASSERT(meshData->attributeFormat(Trade::MeshAttribute::Color) == VertexFormat::Vector4);
Color4 meshColor = meshData->attribute<Color4>(Trade::MeshAttribute::Color)[colorIndex];
/* default colors for ambient (black) and specular
(white) */
materials[i] = Trade::PhongMaterialData{
Trade::MaterialType::Phong,
{{Trade::MaterialAttribute::DiffuseColor, meshColor},
{Trade::MaterialAttribute::Shininess, 2000.0f}}};
/* Fallback to SHAPE_COLOR if MeshData has no colors */
} else {
Warning{} << "DartIntegration::convertShapeNode(): Assimp mesh has no colors. Falling back to SHAPE_COLOR mode";
materials[i] = std::move(nodeMaterial);
}