Debian Codegraph @

src/model/ac3dobject.h

raw symbols SCIP
1 /***************************************************************************
2 AC3DObject.h - description
3 -------------------
4 begin : june 29th, 05
5 copyright : (C) 2005-2007 by Duong Khang NGUYEN
6 email : neoneurone @ gmail com
7
8 $Id: ac3dobject.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_AC3DOBJECT_H_
21 #define _OPENCITY_AC3DOBJECT_H_ 1
22
23 #include "ac3dsurface.h"
24
25 #include <vector>
26 #include <string>
27 #include <sstream>
28
29 namespace AC3D {
30
31 using std::vector;
32 using std::string;
33 using std::stringstream;
34
35 /** The different AC3D object type
36 */
37 enum OBJECT_TYPE {
38 OBJECT_WORLD, ///< World object
39 OBJECT_POLYGON, ///< Polygon object
40 OBJECT_GROUP ///< Group object
41 };
42
43 /** A vertex structure which is composed of 3 space coordinates
44 */
45 struct Vertex {
46 float x, y, z;
47 };
48
49
50 //========================================================================
51 /**
52 \author Duong Khang NGUYEN
53 */
54 class AC3DObject{
55 public:
56 AC3DObject();
57 AC3DObject( stringstream& data );
58
59 ~AC3DObject();
60
61
62 //========================================================================
63 /** Add a new kid to this object. It automatically set the translucent
64 attribute of the children to true if the parent is a translucent group.
65 */
66 void
67 AddKid( AC3DObject* kid );
68
69
70 //========================================================================
71 /** Decode the "name" attribute to determine whether the object is
72 translucent or not. This is specific to OpenCity
73 \return True if the object is translucent
74 */
75 bool
76 IsTranslucent() const;
77
78
79 //========================================================================
80 /** Set the translucent attribute of the object to true regarless its
81 encoded value in the "name" attribute.
82 */
83 void
84 SetTranslucent(bool bValue);
85
86
87 //========================================================================
88 /**
89 \return The content of the name command
90 */
91 string
92 GetName() const;
93
94
95 //========================================================================
96 /**
97 \return The number of kids which may differ from the size of the vector
98 returned by GetVPObject() during loading process.
99 */
100 unsigned int
101 GetNumberKid() const;
102
103
104 //========================================================================
105 /**
106 \return The file name of the texture
107 */
108 const string&
109 GetTextureFile() const;
110
111
112 //========================================================================
113 /**
114 \return The "location" translation vector
115 */
116 const float*
117 GetLoc() const;
118
119
120 //========================================================================
121 /**
122 \return The constant reference to the vector which contains all
123 the vertex of the object
124 */
125 const vector<Vertex>&
126 GetVVertex() const;
127
128
129 //========================================================================
130 /**
131 \return The constant reference to the vector which contains all
132 the pointers to the surface of the object
133 */
134 const vector<AC3DSurface*>&
135 GetVPSurface() const;
136
137
138 //========================================================================
139 /**
140 \return The constant reference to the vector which contains all
141 the child objects
142 */
143 const vector<AC3DObject*>&
144 GetVPObject() const;
145
146
147 //========================================================================
148 /** Parse and extract the data from the given stream
149 */
150 void Parse( stringstream& data );
151
152
153 string ToStr() const;
154
155 private:
156 OBJECT_TYPE type; ///< Object's type
157 string strName; ///< Content of the "name" command
158 string _sData; ///< The optional data is stocked as std::string
159 string strTexture; ///< Texture file name
160 float fTexRep[2]; ///< Default (1, 1). The texture repeat values for the tiling of a texture on an object's surfaces.
161 float fRot[9]; ///< Rotation matrix
162 float fLoc[3]; ///< Translation vector
163 float fCrease; ///< Angle in degrees for calculating normals for smoothing
164 string strURL; ///< The URL of the file
165
166 bool _bTranslucent; ///< True if the object is translucent, false otherwise
167
168 uint uiNumVert; ///< Number of vertices in this object
169 vector<Vertex> vVertex; ///< Table of vertices
170
171 uint uiNumSurf; ///< Number of surfaces of this object
172 vector<AC3DSurface*> vpSurface; ///< Table of surfaces
173
174 uint uiKids; ///< Number of kids
175 vector<AC3DObject*> vpObject; ///< Table of child objects
176
177
178 //========================================================================
179 // Private methods
180 //========================================================================
181 void ac3dSetDefault();
182
183 void
184 ac3dobjectParseVertex(
185 unsigned int nb,
186 stringstream& data,
187 char* buffer );
188
189 void
190 ac3dobjectParseSurface(
191 unsigned int nb,
192 stringstream& data,
193 char* buffer );
194 };
195
196 }
197
198 #endif
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221