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_FRUSTUM_H 00024 #define LSG_FRUSTUM_H 1 00025 00026 /** 00027 * \file frustum.h 00028 * \brief View Frustum 00029 */ 00030 00031 #include <lescegra/util/object.h> 00032 00033 #include <lescegra/util/vertex.h> 00034 #include <lescegra/util/matrix.h> 00035 00036 /** 00037 * \brief Clipping plane 00038 * 00039 * A view frustum clipping plane 00040 */ 00041 typedef struct { 00042 Vertex normal; 00043 float distance; 00044 } LsgPlane; 00045 00046 /** 00047 * \brief View Frustum 00048 * 00049 * A view frustum defined by two matrizes (modelview and projection) 00050 * and the six clipping planes. 00051 */ 00052 typedef struct { 00053 LsgObject super; 00054 Matrix projection; 00055 Matrix modelview; 00056 LsgPlane planes[6]; 00057 } LsgFrustum; 00058 00059 /** 00060 * \relates LsgFrustum 00061 * Allocate and initialize a view frustum. 00062 * @param projection The projection matrix 00063 * @param modelview The modelview matrix 00064 * @return The view frustum as defined by projection and modelview 00065 */ 00066 LsgFrustum* LsgFrustum_create(const Matrix projection, const Matrix modelview); 00067 00068 /** 00069 * \relates LsgFrustum 00070 * Constructor method for LsgFrustum. 00071 * @param self The instance variable 00072 * @param projection The projection matrix 00073 * @param modelview The modelview matrix 00074 */ 00075 void LsgFrustum_init(LsgFrustum* self, const Matrix projection, const Matrix modelview); 00076 00077 /** 00078 * \relates LsgFrustum 00079 * Transform a view frustum. 00080 * @param self The instance variable 00081 * @param projection The transformation matrix for the projection matrix 00082 * @param modelview The transformation matrix for the modelview matrix 00083 */ 00084 void LsgFrustum_transform(LsgFrustum* self, const Matrix projection, const Matrix modelview); 00085 00086 /** 00087 * \relates LsgFrustum 00088 * Update the clipping planes after transforming the defining projection 00089 * and/or modelview matrix. 00090 * @param self The instance variable 00091 */ 00092 void LsgFrustum_updatePlanes(LsgFrustum* self); 00093 00094 /** 00095 * The destructor method for LsgFrustum. Reuse parent implementation. 00096 */ 00097 #define LsgFrustum_destroy(self) LsgObject_destroy(&(self)->super) 00098 00099 #endif