26 #include <VirtualRobot/Visualization/TriMeshModel.h>
27 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
34 static DebugDrawerTriMesh
convertTriMesh(
const VirtualRobot::TriMeshModel& trimesh)
36 DebugDrawerTriMesh ddMesh;
38 auto addVertex = [&](
const Eigen::Vector3f &
v)
40 ddMesh.vertices.push_back({
v(0),
v(1),
v(2)});
41 return (
int)ddMesh.vertices.size() - 1;
46 ddMesh.colors.push_back(DrawColor {
c.r,
c.g,
c.b,
c.transparency});
47 return (
int)ddMesh.colors.size() - 1;
49 ddMesh.faces.reserve(trimesh.faces.size());
50 ddMesh.vertices.reserve(trimesh.vertices.size());
51 ddMesh.colors.reserve(trimesh.colors.size());
53 for (
auto& f : trimesh.faces)
56 f2.vertex1.vertexID = addVertex(trimesh.vertices.at(f.id1));
57 f2.vertex2.vertexID = addVertex(trimesh.vertices.at(f.id2));
58 f2.vertex3.vertexID = addVertex(trimesh.vertices.at(f.id3));
59 if (f.idNormal1 != UINT_MAX)
61 f2.vertex1.normalID = addVertex(trimesh.normals.at(f.idNormal1));
62 f2.vertex2.normalID = addVertex(trimesh.normals.at(f.idNormal2));
63 f2.vertex3.normalID = addVertex(trimesh.normals.at(f.idNormal3));
68 f2.normal = {f.normal.x(), f.normal.y(), f.normal.z()};
70 f2.vertex1.colorID = addColor(trimesh.colors.at(f.idColor1));
71 f2.vertex2.colorID = addColor(trimesh.colors.at(f.idColor2));
72 f2.vertex3.colorID = addColor(trimesh.colors.at(f.idColor3));
74 ddMesh.faces.push_back(f2);