Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep backward compatibility, add glvertices slot to collada-body #156

Merged
merged 1 commit into from
Nov 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions euscollada/src/collada2eus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ void writeTriangle(FILE *fp, domGeometry *thisGeometry, const char* robot_name)
fprintf(fp, "(defmethod %s_%s\n", robot_name, thisGeometry->getId());
if ( thisMesh == NULL || triangleElementCount == 0 ) {
fprintf(fp, " (:init (&key (name))\n");
fprintf(fp, " (replace-object self (make-cube 10 10 10))\n");
fprintf(fp, " (if name (send self :name name))\n");
fprintf(fp, " (send-super :init :name name)");
fprintf(fp, " self)\n");
fprintf(fp, " )\n");
return;
Expand All @@ -76,9 +75,9 @@ void writeTriangle(FILE *fp, domGeometry *thisGeometry, const char* robot_name)
} else {
fprintf(fp, " (:init (&key (name))\n");
}
fprintf(fp, " (replace-object self (send self :qhull-faceset))\n");
fprintf(fp, " (if name (send self :name name))\n");
fprintf(fp, " (send self :def-gl-vertices)\n");
fprintf(fp, " (send-super :init :name name :replace-obj (send self :qhull-faceset))\n");
fprintf(fp, " (send self :assoc gl::aglvertices)\n");
fprintf(fp, " self)\n");

fprintf(fp, " (:def-gl-vertices ()\n");
Expand Down Expand Up @@ -303,11 +302,7 @@ void writeTriangle(FILE *fp, domGeometry *thisGeometry, const char* robot_name)
}
fprintf(fp, " )))\n");
fprintf(fp, " (send gl::aglvertices :calc-normals)\n");
if (points.size() > 0) {
fprintf(fp, " (send self :assoc gl::aglvertices)\n gl::aglvertices)\n");
} else {
fprintf(fp, " gl::aglvertices)\n");
}
fprintf(fp, " gl::aglvertices)\n");

// do qhull
if ( points.size() > 0 ) {
Expand Down
20 changes: 11 additions & 9 deletions euscollada/src/collada2eus_urdfmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
string gname(name);
if (g->type == Geometry::MESH) gname = ((Mesh *)(g.get()))->filename;
fprintf(fp, " (:_make_instance_%s ()\n", name.c_str());
fprintf(fp, " (let (geom glvertices qhull\n");
fprintf(fp, " (let (geom glv qhull\n");
fprintf(fp, " (local-cds (make-coords :pos ");
fprintf(fp, "(float-vector "FLOAT_PRECISION_FINE" "FLOAT_PRECISION_FINE" "FLOAT_PRECISION_FINE")",
pose.position.x * 1000,
Expand Down Expand Up @@ -1352,21 +1352,21 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
Vector3 scale = ((Mesh *)(g.get()))->scale;
vector<coordT> points;
if (scene && scene->HasMeshes() && !use_loadable_mesh) {
fprintf(fp, " (setq glvertices\n");
fprintf(fp, " (setq glv\n");
fprintf(fp, " (instance gl::glvertices :init\n");
fprintf(fp, " (list ;; mesh list\n");
// TODO: use g->scale
printMesh(scene, scene->mRootNode, scale, material_name, points, true);
fprintf(fp, " )\n");
fprintf(fp, " ))\n");
fprintf(fp, " (send glvertices :transform local-cds)\n");
fprintf(fp, " (send glvertices :calc-normals)\n");
fprintf(fp, " (send glv :transform local-cds)\n");
fprintf(fp, " (send glv :calc-normals)\n");
} else if (scene && scene->HasMeshes()) {
fprintf(fp, " (setq glvertices (load-mesh-file (ros::resolve-ros-path \"%s\")\n", gname.c_str());
fprintf(fp, " (setq glv (load-mesh-file (ros::resolve-ros-path \"%s\")\n", gname.c_str());
fprintf(fp, " :scale %f :process-max-quality t))\n", scale.x*1000);
printMesh(scene, scene->mRootNode, scale, material_name, points, false);
fprintf(fp, " (send glvertices :transform local-cds)\n");
fprintf(fp, " (send glvertices :calc-normals)\n");
fprintf(fp, " (send glv :transform local-cds)\n");
fprintf(fp, " (send glv :calc-normals)\n");
} else {
// error
}
Expand Down Expand Up @@ -1416,10 +1416,12 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
}
}
}
if (g->type == Geometry::MESH) {
fprintf(fp, " (setq (geom . gl::aglvertices) glv)\n");
}
fprintf(fp, " (setq geom (instance collada-body :init :replace-obj qhull :name \"%s\"))\n", gname.c_str());
if (g->type == Geometry::MESH) {
fprintf(fp, " (send geom :assoc glvertices)\n");
fprintf(fp, " (setq (geom . gl::aglvertices) glvertices)\n");
fprintf(fp, " (send geom :assoc glv)\n");
}
fprintf(fp, " geom))\n");
}
Expand Down
3 changes: 2 additions & 1 deletion euscollada/src/euscollada-robot.l
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@
;; This euscollada-body class is for bodies in robot model converted from collada files.
(defclass collada-body
:super gl::glbody
:slots ()
:slots (glvertices) ;; glvertices slot for backward compatibility
)
(defmethod collada-body
(:init (&key (name) (replace-obj))
(if replace-obj
(replace-object self replace-obj)
(replace-object self (make-cube 10 10 10)))
(if name (send self :name name))
(setq glvertices gl::aglvertices)
self)
(:change-visual
(&optional (visual :convex))
Expand Down