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_MD2MODEL_H 00024 #define LSG_MD2MODEL_H 1 00025 00026 /** 00027 * \file md2model.h 00028 * \brief Quake II model container and loader 00029 */ 00030 00031 #include <lescegra/sg/node.h> 00032 00033 #include <lescegra/util/vertex.h> 00034 00035 typedef float LsgTexCoord[2]; 00036 00037 typedef struct { 00038 int vertices[3]; 00039 int tex_coords[3]; 00040 } LsgMD2Triangle; 00041 00042 /** 00043 * \ingroup geometry 00044 * \brief Quake II model container 00045 * 00046 * Container class for a Quake II model with animation frames and skin 00047 * textures. 00048 */ 00049 typedef struct { 00050 LsgNode super; 00051 int frame; 00052 int skin; 00053 int frame_count; 00054 int triangle_count; 00055 int vertex_count; 00056 int skin_count; 00057 LsgMD2Triangle* triangles; 00058 LsgTexCoord* tex_coords; 00059 Vertex* vertices; 00060 int* normals; 00061 unsigned int* skins; 00062 } LsgMD2Model; 00063 00064 /** 00065 * Allocate and initialize a LsgMD2Model instance. 00066 * @param filename The name of the file containing the Quake II model data 00067 * @return A new LsgMD2Model instance 00068 */ 00069 LsgMD2Model* LsgMD2Model_create(const char* filename); 00070 00071 /** 00072 * Constructor method for LsgMD2Model. Load a Quake II model from the given 00073 * file. 00074 * @param self The instance variable 00075 * @param filename The name of the Quake II model file 00076 */ 00077 void LsgMD2Model_init(LsgMD2Model* self, const char* filename); 00078 void LsgMD2Model_display(LsgMD2Model* self, LsgFrustum* frust); 00079 void LsgMD2Model_displayWireframe(LsgMD2Model* self, LsgFrustum* frust); 00080 void LsgMD2Model_destroy(LsgMD2Model* self); 00081 00082 /** 00083 * Optimize the nodes bounding box to exactly fit the current frame. 00084 * @param self The instance variable 00085 */ 00086 void LsgMD2Model_optimizeBBox(LsgMD2Model* self); 00087 00088 #define LsgMD2Model_clean(self) LsgNode_clean(&(self)->super) 00089 #define LsgMD2Model_update(self, now) LsgNode_update(&(self)->super, now) 00090 00091 #endif