00001 /********************************************************************* 00002 * lescegra * 00003 * * 00004 * http://geeky.kicks-ass.org/projects/lescegra.html * 00005 * * 00006 * Copyright 2003 by Enno Cramer <uebergeek@web.de> * 00007 * * 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Library General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2 of the License, or (at your option) any later version. * 00012 * * 00013 * This library 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 GNU * 00016 * Library General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Library General Public * 00019 * License along with this library; if not, write to the Free * 00020 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00021 *********************************************************************/ 00022 00023 #ifndef LSG_TERRAIN_H 00024 #define LSG_TERRAIN_H 1 00025 00026 /** 00027 * \file terrain.h 00028 * \brief Heightfield/Terrain 00029 */ 00030 00031 #include <lescegra/sg/gllist.h> 00032 00033 #include <lescegra/util/vertex.h> 00034 #include <lescegra/util/image.h> 00035 00036 /** 00037 * \ingroup geometry 00038 * \brief Heightfield/Terrain 00039 * 00040 * Heightfield/Terrain using a single OpenGL list to store vertex / 00041 * normal data. 00042 */ 00043 typedef struct { 00044 LsgGLList super; 00045 } LsgTerrain; 00046 00047 /** 00048 * \relates LsgTerrain 00049 * Allocate and initialize a terrain node. 00050 * @param hf The bitmap used to construct the terrain 00051 * @param dim The dimension of the constructed terrain 00052 * @return A new terrain node 00053 */ 00054 LsgTerrain* LsgTerrain_create(LsgImage* hf, Vertex dim); 00055 00056 /** 00057 * \relates LsgTerrain 00058 * Constructor method for LsgTerrain. Convert a bitmaps pixel values to vertices 00059 * and store them in an OpenGL list alongside with calculated normals. 00060 * @param self The instance variable 00061 * @param hf The bitmap used to construct the terrain 00062 * @param dim The dimension of the constructed terrain 00063 */ 00064 void LsgTerrain_init(LsgTerrain* self, LsgImage* hf, Vertex dim); 00065 00066 /** 00067 * Clean this node. Reuse parent implementation. 00068 */ 00069 #define LsgTerrain_clean(self) LsgGLList_clean(&(self)->super) 00070 00071 /** 00072 * Update this node. Reuse parent implementation. 00073 */ 00074 #define LsgTerrain_update(self, now) LsgGLList_update(&(self)->super, now) 00075 00076 /** 00077 * Display this node. Reuse parent implementation. 00078 */ 00079 #define LsgTerrain_display(self, frust) LsgGLList_display(&(self)->super, frust) 00080 00081 /** 00082 * Destructor for LsgTerrain. Reuse parent implementation. 00083 */ 00084 #define LsgTerrain_destroy(self) LsgGLList_destroy(&(self)->super) 00085 00086 #endif