1 /* 2 * Models.h 3 * Copyright (C) 2007 by Bryan Duff <duff0097@gmail.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 * USA 19 */ 20 #ifndef _MODELS_H_ 21 #define _MODELS_H_ 22 23 /**> Model Loading <**/ 24 // 25 // Model Maximums 26 // 27 #include "Quaternions.h" 28 #include <GL/gl.h> 29 #include <GL/glu.h> 30 #include "Files.h" 31 #include "Constants.h" 32 33 #define max_textured_triangle 400 // maximum number of texture-filled triangles in a model 34 #define max_model_vertex max_textured_triangle*3 // maximum number of vertexs 35 36 // 37 // Model Structures 38 // 39 40 class TexturedTriangle { 41 public: 42 short vertex[3]; 43 float r, g, b; 44 }; 45 46 class Model { 47 public: 48 short vertexNum, TriangleNum; 49 50 XYZ vertex[max_model_vertex]; 51 XYZ normals[max_textured_triangle]; 52 TexturedTriangle Triangles[max_textured_triangle]; 53 GLfloat vArray[max_textured_triangle * 27]; 54 55 XYZ boundingspherecenter; 56 float boundingsphereradius; 57 int LineCheck(XYZ p1, XYZ p2, XYZ * p); 58 int LineCheck2(XYZ p1, XYZ p2, XYZ * p, XYZ move, float rotate); 59 int LineCheck2(XYZ * p1, XYZ * p2, XYZ * p, XYZ * move, float *rotate); 60 int LineCheck3(XYZ p1, XYZ p2, XYZ * p, XYZ move, float rotate, float *d); 61 62 void UpdateVertexArray(); 63 bool load(Str255 Name); 64 void Scale(float xscale, float yscale, float zscale); 65 void ScaleNormals(float xscale, float yscale, float zscale); 66 void Translate(float xtrans, float ytrans, float ztrans); 67 void CalculateNormals(); 68 void draw(); 69 void draw(float r, float g, float b); 70 void draw(float r, float g, float b, float o); 71 void draw(float r, float g, float b, float x, float y, float z); 72 void Rotate(float xang, float yang, float zang); 73 void MultColor(float howmuch); 74 75 XYZ boundingboxmin, boundingboxmax; 76 }; 77 78 #endif 79