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 * Allocate and initialize a terrain node. 00049 * @param hf The bitmap used to construct the terrain 00050 * @param dim The dimension of the constructed terrain 00051 * @return A new terrain node 00052 */ 00053 LsgTerrain* LsgTerrain_create(LsgImage* hf, Vertex dim); 00054 00055 /** 00056 * Constructor method for LsgTerrain. Convert a bitmaps pixel values to vertices 00057 * and store them in an OpenGL list alongside with calculated normals. 00058 * @param self The instance variable 00059 * @param hf The bitmap used to construct the terrain 00060 * @param dim The dimension of the constructed terrain 00061 */ 00062 void LsgTerrain_init(LsgTerrain* self, LsgImage* hf, Vertex dim); 00063 00064 /** 00065 * Clean this node. Reuse parent implementation. 00066 */ 00067 #define LsgTerrain_clean(self) LsgGLList_clean(&(self)->super) 00068 00069 /** 00070 * Update this node. Reuse parent implementation. 00071 */ 00072 #define LsgTerrain_update(self, now) LsgGLList_update(&(self)->super, now) 00073 00074 /** 00075 * Display this node. Reuse parent implementation. 00076 */ 00077 #define LsgTerrain_display(self, frust) LsgGLList_display(&(self)->super, frust) 00078 00079 /** 00080 * Destructor for LsgTerrain. Reuse parent implementation. 00081 */ 00082 #define LsgTerrain_destroy(self) LsgGLList_destroy(&(self)->super) 00083 00084 #endif