1 // Ac3d - 3D objects 2 // 3 // Vamos Automotive Simulator 4 // Copyright (C) 2003 Sam Varner 5 // 6 // This program is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 2 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 20 #ifndef _AC3D_H_ 21 #define _AC3D_H_ 22 23 #include "../geometry/Three_Vector.h" 24 25 #ifdef WIN32 26 # define WINDOWS_LEAN_AND_MEAN 1 27 # define NOMINMAX 1 // Do not define MS' min()/max() macros. 28 # include <windows.h> 29 #endif 30 31 #include <GL/gl.h> 32 33 #include <string> 34 #include <vector> 35 36 namespace Vamos_Media 37 { 38 class Ac3d_Exception 39 { 40 std::string m_message; 41 public: Ac3d_Exception(std::string message)42 Ac3d_Exception (std::string message) : m_message (message) {}; message()43 std::string message () const { return m_message; } 44 }; 45 46 class No_File : public Ac3d_Exception 47 { 48 public: No_File(std::string message)49 No_File (std::string message) : Ac3d_Exception (message) {}; 50 }; 51 52 class Not_An_Ac3d_File : public Ac3d_Exception 53 { 54 public: Not_An_Ac3d_File(std::string message)55 Not_An_Ac3d_File (std::string message) : Ac3d_Exception (message) {}; 56 }; 57 58 class Malformed_Ac3d_File : public Ac3d_Exception 59 { 60 public: Malformed_Ac3d_File(std::string message)61 Malformed_Ac3d_File (std::string message) : Ac3d_Exception (message) {}; 62 }; 63 64 class Ac3d_Material; 65 class Ac3d_Surface; 66 class Ac3d_Object; 67 68 class Ac3d 69 { 70 std::string m_file; 71 int m_version; 72 73 std::vector <const Ac3d_Material*> m_materials; 74 std::vector <const Ac3d_Object*> m_objects; 75 76 double m_scale; 77 Vamos_Geometry::Three_Vector m_translation; 78 Vamos_Geometry::Three_Vector m_rotation; // angle-axis representation 79 80 void read_header (std::ifstream& is); 81 const Ac3d_Material* read_material (std::ifstream& is); 82 const Ac3d_Object* read_object (std::ifstream& is, 83 double scale, 84 const Vamos_Geometry::Three_Vector& 85 translation, 86 const Vamos_Geometry::Three_Vector& 87 rotation); 88 Ac3d_Surface* read_surface (std::ifstream& is, Ac3d_Object* obj); 89 90 public: 91 Ac3d (std::string file, double scale, 92 const Vamos_Geometry::Three_Vector& rotation, 93 const Vamos_Geometry::Three_Vector& translation); 94 ~Ac3d (); 95 96 GLuint build (); 97 }; 98 } 99 100 #endif // not _AC3D_H_ 101