Robot Simulator of the Robotics Group for Self-Organization of Control: tmpprimitive.h Source File

# tmpprimitive.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef __TMPPRIMITIVE_H
    00025 #define __TMPPRIMITIVE_H
    00026
    00027 #include "tmpobject.h"
    00028 #include <ode_robots/osgprimitive.h>
    00029
    00030 namespace lpzrobots {
    00031
    00032   class Primitive;
    00033   class Joint;
    00034
    00035   /**
    00036    holding a temporary primitive
    00037    */
    00038   class TmpPrimitive : public TmpObject {
    00039   public:
    00040     /** creates a new item from the given primitives and initializes it.
    00041         The lifetime is set when adding it to globalData
    00042      */
    00043     TmpPrimitive(Primitive* p, char mode, double mass, const Pose& pose,
    00044                  const Color& color);
    00045
    00046     /// provided for convenience to supply color as name and alpha independently
    00047     TmpPrimitive(Primitive* p, char mode, double mass, const Pose& pose,
    00048                  const std::string& colorname, float alpha = 1.0);
    00049
    00050     virtual void init(const OdeHandle& odeHandle, const OsgHandle& osgHandle);
    00051     virtual void deleteObject();
    00052     virtual void update();
    00053
    00054   private:
    00055     Primitive* item;
    00056     char mode;
    00057     double mass;
    00058     Pose pose;
    00059     Color color;
    00060     std::string colorname;
    00061     bool useColorName;
    00062     float alpha;
    00063     bool initialized;
    00064   };
    00065
    00066   /**
    00067    holding a temporary graphical item
    00068    */
    00069   class TmpDisplayItem : public TmpObject {
    00070   public:
    00071     /** creates a new item from the given primitives and initializes it.
    00072         The lifetime is set when adding it to globalData
    00073      */
    00074     TmpDisplayItem(OSGPrimitive* p, const Pose& pose, const Color& color,
    00075                    OSGPrimitive::Quality quality = OSGPrimitive::Middle);
    00076
    00077     /// provided for convenience to supply color as name and alpha independently
    00078     TmpDisplayItem(OSGPrimitive* p, const Pose& pose,
    00079                    const std::string& colorname, float alpha = 1.0,
    00080                    OSGPrimitive::Quality quality = OSGPrimitive::Middle);
    00081
    00082     virtual void init(const OdeHandle& odeHandle, const OsgHandle& osgHandle);
    00083
    00084     virtual void deleteObject();
    00085     virtual void update() {} // nothing to be done here, because they do not move
    00086
    00087   private:
    00088     OSGPrimitive* item;
    00089     Pose pose;
    00090     Color color;
    00091     std::string colorname;
    00092     bool useColorName;
    00093     float alpha;
    00094     OSGPrimitive::Quality quality;
    00095     bool initialized;
    00096   };
    00097
    00098   /**
    00099    holding a temporary joint
    00100    */
    00101   class TmpJoint : public TmpObject {
    00102   public:
    00103     /** creates a new tmporary object from the given joint and initializes it.
    00104         The lifetime is set when adding it to globalData
    00105      */
    00106     TmpJoint(Joint* p, const Color& color, bool withVisual = true, double visualSize = 0.2,
    00107              bool ignoreColl = true);
    00108
    00109     /// provided for convenience to supply color as name and alpha independently
    00110     TmpJoint(Joint* p, const std::string& colorname, float alpha = 1.0,
    00111              bool withVisual = true, double visualSize = 0.2, bool ignoreColl = true);
    00112
    00113     virtual void init(const OdeHandle& odeHandle, const OsgHandle& osgHandle);
    00114
    00115     virtual void deleteObject();
    00116     virtual void update();
    00117
    00118   private:
    00119     Joint* joint;
    00120     Color color;
    00121     std::string colorname;
    00122     bool useColorName;
    00123     float alpha;
    00124     bool withVisual;
    00125     double visualSize;
    00126     bool ignoreColl;
    00127     bool initialized;
    00128   };
    00129
    00130
    00131
    00132 }
    00133
    00134 #endif