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 * \relates LsgGroup 00051 * Allocate and initialize a new LsgGroup. 00052 * @return A new LsgGroup instance 00053 */ 00054 LsgGroup* LsgGroup_create(void); 00055 00056 /** 00057 * \relates LsgGroup 00058 * Constructor method for LsgGroup. 00059 * @param self The instance variable 00060 */ 00061 void LsgGroup_init(LsgGroup* self); 00062 00063 /** 00064 * \relates LsgGroup 00065 * Clean all children. 00066 * @param self The instance variable 00067 */ 00068 void LsgGroup_clean(LsgGroup* self); 00069 00070 /** 00071 * \relates LsgGroup 00072 * Update all children. 00073 * @param self The instance variable 00074 * @param now The current time 00075 */ 00076 void LsgGroup_update(LsgGroup* self, float time); 00077 00078 /** 00079 * \relates LsgGroup 00080 * Display all subnodes if they are visible within the current view frustum. 00081 * @param self The instance variable 00082 * @param frustum The current view frustum 00083 */ 00084 void LsgGroup_display(LsgGroup* self, LsgFrustum* frustum); 00085 00086 /** 00087 * \relates LsgGroup 00088 * Check for collision with all children. 00089 * @param self The instance variable 00090 * @param v Some vertex 00091 * @param nearest A buffer to store the nearest vertex to v that would collide 00092 * with any child 00093 * @return 1 if v collides with at least one child, 0 otherwise 00094 */ 00095 int LsgGroup_collide(LsgGroup* self, Vertex v, Vertex nearest); 00096 00097 /** 00098 * \relates LsgGroup 00099 * Destructor method for LsgGroup. 00100 * @param self The instance variable 00101 */ 00102 void LsgGroup_destroy(LsgGroup* self); 00103 00104 #endif