Skip to content

Commit

Permalink
Support vertex colors for meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
tribal-tec committed Jul 25, 2018
1 parent ba0fd09 commit 73291a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![C++ Build Status](https://bbpcode.epfl.ch/ci/buildStatus/icon?job=oss.Brayns)](https://bbpcode.epfl.ch/ci/job/oss.Brayns/)
[![Docker Build Status](https://bbpcode.epfl.ch/ci/buildStatus/icon?job=oss.Brayns.docker)](https://bbpcode.epfl.ch/ci/job/oss.Brayns.docker/)
[![Python Build Status](https://travis-ci.org/BlueBrain/Brayns.svg?branch=pypi)](https://travis-ci.org/BlueBrain/Brayns)
[![Python Build Status](https://travis-ci.org/BlueBrain/Brayns.svg)](https://travis-ci.org/BlueBrain/Brayns)
[![Read the Docs](https://readthedocs.org/projects/brayns/badge/?version=latest)](http://brayns.readthedocs.io/en/latest/?badge=latest)
[![Docker Pulls](https://img.shields.io/docker/pulls/bluebrain/brayns.svg)](https://hub.docker.com/r/bluebrain/brayns/)
[![GitHub release](https://img.shields.io/github/release/BlueBrain/Brayns.svg)](https://github.com/BlueBrain/Brayns/releases)
Expand Down
2 changes: 2 additions & 0 deletions brayns/common/scene/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ ModelDescriptorPtr Scene::load(Blob&& blob,
auto loader = _loaderRegistry.createLoader(blob.type);
loader->setProgressCallback(cb);
auto model = loader->importFromBlob(std::move(blob), 0, materialID);
if (!model)
throw std::runtime_error("No model returned by loader");
model->setTransformation(transformation);
addModel(model);
saveToCacheFile();
Expand Down
11 changes: 9 additions & 2 deletions brayns/io/MeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ void MeshLoader::_postLoad(const aiScene* aiScene, Model& model,
triangleMeshes.normals.reserve(nbVertices);
if (mesh->HasTextureCoords(0))
triangleMeshes.textureCoordinates.reserve(nbVertices);
if (mesh->HasVertexColors(0))
triangleMeshes.colors.reserve(nbVertices);
for (size_t i = 0; i < mesh->mNumVertices; ++i)
{
const auto& v = mesh->mVertices[i];
Expand All @@ -268,8 +270,13 @@ void MeshLoader::_postLoad(const aiScene* aiScene, Model& model,
if (mesh->HasTextureCoords(0))
{
const auto& t = mesh->mTextureCoords[0][i];
const Vector2f texCoord(t.x, -t.y);
triangleMeshes.textureCoordinates.push_back(texCoord);
triangleMeshes.textureCoordinates.push_back({t.x, -t.y});
}

if (mesh->HasVertexColors(0))
{
const auto& c = mesh->mColors[0][i];
triangleMeshes.colors.push_back({c.r, c.g, c.b, c.a});
}
}
bool nonTriangulatedFaces = false;
Expand Down

0 comments on commit 73291a6

Please sign in to comment.