00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 *************************************************************************** 00022 * * 00023 * DESCRIPTION * 00024 * * 00025 * $Log: osgheightfield.h,v $ 00026 * Revision 1.3 2009/07/30 11:36:01 guettler 00027 * added check if noGraphics in OsgHandle is set 00028 * 00029 * Revision 1.2 2006/07/14 12:23:35 martius 00030 * selforg becomes HEAD 00031 * 00032 * Revision 1.1.2.2 2006/05/29 20:10:06 martius 00033 * docu 00034 * 00035 * Revision 1.1.2.1 2006/05/28 22:14:56 martius 00036 * heightfield included 00037 * 00038 * Revision 1.1.2.1 2005/12/06 17:38:21 martius 00039 * *** empty log message *** 00040 * 00041 * * 00042 ***************************************************************************/ 00043 #ifndef __OSGHEIGHTFIELD_H 00044 #define __OSGHEIGHTFIELD_H 00045 00046 00047 #include "osgprimitive.h" 00048 #include <osg/Shape> 00049 00050 namespace lpzrobots { 00051 00052 /** 00053 Graphical HeightField 00054 */ 00055 class OSGHeightField : public OSGPrimitive { 00056 public: 00057 00058 /// height coding using in the read in bitmap. 00059 // Red: just the red channel is used; 00060 // Sum: the sum of all channels is used; 00061 // HighMidLow: Blue is least significant, Green is medium significant and Red is most significant 00062 /* typedef */ enum CodingMode {Red, Sum, LowMidHigh}; 00063 00064 00065 OSGHeightField(osg::HeightField* heightfield,float x_size, float y_size); 00066 OSGHeightField(const std::string& filename, float x_size, float y_size, float height); 00067 00068 virtual void setMatrix(const osg::Matrix& matrix); 00069 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle); 00070 00071 virtual const osg::HeightField* getHeightField() const { return field; } 00072 00073 /** loads an ppm image and returns the height field using the given coding and the height 00074 (maximal height of the heightfield) 00075 */ 00076 static osg::HeightField* loadFromPPM(const std::string& filename, double height, 00077 CodingMode codingMode=Red); 00078 /// return the height using the given coding mode. The data pointer points to RGB data point 00079 static double coding(CodingMode mode, const unsigned char* data); 00080 00081 protected: 00082 osg::HeightField* field; 00083 float x_size; 00084 float y_size; 00085 }; 00086 00087 00088 00089 } 00090 00091 #endif