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

node.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_NODE_H
00024 #define LSG_NODE_H 1
00025 
00026 /**
00027  * \file  node.h
00028  * \brief Scene graph hierarchy base class
00029  */
00030 
00031 #include <lescegra/util/object.h>
00032 
00033 #include <lescegra/util/vertex.h>
00034 #include <lescegra/util/frustum.h>
00035 #include <lescegra/util/bbox.h>
00036 
00037 typedef struct LsgNode LsgNode;
00038 
00039 /**
00040  * \brief Scene graph hierarchy base class
00041  *
00042  * Abstract base class for the scene graph class hierarchy.
00043  */
00044 struct LsgNode {
00045     LsgObject super;
00046     LsgBBox* bbox;
00047     /**
00048      * Flag to indicate a changed boundig box. Parents should check this flag
00049      * after calling update and update their own bounding boxes if necessary.
00050      */
00051     int dirty;
00052     /**
00053      * Mark this node as having any changes processed. Call after running
00054      * update to ensure later calls to update don't have process to reevaluate
00055      * unchanged nodes.
00056      * @param self      The instance variable
00057      */
00058     void (*clean)(LsgNode* self);
00059     /**
00060      * Update this node to accommodate to passingtime.
00061      * @param self      The instance variable
00062      * @param now       The current time
00063      */
00064     void (*update)(LsgNode* self, float now);
00065     /**
00066      * Display this node.
00067      * @param self      The instance variable
00068      * @param frustum   The viewing frustum transformed to the local
00069      *                  coordinate system
00070      */
00071     void (*display)(LsgNode* self, LsgFrustum* frustum);
00072     /**
00073      * Check for collision and calculate nearest vertex if asked for.
00074      * @param self      The instance variable
00075      * @param v         Some vertex
00076      * @param nearest   The buffer to store the vertex nearest to v that would
00077      *                  cause a collision. May be NULL to indicate that the
00078      *                  computation is not neccessary.
00079      * @return 1 if the vertex v collides with the node, 0 otherwise
00080      */
00081     int  (*collide)(LsgNode* self, Vertex v, Vertex nearest);
00082 };
00083 
00084 /**
00085  * Constructor for LsgNode. Initially clear the bounding box and set the dirty flag
00086  * to make the first call to update recompute the complete bounding box tree.
00087  * @param self      The instance variable
00088  */
00089 void LsgNode_init(LsgNode* self);
00090 
00091 /**
00092  * Clean the node by unsetting the dirty flag.
00093  * @param self      The instance variable
00094  */
00095 void LsgNode_clean(LsgNode* self);
00096 
00097 /**
00098  * Update the node. Does nothing at all.
00099  * @param self      The instance variable
00100  */
00101 void LsgNode_update(LsgNode* self, float now);
00102 
00103 /**
00104  * Display this node. Does nothing at all.
00105  * @param self      The instance variable
00106  * @param frustum   The view frustum transformed to the local coordinat system
00107  */
00108 void LsgNode_display(LsgNode* self, LsgFrustum* frustum);
00109 
00110 /**
00111  * Check collision with this node. Delegate collision detection to bounding box
00112  * if it is valid. Otherwise always return 0. The value of nearest is not defined
00113  * if the bounding box is not valid.
00114  * @param self      The instance variable
00115  * @param v         Some vertex
00116  * @param nearest   The buffer to store the vertex nearest to v that would
00117  *                  cause a collision. May be NULL to indicate that the
00118  *                  computation is not neccessary.
00119  * @return 0 if bounding box is not valid, otherwise the return value of
00120  *         bbox_collide with the same vertex.
00121  */
00122 int  LsgNode_collide(LsgNode* self, Vertex v, Vertex nearest);
00123 
00124 /**
00125  * Destructor for LsgNode. Destroy the bounding box.
00126  * @param self      The instance variable
00127  */
00128 void LsgNode_destroy(LsgNode* self);
00129 
00130 #endif

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