00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00037 #include <iostream>
00038
00039
00040 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
00041 #include <Inventor/actions/SoGetBoundingBoxAction.h>
00042 #include <Inventor/actions/SoSearchAction.h>
00043 #include <Inventor/nodes/SoCylinder.h>
00044 #include <Inventor/nodes/SoCone.h>
00045 #include <Inventor/nodes/SoCube.h>
00046 #include <Inventor/nodes/SoSphere.h>
00047 #include <Inventor/SoLists.h>
00048 #include "SoArrow.h"
00049 #include "SoTorquePointer.h"
00050 #include "SoComplexShape.h"
00051 #include <Inventor/fields/SoSFFloat.h>
00052 #include <Inventor/actions/SoGetMatrixAction.h>
00053 #include <Inventor/SbLinear.h>
00054 #include <Inventor/nodes/SoRotation.h>
00055 #include <Inventor/nodes/SoCamera.h>
00056 #include <Inventor/nodes/SoTransformSeparator.h>
00057 #include <Inventor/nodes/SoDirectionalLight.h>
00058 #include <Inventor/sensors/SoIdleSensor.h>
00059 #include <Inventor/nodes/SoMaterial.h>
00060 #include <Inventor/SbColor.h>
00061 #include <Inventor/nodes/SoTransform.h>
00062
00063 #include "grasp_visualization.h"
00064
00074 grasp_representation::grasp_representation(SbMatrix mat, SbMatrix thMat, SoSeparator* glroot){
00075
00076 parentSep = glroot;
00077
00078 top = new SoSeparator();
00079 sep = new SoSeparator();
00080 thSep = new SoSeparator();
00081
00082 material = new SoMaterial();
00083
00084 tranArrowSphere = new SoTransform();
00085 arrow = new SoArrow();
00086 arrow->height.setValue(50.);
00087 sphere = new SoSphere();
00088 sphere->radius.setValue(5.0);
00089
00090 thRot = new SoTransform();
00091 thArrow = new SoArrow();
00092 thArrow->height.setValue(20.);
00093
00094 top->addChild(sep);
00095 top->addChild(thSep);
00096
00097 sep->addChild(tranArrowSphere);
00098 sep->addChild(material);
00099 sep->addChild(arrow);
00100 sep->addChild(sphere);
00101
00102 thSep->addChild(material);
00103 thSep->addChild(thRot);
00104 thSep->addChild(thArrow);
00105
00106 tranArrowSphere->setMatrix(mat);
00107
00108 thRot->setMatrix(thMat);
00109
00110 parentSep->addChild(top);
00111
00112 visOn = true;
00113 }
00114
00118 grasp_representation::~grasp_representation(){
00119
00120 if (visOn)
00121 parentSep->removeChild(top);
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 }
00146
00150 void
00151 grasp_representation::changeColor(double r, double g, double b){
00152 material->diffuseColor.setValue((float)r,(float)g,(float)b);
00153 material->transparency.setValue(0.5);
00154 }
00155
00160 void
00161 grasp_representation::resetColor(){
00162 material->setToDefaults();
00163 }
00164
00169 void
00170 grasp_representation::changeRadius(double rad){
00171 sphere->radius.setValue((float)(rad * GRASP_SPHERE_SIZE_FACTOR));
00172 }
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188