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

add #-:gl for euslisp without :gl features, may be we should put glbody/glvertices in irtgeo? #246

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions euscollada/src/collada2eus_urdfmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,7 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
<< std::endl;
#endif
double radius = ((Sphere *)g.get())->radius;
fprintf(fp, "#+:gl\n");
fprintf(fp, " (let ((bdy (make-sphere %f)))\n", 1000*radius);
fprintf(fp, " (setq qhull bdy)\n");
fprintf(fp, " (setq glv (gl::make-glvertices-from-faceset bdy\n");
Expand All @@ -1738,13 +1739,18 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
fprintf(fp, " (send glv :transform local-cds)\n");
fprintf(fp, " (send bdy :transform local-cds)\n");
fprintf(fp, " (send glv :calc-normals))\n");
fprintf(fp, "#-:gl\n");
fprintf(fp, " (let ((bdy (make-sphere %f)))\n", 1000*radius);
fprintf(fp, " (setq qhull bdy)\n");
fprintf(fp, " (send bdy :transform local-cds))\n");
} else if (g->type == Geometry::BOX) {
Vector3 vec = ((Box *)g.get())->dim;
#if 0
std::cerr << "BOX: " << name
<< ", dim = " << vec.x << " " << vec.y << " " << vec.z
<< std::endl;
#endif
fprintf(fp, "#+:gl\n");
fprintf(fp, " (let ((bdy (make-cube %f %f %f)))\n", 1000*vec.x, 1000*vec.y, 1000*vec.z);
fprintf(fp, " (setq qhull bdy)\n");
fprintf(fp, " (setq glv (gl::make-glvertices-from-faceset bdy\n");
Expand All @@ -1753,6 +1759,10 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
fprintf(fp, " (send glv :transform local-cds)\n");
fprintf(fp, " (send bdy :transform local-cds)\n");
fprintf(fp, " (send glv :calc-normals))\n");
fprintf(fp, "#-:gl\n");
fprintf(fp, " (let ((bdy (make-cube %f %f %f)))\n", 1000*vec.x, 1000*vec.y, 1000*vec.z);
fprintf(fp, " (setq qhull bdy)\n");
fprintf(fp, " (send bdy :transform local-cds))\n");
} else if (g->type == Geometry::CYLINDER) {
#if 0
std::cerr << "CYLINDER: " << name
Expand All @@ -1762,6 +1772,7 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
#endif
double length = ((Cylinder *)g.get())->length;
double radius = ((Cylinder *)g.get())->radius;
fprintf(fp, "#+:gl\n");
fprintf(fp, " (let ((bdy (make-cylinder %f %f :segments 24)))\n", 1000*radius, 1000*length);
fprintf(fp, " (send bdy :translate-vertices (float-vector 0 0 %f))\n", -500*length);
fprintf(fp, " (setq qhull bdy)\n");
Expand All @@ -1771,6 +1782,10 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
fprintf(fp, " (send glv :transform local-cds)\n");
fprintf(fp, " (send bdy :transform local-cds)\n");
fprintf(fp, " (send glv :calc-normals))\n");
fprintf(fp, "#-:gl\n");
fprintf(fp, " (let ((bdy (make-cylinder %f %f :segments 24)))\n", 1000*radius, 1000*length);
fprintf(fp, " (send bdy :translate-vertices (float-vector 0 0 %f))\n", -500*length);
fprintf(fp, " (setq qhull bdy))\n");
} else {
std::cerr << "unknown geometry type: " << name << std::endl;
}
Expand Down Expand Up @@ -1853,6 +1868,8 @@ 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, "#+:gl\n");
fprintf(fp, " (progn\n");
fprintf(fp, " (setq glv\n");
fprintf(fp, " (instance gl::glvertices :init\n");
fprintf(fp, " (list ;; mesh list\n");
Expand All @@ -1862,6 +1879,7 @@ void ModelEuslisp::printGeometry (boost::shared_ptr<Geometry> g, const Pose &pos
fprintf(fp, " ))\n");
fprintf(fp, " (send glv :transform local-cds)\n");
fprintf(fp, " (send glv :calc-normals)\n");
fprintf(fp, " )");
} else if (scene && scene->HasMeshes()) {
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);
Expand Down
15 changes: 15 additions & 0 deletions euscollada/src/euscollada-robot.l
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
(push (send bd :faces) fs)))
(setq fs (flatten fs))
(cond
#+:gl
((and (not fs) glv) ;; if there is no faces, use glvertices for creating pqpmodel
(setq usefs (instance gl::glvertices :init nil))
(send usefs :transform (send ll :worldcoords))
Expand All @@ -101,10 +102,24 @@

;; copy euscollada-body class definition from euscollada/src/euscollada-robot.l
;; This euscollada-body class is for bodies in robot model converted from collada files.
#+:gl
(defclass collada-body
:super gl::glbody
:slots (glvertices) ;; glvertices slot for backward compatibility
)
;; For euslisp without :gl features, may be we should put glbody/glvertices in irtgeo?
#-:gl
(defclass collada-body
:super body
;; glvertices slot for backward compatibility
;; aglvertices slot is defined in glbody
:slots (gl::aglvertices glvertices)
)
;; glbody defineds :gvertices methods
#-:gl
(defmethod collada-body
(:glvertices (&rest args) (user::forward-message-to glvertices args))
)
(defmethod collada-body
(:init (&key (name) (replace-obj))
(if replace-obj
Expand Down