| 1 | /*************************************************************************** |
| 2 | modelloader.h - description |
| 3 | ------------------- |
| 4 | begin : may 22th, 2004 |
| 5 | copyright : (C) 2004-2006 by Duong Khang NGUYEN |
| 6 | email : neoneurone @ gmail com |
| 7 | |
| 8 | $Id: modelloader.h 375 2008-10-28 14:47:15Z neoneurone $ |
| 9 | ***************************************************************************/ |
| 10 | |
| 11 | /*************************************************************************** |
| 12 | * * |
| 13 | * This program is free software; you can redistribute it and/or modify * |
| 14 | * it under the terms of the GNU General Public License as published by * |
| 15 | * the Free Software Foundation; either version 2 of the License, or * |
| 16 | * any later version. * |
| 17 | * * |
| 18 | ***************************************************************************/ |
| 19 | |
| 20 | #ifndef _OPENCITY_MODELLOADER_H_ |
| 21 | #define _OPENCITY_MODELLOADER_H_ 1 |
| 22 | |
| 23 | #include "main.h" |
| 24 | |
| 25 | #include "ac3dobject.h" // Vertex struct |
| 26 | #include "ac3dmaterial.h" |
| 27 | |
| 28 | #include <vector> |
| 29 | |
| 30 | using std::vector; |
| 31 | |
| 32 | using AC3D::Vertex; |
| 33 | |
| 34 | class Model; |
| 35 | |
| 36 | |
| 37 | //======================================================================== |
| 38 | /** The purpose of this class is simple: read the given file, then return |
| 39 | an object of type Model. |
| 40 | */ |
| 41 | class ModelLoader { |
| 42 | public: |
| 43 | |
| 44 | |
| 45 | //======================================================================== |
| 46 | /** Detect the file type according to its extension. Currently, |
| 47 | it checks for ".ocm" and ".ac" |
| 48 | */ |
| 49 | static Model* const |
| 50 | Load( |
| 51 | const string & rcsFileName ); |
| 52 | |
| 53 | |
| 54 | //======================================================================== |
| 55 | /** OCM file loader |
| 56 | */ |
| 57 | static Model* const |
| 58 | LoadOCM( |
| 59 | const string & rcsFileName ); |
| 60 | |
| 61 | |
| 62 | //======================================================================== |
| 63 | /** AC3D file loader |
| 64 | */ |
| 65 | static Model* const |
| 66 | LoadAC3D( |
| 67 | const string & rcsFileName ); |
| 68 | |
| 69 | |
| 70 | //======================================================================== |
| 71 | /** Calculate the result vector of OA ^ OB |
| 72 | */ |
| 73 | static Vertex |
| 74 | GetNormal( |
| 75 | Vertex & vO, |
| 76 | Vertex & vA, |
| 77 | Vertex & vB ); |
| 78 | |
| 79 | |
| 80 | private: |
| 81 | static void |
| 82 | _AC3DTextureToGL( |
| 83 | const AC3D::AC3DObject* const pObject, |
| 84 | string& strTextureFile |
| 85 | ); |
| 86 | |
| 87 | |
| 88 | static void |
| 89 | _AC3DVertexToGL( |
| 90 | const string& strPath, |
| 91 | const vector<AC3D::AC3DMaterial>& vMaterial, |
| 92 | const AC3D::AC3DObject* const pObject, |
| 93 | const bool bProcessTranslucent = false, |
| 94 | const bool bProcessTwoSide = false |
| 95 | ); |
| 96 | }; |
| 97 | #endif |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 |