Skip to content
Snippets Groups Projects
Commit c2a68a14 authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Enable viz::coin::Object to handle dae, off, ply, stl, iv etc.

parent 1f447b6c
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
#include <VirtualRobot/XML/RobotIO.h>
#include <VirtualRobot/XML/ObjectIO.h>
#include <VirtualRobot/Visualization/CoinVisualization/CoinVisualization.h>
#include <VirtualRobot/Import/MeshImport/AssimpReader.h>
#include <SimoxUtility/algorithm/string/string_tools.h>
......@@ -79,18 +80,30 @@ namespace armarx::viz::coin
{
ARMARX_INFO << "Loading object from " << fullFilename;
if (simox::alg::ends_with(fullFilename, ".wrl"))
std::filesystem::path path{fullFilename};
const std::string ext = simox::alg::to_lower(path.extension());
if (ext == ".wrl" || ext == ".iv")
{
VirtualRobot::VisualizationFactoryPtr factory = VirtualRobot::VisualizationFactory::fromName("inventor", NULL);
VirtualRobot::VisualizationNodePtr vis = factory->getVisualizationFromFile(fullFilename);
result = VirtualRobot::ManipulationObjectPtr(new VirtualRobot::ManipulationObject(filename, vis));
}
else
else if (ext == ".xml")
{
result = VirtualRobot::ObjectIO::loadManipulationObject(fullFilename);
}
else if (VirtualRobot::AssimpReader::can_load(fullFilename))
{
const auto& tri = VirtualRobot::AssimpReader{}.readFileAsTriMesh(fullFilename);
result = VirtualRobot::ManipulationObjectPtr(new VirtualRobot::ManipulationObject(filename, tri));
}
else
{
ARMARX_WARNING << "Could not load object from file: " << fullFilename
<< "\nunknown extension '" << ext << "'";
}
}
catch (std::exception const& ex)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment