/
OSGColladaGeometry.h
224 lines (176 loc) · 9.92 KB
/
OSGColladaGeometry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*---------------------------------------------------------------------------*\
* OpenSG *
* *
* *
* Copyright (C) 2009 by the OpenSG Forum *
* *
* www.opensg.org *
* *
* contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* License *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Library General Public License as published *
* by the Free Software Foundation, version 2. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
* Changes *
* *
* *
* *
* *
* *
* *
\*---------------------------------------------------------------------------*/
#ifndef _OSGCOLLADAGEOMETRY_H_
#define _OSGCOLLADAGEOMETRY_H_
#include "OSGConfig.h"
#ifdef OSG_WITH_COLLADA
#include "OSGColladaInstantiableElement.h"
#include "OSGColladaElementFactoryHelper.h"
#include "OSGColladaInstanceMaterial.h"
#include "OSGNode.h"
#include "OSGGeometry.h"
#include "OSGGeoVectorProperty.h"
#include "OSGGeoIntegralProperty.h"
#include <dae/daeDomTypes.h>
#include <dom/domInputLocal.h>
#include <dom/domInputLocalOffset.h>
// forward decls
class domMesh;
class domLines;
class domLinestrips;
class domPolygons;
class domPolylist;
class domTriangles;
class domTrifans;
class domTristrips;
OSG_BEGIN_NAMESPACE
// forward decls
class ColladaSource;
OSG_GEN_MEMOBJPTR(ColladaSource);
class ColladaInstanceGeometry;
OSG_GEN_MEMOBJPTR(ColladaInstanceGeometry);
class OSG_FILEIO_DLLMAPPING ColladaGeometry : public ColladaInstantiableElement
{
/*========================== PUBLIC =================================*/
public:
/*---------------------------------------------------------------------*/
/*! \name Types */
/*! \{ */
typedef ColladaInstantiableElement Inherited;
typedef ColladaGeometry Self;
OSG_GEN_INTERNAL_MEMOBJPTR(ColladaGeometry);
typedef ColladaInstanceMaterial::BindInfo BindInfo;
typedef ColladaInstanceMaterial::BindStore BindStore;
typedef ColladaInstanceMaterial::BindVertexInfo BindVertexInfo;
typedef ColladaInstanceMaterial::BindVertexStore BindVertexStore;
/*! \} */
/*---------------------------------------------------------------------*/
/*! \name Create */
/*! \{ */
static ColladaElementTransitPtr
create(daeElement *elem, ColladaGlobal *global);
/*! \} */
/*---------------------------------------------------------------------*/
/*! \name Reading */
/*! \{ */
virtual void read (void );
virtual Node *createInstance(ColladaInstanceElement *instElem);
/*! \} */
/*========================= PROTECTED ===============================*/
protected:
/*---------------------------------------------------------------------*/
/*! \name Constructors/Destructor */
/*! \{ */
ColladaGeometry(daeElement *elem, ColladaGlobal *global);
virtual ~ColladaGeometry(void );
/*! \} */
/*---------------------------------------------------------------------*/
// <source> map
typedef std::map<std::string, ColladaSourceRefPtr> SourceMap;
typedef SourceMap::iterator SourceMapIt;
typedef SourceMap::const_iterator SourceMapConstIt;
struct PropInfo
{
std::string _semantic;
Int32 _set;
GeoVectorPropertyUnrecPtr _prop;
};
typedef std::vector<PropInfo > PropStore;
typedef PropStore::iterator PropStoreIt;
typedef PropStore::const_iterator PropStoreConstIt;
typedef std::vector<GeoIntegralPropertyUnrecPtr> IndexStore;
typedef IndexStore::iterator IndexStoreIt;
typedef IndexStore::const_iterator IndexStoreConstIt;
// map <instance_material> target attribute to an index into
// the instance store (getInstStore())
typedef std::map<std::string, UInt32> InstanceMap;
typedef InstanceMap::iterator InstanceMapIt;
typedef InstanceMap::const_iterator InstanceMapConstIt;
struct GeoInfo
{
std::string _matSymbol;
PropStore _propStore;
IndexStore _indexStore;
GeoIntegralPropertyUnrecPtr _lengths;
GeoIntegralPropertyUnrecPtr _types;
InstanceMap _instMap;
};
typedef std::vector<GeoInfo > GeoStore;
typedef GeoStore::iterator GeoStoreIt;
typedef GeoStore::const_iterator GeoStoreConstIt;
void readMesh (domMesh *mesh);
void readSources (domMesh *mesh);
void readLines (domMesh *mesh, domLines *lines );
void readLineStrips(domMesh *mesh, domLinestrips *lineStrips);
void readPolygons (domMesh *mesh, domPolygons *polygons );
void readPolyList (domMesh *mesh, domPolylist *polyList );
void readTriangles (domMesh *mesh, domTriangles *triangles );
void readTriFans (domMesh *mesh, domTrifans *triFans );
void readTriStrips (domMesh *mesh, domTristrips *triStrips );
UInt32 mapSemantic (const std::string &semantic,
UInt32 set,
UInt32 geoIdx );
void setupProperty(UInt32 geoIdx,
UInt32 propIdx,
const std::string &semantic,
UInt32 set,
const std::string &sourceId,
GeoIntegralProperty *idxProp );
UInt32 setupGeometry(const domInputLocal_Array &vertInputs,
const domInputLocalOffset_Array &inputs,
xsNCName matSymbold,
IndexStore &indexStore );
void handleBindMaterial(const GeoInfo &geoInfo,
Geometry *geo,
ColladaInstanceGeometry *colInstGeo);
const BindInfo *findBind (const BindStore &store,
const std::string &semantic,
UInt32 &offset );
const BindVertexInfo *findBindVertex(const BindVertexStore &store,
const std::string &inSemantic,
UInt32 inSet,
UInt32 &offset );
static ColladaElementRegistrationHelper _regHelper;
SourceMap _sourceMap;
GeoStore _geoStore;
};
OSG_GEN_MEMOBJPTR(ColladaGeometry);
OSG_END_NAMESPACE
// #include "OSGColladaGeometry.inl"
#endif // OSG_WITH_COLLADA
#endif // _OSGCOLLADAGEOMETRY_H_