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_GROUP_H 00024 #define LSG_GROUP_H 1 00025 00026 /** 00027 * \file group.h 00028 * \brief Basic grouping node 00029 */ 00030 00031 #include <lescegra/sg/node.h> 00032 00033 #include <lescegra/util/list.h> 00034 #include <lescegra/util/vertex.h> 00035 #include <lescegra/util/frustum.h> 00036 00037 /** 00038 * \ingroup scene 00039 * \brief Basic grouping node 00040 * 00041 * The junction base class for the scene graph. Allows grouping of nodes and 00042 * thereby hierarchical view frustum culling and collision detection. 00043 */ 00044 typedef struct { 00045 LsgNode super; 00046 LsgList* children; 00047 } LsgGroup; 00048 00049 /** 00050 * Allocate and initialize a new LsgGroup. 00051 * @return A new LsgGroup instance 00052 */ 00053 LsgGroup* LsgGroup_create(void); 00054 00055 /** 00056 * Constructor method for LsgGroup. 00057 * @param self The instance variable 00058 */ 00059 void LsgGroup_init(LsgGroup* self); 00060 00061 /** 00062 * Clean all children. 00063 * @param self The instance variable 00064 */ 00065 void LsgGroup_clean(LsgGroup* self); 00066 00067 /** 00068 * Update all children. 00069 * @param self The instance variable 00070 * @param now The current time 00071 */ 00072 void LsgGroup_update(LsgGroup* self, float time); 00073 00074 /** 00075 * Display all subnodes if they are visible within the current view frustum. 00076 * @param self The instance variable 00077 * @param frustum The current view frustum 00078 */ 00079 void LsgGroup_display(LsgGroup* self, LsgFrustum* frustum); 00080 00081 /** 00082 * Check for collision with all children. 00083 * @param self The instance variable 00084 * @param v Some vertex 00085 * @param nearest A buffer to store the nearest vertex to v that would collide 00086 * with any child 00087 * @return 1 if v collides with at least one child, 0 otherwise 00088 */ 00089 int LsgGroup_collide(LsgGroup* self, Vertex v, Vertex nearest); 00090 00091 /** 00092 * Destructor method for LsgGroup. 00093 * @param self The instance variable 00094 */ 00095 void LsgGroup_destroy(LsgGroup* self); 00096 00097 #endif