include/vamos/geometry/Ac3d.h

Go to the documentation of this file.
00001 //  Ac3d - 3D objects
00002 //
00003 //      Vamos Automotive Simulator
00004 //  Copyright (C) 2003 Sam Varner
00005 //
00006 //  This program is free software; you can redistribute it and/or modify
00007 //  it under the terms of the GNU General Public License as published by
00008 //  the Free Software Foundation; either version 2 of the License, or
00009 //  (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 #ifndef _AC3D_H_
00021 #define _AC3D_H_
00022 
00023 #include <vamos/geometry/Three_Vector.h>
00024 
00025 #ifdef WIN32
00026 # define WINDOWS_LEAN_AND_MEAN 1
00027 # define NOMINMAX 1               // Do not define MS' min()/max() macros.
00028 # include <windows.h>
00029 #endif
00030 
00031 #include <GL/gl.h>
00032 
00033 #include <string>
00034 #include <vector>
00035 #include <fstream>
00036 
00037 namespace Vamos_Geometry
00038 {
00039   class Gl_Texture_Image;
00040 
00041   class Ac3d_Exception
00042   {
00043         std::string m_message;
00044   public:
00045         Ac3d_Exception (std::string message) : m_message (message) {};
00046         std::string message () const { return m_message; }
00047   };
00048 
00049   class No_File : public Ac3d_Exception 
00050   {
00051   public:
00052         No_File (std::string message) : Ac3d_Exception (message) {};
00053   };
00054 
00055   class Not_An_Ac3d_File : public Ac3d_Exception
00056   {
00057   public:
00058         Not_An_Ac3d_File (std::string message) : Ac3d_Exception (message) {};
00059   };
00060 
00061   class Malformed_Ac3d_File : public Ac3d_Exception
00062   {
00063   public:
00064         Malformed_Ac3d_File (std::string message) : Ac3d_Exception (message) {};
00065   };
00066 
00067   class Ac3d_Material;
00068   class Ac3d_Surface;
00069   class Ac3d_Object;
00070 
00071   class Ac3d
00072   {
00073         std::string m_file;
00074         int m_version;
00075 
00076         std::vector <const Ac3d_Material*> m_materials;
00077         std::vector <const Ac3d_Object*> m_objects;
00078 
00079         double m_scale;
00080         Three_Vector m_translation;
00081         Three_Vector m_rotation; // angle-axis representation
00082 
00083         void read_header (std::ifstream& is);
00084         const Ac3d_Material* read_material (std::ifstream& is);
00085         const Ac3d_Object* read_object (std::ifstream& is, double scale,
00086                                                                         const Three_Vector& translation,
00087                                                                         const Three_Vector& rotation);
00088         Ac3d_Surface* read_surface (std::ifstream& is, Ac3d_Object* obj);
00089 
00090   public:
00091         Ac3d (std::string file, double scale, 
00092                   const Three_Vector& rotation,
00093                   const Three_Vector& translation);
00094         ~Ac3d ();
00095 
00096         GLuint build ();
00097   };
00098 }
00099 
00100 #endif // not _AC3D_H_

Generated on Thu Oct 19 04:05:47 2006 by  doxygen 1.4.6