Skip to content

Commit

Permalink
fix configLoader, material struct and feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Dharini Dutia <[email protected]>
  • Loading branch information
quarkytale committed Dec 20, 2023
1 parent 96dd518 commit 8db08c1
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 390 deletions.
26 changes: 13 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ gz_msgs_generate_messages_impl(
DEPENDENCY_DESCRIPTIONS ${msgs_desc_file}
)

set(cli_sources
gz.cc
cmd/ModelCommandAPI.cc
set(network_sources
network/NetworkConfig.cc
network/NetworkManager.cc
network/NetworkManagerPrimary.cc
network/NetworkManagerSecondary.cc
network/PeerInfo.cc
network/PeerTracker.cc
)

set(comms_sources
Expand All @@ -51,20 +55,16 @@ set(gui_sources
PARENT_SCOPE
)

set(cli_sources
gz.cc
cmd/ModelCommandAPI.cc
)

set(material_sources
rendering/MaterialParser/MaterialParser.cc
rendering/MaterialParser/ConfigLoader.cc
)

set(network_sources
network/NetworkConfig.cc
network/NetworkManager.cc
network/NetworkManagerPrimary.cc
network/NetworkManagerSecondary.cc
network/PeerInfo.cc
network/PeerTracker.cc
)

set (sources
Actor.cc
Barrier.cc
Expand Down Expand Up @@ -94,9 +94,9 @@ set (sources
Util.cc
View.cc
World.cc
${network_sources}
${comms_sources}
${msgs_sources}
${network_sources}
${material_sources}
)

Expand Down
16 changes: 9 additions & 7 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ class gz::sim::SdfEntityCreatorPrivate
/// \brief Keep track of new visuals being added, so we load their plugins
/// only after we have their scoped name.
public: std::map<Entity, sdf::Plugins> newVisuals;

/// \brief Parse Gazebo defined materials for visuals
public: MaterialParser materialParser;
};

using namespace gz;
Expand Down Expand Up @@ -804,15 +807,14 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Visual *_visual)
std::string scriptName = visualMaterial.ScriptName();

if((scriptName.find("Gazebo/") != std::string::npos)) {
gzwarn << "Using internal gazebo.material to parse " << scriptName
gzwarn << "Using an internal gazebo.material to parse " << scriptName
<< std::endl;
MaterialParser* materialParser = new MaterialParser();
materialParser->Load();
std::vector<std::vector<float>> parsed = materialParser->GetMaterialValues(scriptName);
this->dataPtr->materialParser.Load();
MaterialParser::MaterialValues parsed = this->dataPtr->materialParser.GetMaterialValues(scriptName);

visualMaterial.SetAmbient(gz::math::Color(parsed[0][0],parsed[0][1], parsed[0][2]));
visualMaterial.SetDiffuse(gz::math::Color(parsed[1][0],parsed[1][1], parsed[1][2]));
visualMaterial.SetSpecular(gz::math::Color(parsed[2][0],parsed[2][1], parsed[2][2], parsed[2][3]));
visualMaterial.SetAmbient(parsed.ambient.value());
visualMaterial.SetDiffuse(parsed.diffuse.value());
visualMaterial.SetSpecular(parsed.specular.value());
}
}
this->dataPtr->ecm->CreateComponent(visualEntity,
Expand Down
8 changes: 4 additions & 4 deletions src/rendering/MaterialParser/ConfigLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void ConfigLoader::_nextToken(std::ifstream & stream)
}

// Text token
if (ch < 32 || ch > 122) { // Verify valid char
if (ch < 32 || ch > 122) { // Verify valid char
throw std::runtime_error("Parse Error: Invalid character, ConfigLoader::load()");
}

Expand Down Expand Up @@ -182,7 +182,7 @@ void ConfigLoader::_nextToken(std::ifstream & stream)
}

// Add valid char to tokVal
tokVal += (char)ch;
tokVal += static_cast<char>(ch);

// Next char
ch = stream.get();
Expand Down Expand Up @@ -277,7 +277,7 @@ ConfigNode::ConfigNode(ConfigNode * parent, const std::string & name)
{
m_name = name;
m_parent = parent;
_removeSelf = true; // For proper destruction
_removeSelf = true; // For proper destruction
m_lastChildFound = -1;

// Add self to parent's child list (unless this is the root node being created)
Expand Down Expand Up @@ -318,7 +318,7 @@ ConfigNode * ConfigNode::addChild(const std::string & name, bool replaceExisting
ConfigNode * ConfigNode::findChild(const std::string & name, bool recursive)
{
int indx, prevC, nextC;
int childCount = (int)m_children.size();
int childCount = static_cast<int>(m_children.size());

if (m_lastChildFound != -1) {
// If possible, try checking the nodes neighboring the last successful search
Expand Down
Loading

0 comments on commit 8db08c1

Please sign in to comment.