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  * Allocate and initialize a bounding box.
00051  */
00052 LsgBBox* LsgBBox_create(void);
00053 
00054 /**
00055  * Constructor method for LsgBBox.
00056  * Initially set the bounding box state to invalid.
00057  * @param self  The instance variable
00058  */
00059 void LsgBBox_init(LsgBBox* self);
00060 
00061 /**
00062  * Clear the bounding box volume.
00063  * Set the bounding box state to invalid. Min and max are undefined.
00064  * @param self  The instance variable
00065  */
00066 void LsgBBox_clear(LsgBBox* self);
00067 
00068 /**
00069  * Include another bounding box in the bounded volume.
00070  * @param self  The instance variable
00071  * @param box   The other bounding box
00072  */
00073 void LsgBBox_combine(LsgBBox* self, const LsgBBox* box);
00074 
00075 /**
00076  * Add a vertex to the bounded volume.
00077  * @param self  The instance variable
00078  * @param v     The vertex to add to the bounded volume
00079  */
00080 void LsgBBox_include(LsgBBox* self, Vertex v);
00081 
00082 /**
00083  * Transform the bounding box with a matrix.
00084  * @param self  The instance variable
00085  * @param tm    The transformation matrix
00086  */
00087 void LsgBBox_transform(LsgBBox* self, Matrix tm);
00088 
00089 /**
00090  * Check if the bounding box contains a vertex.
00091  * @param self  The instance variable
00092  * @param v     The vertex to check
00093  * @return 1 if the vertex v is contained in the volume bound by self,
00094  *         0 otherwise
00095  */
00096 int LsgBBox_contains(LsgBBox* self, Vertex v);
00097 
00098 /**
00099  * Check if any part of the bounding box is inside a given view frustum.
00100  * @param self      The instance variable
00101  * @param frustum   The view frustum
00102  * @return 1 if any part of the volume bound by self intersects with the view
00103  *         frustum, 0 otherwise
00104  */
00105 int LsgBBox_visible(LsgBBox* self, LsgFrustum* frustum);
00106 
00107 /**
00108  * Compute the point nearest to a given vertex that is still inside the
00109  * bounded volume.
00110  * @param self  The instance variable
00111  * @param v     Some vertex
00112  * @param n     The buffer to hold the vertex nearest to v but still inside
00113  *              the bounded volume
00114  */
00115 void LsgBBox_nearest(LsgBBox* self, Vertex v, Vertex n);
00116 
00117 #endif

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