Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

hterrain.h

Go to the documentation of this file.
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_HTERRAIN_H
00024 #define LSG_HTERRAIN_H 1
00025 
00026 /**
00027  * \file  hterrain.h
00028  * \brief Hierarchical subdivided terrain
00029  */
00030 
00031 #include <lescegra/sg/node.h>
00032 
00033 #include <lescegra/util/vertex.h>
00034 #include <lescegra/util/image.h>
00035 
00036 typedef struct {
00037     Vertex n;
00038     Vertex v;
00039 } LsgHTerrainDataElement;
00040 
00041 typedef struct {
00042     int width;
00043     int depth;
00044     LsgHTerrainDataElement elements[1];
00045 } LsgHTerrainData;
00046 
00047 /**
00048  * \ingroup geometry
00049  * \brief   Hierarchical subdivided terrain
00050  *
00051  * A hierarchical subdivided terrain node to allow swift rendering of
00052  * static terrain with up to several million vertices.
00053  */
00054 typedef struct {
00055     LsgNode super;
00056     LsgHTerrainData* data;
00057     int min_x;
00058     int min_z;
00059     int max_x;
00060     int max_z;
00061 } LsgHTerrain;
00062 
00063 LsgHTerrain* LsgHTerrain_create(LsgHTerrainData* data, int min_x, int min_z, int max_x, int max_z);
00064 void LsgHTerrain_init(LsgHTerrain* self, LsgHTerrainData* data, int min_x, int min_z, int max_x, int max_z);
00065 void LsgHTerrain_display(LsgHTerrain* self, LsgFrustum* frust);
00066 int  LsgHTerrain_collide(LsgHTerrain* self, Vertex v, Vertex nearest);
00067 
00068 #define LsgHTerrain_clean(self)       LsgNode_clean(&(self)->super)
00069 #define LsgHTerrain_update(self, now) LsgNode_update(&(self)->super, now)
00070 #define LsgHTerrain_destroy(self)     LsgNode_destroy(&(self)->super)
00071 
00072 /* LsgHTerrainLsgGroup */
00073 
00074 #include <lescegra/sg/group.h>
00075 
00076 typedef struct {
00077     LsgGroup super;
00078     int div_x;
00079     int div_z;
00080     float min_x;
00081     float min_z;
00082     float width;
00083     float depth;
00084 } LsgHTerrainLsgGroup;
00085 
00086 LsgHTerrainLsgGroup* LsgHTerrainLsgGroup_create(float min_x, float min_z, float width, float depth, int div_x, int div_z);
00087 void LsgHTerrainLsgGroup_init(LsgHTerrainLsgGroup* self, float min_x, float min_z, float width, float depth, int div_x, int div_z);
00088 int LsgHTerrainLsgGroup_collide(LsgHTerrainLsgGroup* self, Vertex v, Vertex nearest);
00089 
00090 #define LsgHTerrainLsgGroup_clean(self)          LsgGroup_clean(&(self)->super)
00091 #define LsgHTerrainLsgGroup_update(self, now)    LsgGroup_update(&(self)->super, now)
00092 #define LsgHTerrainLsgGroup_display(self, frust) LsgGroup_display(&(self)->super, frust)
00093 #define LsgHTerrainLsgGroup_destroy(self)        LsgGroup_destroy(&(self)->super)
00094 
00095 /* something else :) */
00096 
00097 LsgNode* LsgHTerrain_createHierarchy(LsgImage* img, int size, Vertex dimension);
00098 
00099 #endif

(c) 2003, by Enno Cramer
generated on 9 Jul 2003
lescegra - doxygen