| 1 | /*************************************************************************** |
| 2 | AC3DSurface.h - description |
| 3 | ------------------- |
| 4 | begin : june 29th, 05 |
| 5 | copyright : (C) 2005-2006 by Duong Khang NGUYEN |
| 6 | email : neoneurone @ gmail com |
| 7 | |
| 8 | $Id: ac3dsurface.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_AC3DAC3DSURFACE_H_ |
| 21 | #define _OPENCITY_AC3DAC3DSURFACE_H_ 1 |
| 22 | |
| 23 | #include <vector> |
| 24 | #include <string> |
| 25 | #include <sstream> |
| 26 | |
| 27 | #ifndef uint |
| 28 | typedef unsigned int uint; |
| 29 | #endif |
| 30 | |
| 31 | namespace AC3D { |
| 32 | |
| 33 | using std::vector; |
| 34 | using std::string; |
| 35 | using std::stringstream; |
| 36 | |
| 37 | /** The type of the AC3D surface. OpenCity only handles the polygon type |
| 38 | at the moment |
| 39 | */ |
| 40 | enum SURFACE_TYPE { |
| 41 | SURFACE_POLYGON, ///< Polygon surface type |
| 42 | SURFACE_CLOSEDLINE, ///< Closed line surface type |
| 43 | SURFACE_LINE ///< Line type |
| 44 | }; |
| 45 | |
| 46 | /** A reference to a vertex |
| 47 | */ |
| 48 | struct Ref { |
| 49 | unsigned int uiVertIndex; ///< The index of the referenced vertex |
| 50 | float fTexS; ///< The vertex 2D S texture coordinate |
| 51 | float fTexT; ///< The vertex 2D T texture coordinate |
| 52 | }; |
| 53 | |
| 54 | |
| 55 | //======================================================================== |
| 56 | /** A surface is composed of vertices |
| 57 | \author Duong Khang NGUYEN |
| 58 | */ |
| 59 | class AC3DSurface{ |
| 60 | public: |
| 61 | AC3DSurface(); |
| 62 | AC3DSurface( stringstream& data ); |
| 63 | |
| 64 | ~AC3DSurface(); |
| 65 | |
| 66 | |
| 67 | //======================================================================== |
| 68 | /** Tell whether the surface is twosided |
| 69 | \return True if the surface is twosided |
| 70 | */ |
| 71 | bool IsTwoSide() const; |
| 72 | |
| 73 | //======================================================================== |
| 74 | /** |
| 75 | \return The index of the used material |
| 76 | */ |
| 77 | const unsigned int |
| 78 | GetMat() const; |
| 79 | |
| 80 | //======================================================================== |
| 81 | /** |
| 82 | \return The constant reference to the vector which contains all |
| 83 | the references of the surface |
| 84 | */ |
| 85 | const vector<Ref>& |
| 86 | GetVRef() const; |
| 87 | |
| 88 | |
| 89 | void Parse( stringstream& data ); |
| 90 | |
| 91 | string ToStr() const; |
| 92 | |
| 93 | |
| 94 | private: |
| 95 | uint uiAttribute; |
| 96 | SURFACE_TYPE type; |
| 97 | bool bShaded; |
| 98 | bool bTwoSide; |
| 99 | uint uiMat; ///< Index of the material used |
| 100 | uint uiNumRef; ///< Number of references |
| 101 | vector<Ref> vRef; ///< Table of references |
| 102 | }; |
| 103 | |
| 104 | } |
| 105 | |
| 106 | #endif |
| 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 |