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

bbox.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_BBOX_H
00024 #define LSG_BBOX_H 1
00025 
00026 /**
00027  * \file  bbox.h
00028  * \brief Axis Aligned Bounding Box
00029  */
00030 
00031 #include <lescegra/util/object.h>
00032 
00033 #include <lescegra/util/vertex.h>
00034 #include <lescegra/util/matrix.h>
00035 #include <lescegra/util/frustum.h>
00036 
00037 /**
00038  * \brief Axis Aligned Bounding Box
00039  *
00040  * An axis aligned bounding box
00041  */
00042 typedef struct {
00043     LsgObject super;
00044     Vertex min;
00045     Vertex max;
00046     int valid;
00047 } LsgBBox;
00048 
00049 /**
00050  * \relates LsgBBox
00051  * Allocate and initialize a bounding box.
00052  */
00053 LsgBBox* LsgBBox_create(void);
00054 
00055 /**
00056  * \relates LsgBBox
00057  * Constructor method for LsgBBox.
00058  * Initially set the bounding box state to invalid.
00059  * @param self  The instance variable
00060  */
00061 void LsgBBox_init(LsgBBox* self);
00062 
00063 /**
00064  * \relates LsgBBox
00065  * Clear the bounding box volume.
00066  * Set the bounding box state to invalid. Min and max are undefined.
00067  * @param self  The instance variable
00068  */
00069 void LsgBBox_clear(LsgBBox* self);
00070 
00071 /**
00072  * \relates LsgBBox
00073  * Include another bounding box in the bounded volume.
00074  * @param self  The instance variable
00075  * @param box   The other bounding box
00076  */
00077 void LsgBBox_combine(LsgBBox* self, const LsgBBox* box);
00078 
00079 /**
00080  * \relates LsgBBox
00081  * Add a vertex to the bounded volume.
00082  * @param self  The instance variable
00083  * @param v     The vertex to add to the bounded volume
00084  */
00085 void LsgBBox_include(LsgBBox* self, Vertex v);
00086 
00087 /**
00088  * \relates LsgBBox
00089  * Transform the bounding box with a matrix.
00090  * @param self  The instance variable
00091  * @param tm    The transformation matrix
00092  */
00093 void LsgBBox_transform(LsgBBox* self, Matrix tm);
00094 
00095 /**
00096  * \relates LsgBBox
00097  * Check if the bounding box contains a vertex.
00098  * @param self  The instance variable
00099  * @param v     The vertex to check
00100  * @return 1 if the vertex v is contained in the volume bound by self,
00101  *         0 otherwise
00102  */
00103 int LsgBBox_contains(LsgBBox* self, Vertex v);
00104 
00105 /**
00106  * \relates LsgBBox
00107  * Check if any part of the bounding box is inside a given view frustum.
00108  * @param self      The instance variable
00109  * @param frustum   The view frustum
00110  * @return 1 if any part of the volume bound by self intersects with the view
00111  *         frustum, 0 otherwise
00112  */
00113 int LsgBBox_visible(LsgBBox* self, LsgFrustum* frustum);
00114 
00115 /**
00116  * \relates LsgBBox
00117  * Compute the point nearest to a given vertex that is still inside the
00118  * bounded volume.
00119  * @param self  The instance variable
00120  * @param v     Some vertex
00121  * @param n     The buffer to hold the vertex nearest to v but still inside
00122  *              the bounded volume
00123  */
00124 void LsgBBox_nearest(LsgBBox* self, Vertex v, Vertex n);
00125 
00126 #endif

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