00001 /* 00002 00003 ************************************************************************* 00004 00005 ArmageTron -- Just another Tron Lightcycle Game in 3D. 00006 Copyright (C) 2000 Manuel Moos (manuel@moosnet.de) 00007 00008 ************************************************************************** 00009 00010 This program is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 00024 *************************************************************************** 00025 00026 */ 00027 00028 #ifndef ArmageTron_MODEL_H 00029 #define ArmageTron_MODEL_H 00030 00031 #include "defs.h" 00032 #include "tArray.h" 00033 #include "tLinkedList.h" 00034 #include <math.h> 00035 #include "rGL.h" 00036 #include "rDisplayList.h" 00037 00038 class Vec3{ 00039 public: 00040 float x[3]; 00041 Vec3(REAL a=0,REAL b=0,REAL c=0){x[0]=a;x[1]=b;x[2]=c;} 00042 ~Vec3(){}; 00043 00044 REAL Norm(){return REAL(sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]));} 00045 00046 Vec3 operator*(REAL y){return Vec3(x[0]*y,x[1]*y,x[2]*y);} 00047 void operator+=(const Vec3 &y){x[0]+=y.x[0];x[1]+=y.x[1];x[2]+=y.x[2];} 00048 00049 void RenderVertex(); 00050 void RenderNormal(); 00051 }; 00052 00053 class rModelFace{ 00054 public: 00055 int A[3]; 00056 rModelFace(int a=0,int b=0,int c=0){A[0]=a;A[1]=b;A[2]=c;} 00057 ~rModelFace(){}; 00058 }; 00059 00060 class rModel 00061 { 00062 rDisplayList displayList_; 00063 00064 tArray<Vec3> vertices; 00065 tArray<Vec3> texVert; 00066 tArray<Vec3> normals; 00067 tArray<rModelFace> modelFaces; 00068 tArray<rModelFace> modelTexFaces; 00069 bool modelTexFacesCoherent; // if modelFaces and modelTexFaces are identical 00070 void Load(std::istream &s,const char *fileName); 00071 public: 00072 rModel(const char *fileName,const char *fileName_alt=""); 00073 ~rModel(); 00074 00075 void Render(); 00076 }; 00077 00078 #endif 00079 00080 00081