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 * Allocate and initialize a view frustum. 00061 * @param projection The projection matrix 00062 * @param modelview The modelview matrix 00063 * @return The view frustum as defined by projection and modelview 00064 */ 00065 LsgFrustum* LsgFrustum_create(const Matrix projection, const Matrix modelview); 00066 00067 /** 00068 * Constructor method for LsgFrustum. 00069 * @param self The instance variable 00070 * @param projection The projection matrix 00071 * @param modelview The modelview matrix 00072 */ 00073 void LsgFrustum_init(LsgFrustum* self, const Matrix projection, const Matrix modelview); 00074 00075 /** 00076 * Transform a view frustum. 00077 * @param self The instance variable 00078 * @param projection The transformation matrix for the projection matrix 00079 * @param modelview The transformation matrix for the modelview matrix 00080 */ 00081 void LsgFrustum_transform(LsgFrustum* self, const Matrix projection, const Matrix modelview); 00082 00083 /** 00084 * Update the clipping planes after transforming the defining projection 00085 * and/or modelview matrix. 00086 * @param self The instance variable 00087 */ 00088 void LsgFrustum_updatePlanes(LsgFrustum* self); 00089 00090 /** 00091 * The destructor method for LsgFrustum. Reuse parent implementation. 00092 */ 00093 #define LsgFrustum_destroy(self) LsgObject_destroy(&(self)->super) 00094 00095 #endif