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

# osgheightfield.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 __OSGHEIGHTFIELD_H
    00025 #define __OSGHEIGHTFIELD_H
    00026
    00027
    00028 #include "osgprimitive.h"
    00029 #include <osg/Shape>
    00030
    00031 namespace lpzrobots {
    00032
    00033   /**
    00034      Graphical HeightField
    00035   */
    00036   class OSGHeightField : public OSGPrimitive {
    00037   public:
    00038
    00039     /** height coding using in the read in bitmap.
    00040      * Red: just the red channel is used;
    00041      * Sum: the sum of all channels is used;
    00042      * HighMidLow: Blue is least significant, Green is medium significant and Red is most significant
    00043      */
    00044     enum CodingMode {Red, Sum, LowMidHigh};
    00045
    00046
    00047     OSGHeightField(osg::HeightField* heightfield,float x_size, float y_size);
    00048     OSGHeightField(const std::string& filename, float x_size, float y_size, float height);
    00049
    00050     virtual void setMatrix(const osg::Matrix& matrix);
    00051     virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
    00052
    00053     virtual const osg::HeightField* getHeightField() const { return field; }
    00054
    00055     /** loads an ppm image and returns the height field using the given coding and the height
    00056         (maximal height of the heightfield)
    00057     */
    00058     static osg::HeightField* loadFromPPM(const std::string& filename, double height,
    00059                                          CodingMode codingMode=Red);
    00060     /// return the height using the given coding mode. The data pointer points to RGB data point
    00061     static double coding(CodingMode mode, const unsigned char* data);
    00062
    00063   protected:
    00064     osg::HeightField* field;
    00065     float x_size;
    00066     float y_size;
    00067   };
    00068
    00069
    00070
    00071 }
    00072
    00073 #endif