Grip-Reloaded
Grip version visualizaiton interface for DART (DynamicAnimationandRoboticsToolkits)
|
00001 /* 00002 * Copyright (c) 2014, Georgia Tech Research Corporation 00003 * All rights reserved. 00004 * 00005 * Author: Pete Vieira <pete.vieira@gatech.edu> 00006 * Date: Feb 2014 00007 * 00008 * Humanoid Robotics Lab Georgia Institute of Technology 00009 * Director: Mike Stilman http://www.golems.org 00010 * 00011 * 00012 * This file is provided under the following "BSD-style" License: 00013 * Redistribution and use in source and binary forms, with or 00014 * without modification, are permitted provided that the following 00015 * conditions are met: 00016 * 00017 * * Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * 00020 * * Redistributions in binary form must reproduce the above 00021 * copyright notice, this list of conditions and the following 00022 * disclaimer in the documentation and/or other materials provided 00023 * with the distribution. 00024 * 00025 * * Neither the name of the Humanoid Robotics Lab nor the names of 00026 * its contributors may be used to endorse or promote products 00027 * derived from this software without specific prior written 00028 * permission 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 00031 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 00032 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00033 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00034 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00035 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00036 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00037 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00038 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00039 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00040 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00041 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00042 * POSSIBILITY OF SUCH DAMAGE. 00043 */ 00044 00051 #ifndef SHAPES_H 00052 #define SHAPES_H 00053 00054 // OpenSceneGraph includes 00055 #include <osg/Geode> 00056 #include <osg/ShapeDrawable> 00057 00062 namespace osgGolems { 00063 00068 class Sphere : public osg::Geode 00069 { 00070 public: 00077 inline Sphere(const osg::Vec3& center, float radius, const osg::Vec4& color=osg::Vec4(0,0,0,1)) 00078 { 00079 _sphere = new osg::Sphere(center, radius); 00080 _shapeDrawable = new osg::ShapeDrawable(_sphere); 00081 _shapeDrawable->setColor(color); 00082 this->addDrawable(_shapeDrawable); 00083 } 00084 00090 inline void setColor(const osg::Vec4& newColor) 00091 { 00092 _shapeDrawable->setColor(newColor); 00093 } 00094 00100 inline void setCenter(const osg::Vec3& newCenter) 00101 { 00102 _sphere->setCenter(newCenter); 00103 } 00104 00110 inline void setRadius(float newRadius) 00111 { 00112 _sphere->setRadius(newRadius); 00113 } 00114 00115 protected: 00116 00118 osg::Sphere* _sphere; 00119 00121 osg::ShapeDrawable* _shapeDrawable; 00122 00123 }; // end class Sphere 00124 00125 00130 class Cylinder : public osg::Geode 00131 { 00132 public: 00140 inline Cylinder(const osg::Vec3& center, float radius, float height, const osg::Vec4& color=osg::Vec4(0,0,0,1)) 00141 { 00142 _cylinder = new osg::Cylinder(center, radius, height); 00143 _shapeDrawable = new osg::ShapeDrawable(_cylinder); 00144 _shapeDrawable->setColor(color); 00145 this->addDrawable(_shapeDrawable); 00146 } 00147 00153 inline void setColor(const osg::Vec4& newColor) 00154 { 00155 _shapeDrawable->setColor(newColor); 00156 } 00157 00163 inline void setRadius(float newRadius) 00164 { 00165 _cylinder->setRadius(newRadius); 00166 } 00167 00173 inline void setHeight(float newHeight) 00174 { 00175 _cylinder->setHeight(newHeight); 00176 } 00177 00178 protected: 00179 00181 osg::Cylinder* _cylinder; 00182 00184 osg::ShapeDrawable* _shapeDrawable; 00185 00186 }; // end class Cylinder 00187 00188 00193 class Box : public osg::Geode 00194 { 00195 public: 00202 inline Box(const osg::Vec3& center, float width, const osg::Vec4& color=osg::Vec4(0,0,0,1)) 00203 { 00204 _box = new osg::Box(center, width); 00205 _shapeDrawable = new osg::ShapeDrawable(_box); 00206 _shapeDrawable->setColor(color); 00207 this->addDrawable(_shapeDrawable); 00208 } 00209 00215 inline void setColor(const osg::Vec4& newColor) 00216 { 00217 _shapeDrawable->setColor(newColor); 00218 } 00219 00225 inline void setCenter(const osg::Vec3& newCenter) 00226 { 00227 _box->setCenter(newCenter); 00228 } 00229 00230 //TODO add function for changing the size of the box. Hopefully the setHalfLengths function 00231 00232 protected: 00233 00235 osg::Box* _box; 00236 00238 osg::ShapeDrawable* _shapeDrawable; 00239 00240 }; // end class Box 00241 00246 class Cone : public osg::Geode 00247 { 00248 public: 00255 inline Cone(const osg::Vec3& center, float radius, float height, const osg::Vec4& color=osg::Vec4(0,0,0,1)) 00256 { 00257 _cone = new osg::Cone(center, radius, height); 00258 _shapeDrawable = new osg::ShapeDrawable(_cone); 00259 _shapeDrawable->setColor(color); 00260 this->addDrawable(_shapeDrawable); 00261 } 00262 00268 inline void setColor(const osg::Vec4& newColor) 00269 { 00270 _shapeDrawable->setColor(newColor); 00271 } 00272 00278 inline void setRadius(float newRadius) 00279 { 00280 _cone->setRadius(newRadius); 00281 } 00282 00288 inline void setHeight(float newHeight) 00289 { 00290 _cone->setHeight(newHeight); 00291 } 00292 00293 protected: 00294 00296 osg::Cone* _cone; 00297 00299 osg::ShapeDrawable* _shapeDrawable; 00300 00301 }; // end class Cone 00302 00307 class Capsule : public osg::Geode 00308 { 00309 public: 00317 inline Capsule(const osg::Vec3& center, float radius, float height, const osg::Vec4& color=osg::Vec4(0,0,0,1)) 00318 { 00319 _capsule = new osg::Capsule(center, radius, height); 00320 _shapeDrawable = new osg::ShapeDrawable(_capsule); 00321 _shapeDrawable->setColor(color); 00322 this->addDrawable(_shapeDrawable); 00323 } 00324 00330 inline void setColor(const osg::Vec4& newColor) 00331 { 00332 _shapeDrawable->setColor(newColor); 00333 } 00334 00340 inline void setRadius(float newRadius) 00341 { 00342 _capsule->setRadius(newRadius); 00343 } 00344 00350 inline void setHeight(float newHeight) 00351 { 00352 _capsule->setHeight(newHeight); 00353 } 00354 00355 protected: 00357 osg::Capsule* _capsule; 00358 00360 osg::ShapeDrawable* _shapeDrawable; 00361 00362 }; // end class Capsule 00363 00364 } // end namepsace osgGolems 00365 00366 #endif // SHAPES_H