HeightMap.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(AFX_HEIGHTMAP_H__F4CB4CAD_C592_4183_AFB2_016FC66C144A__INCLUDED_)
00022 #define AFX_HEIGHTMAP_H__F4CB4CAD_C592_4183_AFB2_016FC66C144A__INCLUDED_
00023 
00024 #include <stdlib.h>
00025 #include <common/ProgressCounter.h>
00026 #include <common/FixedVector.h>
00027 #include <common/Vector.h>
00028 
00029 class Line;
00030 class GraphicalHeightMap;
00031 class HeightMap  
00032 {
00033 public:
00034         HeightMap();
00035         virtual ~HeightMap();
00036 
00037         void create(int width, int height);
00038         void reset();
00039 
00040         // Height map size fns
00041         int getMapWidth() { return width_; }
00042         int getMapHeight() { return height_; }
00043 
00044         // Get height fns (z values)
00045         inline fixed getHeight(int w, int h) { 
00046                 if (w >= 0 && h >= 0 && w<=width_ && h<=height_) 
00047                         return heightData_[(width_+1) * h + w].position[2]; 
00048                 return fixed(0); }
00049         fixed getInterpHeight(fixed w, fixed h);
00050 
00051         // Get normal functions
00052         FixedVector &getNormal(int w, int h);
00053         void getInterpNormal(fixed w, fixed h, FixedVector &normal);
00054 
00055         bool getIntersect(Line &direction, Vector &intersect);
00056 
00057         // Alters the actual internal HeightMap points
00058         void setHeight(int w, int h, fixed height);
00059 
00060         GraphicalHeightMap *getGraphicalMap() { return graphicalMap_; }
00061         void setGraphicalMap(GraphicalHeightMap *map) { graphicalMap_ = map; }
00062 
00063 protected:
00064         struct HeightData
00065         {
00066                 FixedVector position;
00067                 FixedVector normal;
00068         };
00069 
00070         int width_, height_;
00071         HeightData *heightData_;
00072         GraphicalHeightMap *graphicalMap_;
00073 
00074         bool getVector(FixedVector &vec, int x, int y);
00075         void getVectorPos(int pos, int &x, int &y, int dist=1);
00076 };
00077 
00078 #endif // !defined(AFX_HEIGHTMAP_H__F4CB4CAD_C592_4183_AFB2_016FC66C144A__INCLUDED_)
00079 

Generated on Mon Feb 16 15:14:50 2009 for Scorched3D by  doxygen 1.5.3