• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KGLLib

simpleterrain.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Rivo Laks <rivolaks@hot.ee>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either 
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public 
00015  * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef KGLLIB_SIMPLETERRAIN_H
00019 #define KGLLIB_SIMPLETERRAIN_H
00020 
00021 
00022 #include "mesh.h"
00023 
00024 #include <Eigen/Core>
00025 
00026 
00027 class QString;
00028 
00029 
00030 namespace KGLLib
00031 {
00032 class Batch;
00033 
00034 class KGLLIB_EXTRAS_EXPORT SimpleTerrain : public Mesh
00035 {
00036 public:
00037     SimpleTerrain(const QString& imgfilename);
00038     virtual ~SimpleTerrain();
00039 
00040     virtual void render();
00041 
00042     void setHeightRange(float min, float max);
00043     void setTileSize(float size);
00044 
00045     int width() const  { return mWidth; }
00046     int height() const  { return mHeight; }
00047     float tileSize() const  { return mTileSize; }
00048     bool isValid() const;
00049 
00050 protected:
00051     void addVertex(int x, int z, int index);
00052     void recalcNormalmap();
00053     void cookMesh(bool useIndices);
00054     inline float height(int x, int z) const  { return mMinHeight + mHeightmap[x][z] * (mMaxHeight - mMinHeight); }
00055     Eigen::Vector3f cellNormal(int x1, int z1,  int x2, int z2,  int x3, int z3);
00056     void setDirty();
00057 
00058 protected:
00059     class Chunk;
00060     float** mHeightmap;
00061     Eigen::Vector3f** mNormalmap;
00062     bool mDirty;
00063 
00064     Eigen::Vector3f* mVertices;
00065     Eigen::Vector3f* mNormals;
00066     unsigned int* mIndices;
00067 
00068     int mWidth;
00069     int mHeight;
00070 
00071     float mMinHeight;
00072     float mMaxHeight;
00073     float mTileSize;
00074 };
00075 
00076 }
00077 
00078 #endif

KGLLib

Skip menu "KGLLib"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KGLLib
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal