Skip to content

Commit

Permalink
Revert "Associate library materials effect with meshes (#151)"
Browse files Browse the repository at this point in the history
This reverts commit 89b1157.

Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina committed Mar 9, 2021
1 parent 38c0d0c commit 50816a3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 159 deletions.
40 changes: 0 additions & 40 deletions graphics/src/ColladaLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ namespace ignition
/// \brief material dictionary indexed by name
public: std::map<std::string, std::string> materialMap;

/// \brief material dictionary indexed by mesh name
public: std::map<std::string, std::string> materialEffectMap;

/// \brief root xml element of COLLADA data
public: tinyxml2::XMLElement *colladaXml;

Expand Down Expand Up @@ -531,7 +528,6 @@ void ColladaLoaderPrivate::LoadNode(tinyxml2::XMLElement *_elem, Mesh *_mesh,
tinyxml2::XMLElement *geomXml = this->ElementId("geometry", geomURL);

this->materialMap.clear();
this->materialEffectMap.clear();
tinyxml2::XMLElement *bindMatXml, *techniqueXml, *matXml;
bindMatXml = instGeomXml->FirstChildElement("bind_material");
while (bindMatXml)
Expand All @@ -544,7 +540,6 @@ void ColladaLoaderPrivate::LoadNode(tinyxml2::XMLElement *_elem, Mesh *_mesh,
std::string symbol = matXml->Attribute("symbol");
std::string target = matXml->Attribute("target");
this->materialMap[symbol] = target;
this->materialEffectMap[geomURL] = target;
matXml = matXml->NextSiblingElement("instance_material");
}
}
Expand All @@ -554,41 +549,6 @@ void ColladaLoaderPrivate::LoadNode(tinyxml2::XMLElement *_elem, Mesh *_mesh,
if (_mesh->HasSkeleton())
_mesh->MeshSkeleton()->SetNumVertAttached(0);
this->LoadGeometry(geomXml, transform, _mesh);

// Associate materials defined in library_materials with the right mesh
if (materialEffectMap.size() > 0)
{
std::string matStr;
int matIndex = -1;
std::map<std::string, std::string>::iterator iter;

iter = this->materialEffectMap.find(geomURL);
if (iter != this->materialEffectMap.end())
matStr = iter->second;
MaterialPtr mat = this->LoadMaterial(matStr);
matIndex = _mesh->IndexOfMaterial(mat.get());
if (matIndex < 0)
{
matIndex = _mesh->AddMaterial(mat);
}
if (matIndex < 0)
{
ignwarn << "Unable to add material[" << matStr << "]\n";
}
else
{
auto subMesh = _mesh->SubMeshByName(this->currentNodeName);
if (subMesh.lock() == nullptr)
{
ignwarn << "Unable to get submesh[" << geomURL << "]\n";
}
else
{
subMesh.lock().get()->SetMaterialIndex(matIndex);
}
}
}

instGeomXml = instGeomXml->NextSiblingElement("instance_geometry");
}

Expand Down
27 changes: 0 additions & 27 deletions graphics/src/ColladaLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,6 @@ TEST_F(ColladaLoader, LoadBox)
EXPECT_STREQ("Cube", mesh->SubMeshByIndex(0).lock()->Name().c_str());
}

/////////////////////////////////////////////////
TEST_F(ColladaLoader, LoadRectangle)
{
common::ColladaLoader loader;
common::Mesh *mesh = loader.Load(common::joinPaths(
std::string(PROJECT_SOURCE_PATH), "test", "data", "rectangle.dae"));

EXPECT_STREQ("unknown", mesh->Name().c_str());
EXPECT_EQ(ignition::math::Vector3d(0.35, 0.4, 1), mesh->Max());
EXPECT_EQ(ignition::math::Vector3d(-0.35, -0.4, -1), mesh->Min());
EXPECT_EQ(35u, mesh->VertexCount());
EXPECT_EQ(35u, mesh->NormalCount());
EXPECT_EQ(36u, mesh->IndexCount());
EXPECT_EQ(0u, mesh->TexCoordCount());
EXPECT_EQ(1u, mesh->SubMeshCount());
EXPECT_EQ(1u, mesh->MaterialCount());

common::MaterialPtr material = mesh->MaterialByIndex(0);
EXPECT_NE(nullptr, material);
EXPECT_EQ(math::Color(0.008957128f, 0.00619848f, 0.64f, 1.0f),
material->Diffuse());
EXPECT_EQ(math::Color(0.5, 0.5, 0.5, 1), material->Specular());
EXPECT_EQ(math::Color(0, 0, 0, 1), material->Ambient());
EXPECT_EQ(math::Color(0, 0, 0, 1), material->Emissive());
EXPECT_DOUBLE_EQ(50.0, material->Shininess());
}

/////////////////////////////////////////////////
TEST_F(ColladaLoader, ShareVertices)
{
Expand Down
92 changes: 0 additions & 92 deletions test/data/rectangle.dae

This file was deleted.

0 comments on commit 50816a3

Please sign in to comment.