1
From: Thomas Moulard <thomas.moulard@gmail.com>
2
Date: Wed, 25 Sep 2013 14:45:09 +0900
3
Subject: Fix OpenSceneGraph compilation issues
5
Fix OpenSceneGraph compilation issues
8
Author: Thomas Moulard <thomas.moulard@gmail.com>
10
src/Base/OsgNormalVisualizer.cpp | 60 +++++++++++++++++++++-------------------
11
src/Base/ScenePieces.cpp | 6 ++--
12
src/Base/ScenePieces.h | 2 +-
13
src/Base/SceneView.cpp | 8 +++---
14
src/Base/VrmlToOsgConverter.cpp | 38 ++++++++++++-------------
15
5 files changed, 58 insertions(+), 56 deletions(-)
17
diff --git a/src/Base/OsgNormalVisualizer.cpp b/src/Base/OsgNormalVisualizer.cpp
18
index 2d84167..dd42e7a 100644
19
--- a/src/Base/OsgNormalVisualizer.cpp
20
+++ b/src/Base/OsgNormalVisualizer.cpp
22
using namespace cnoid;
27
class NormalExtractor : public osg::NodeVisitor
30
NormalExtractor(float normalScale = 1.0, NormalVisualizer::Mode mode = NormalVisualizer::SURFACE);
33
void apply(osg::Geode& geode);
36
osg::Vec3Array* getNormalLines() { return normalLines.get(); }
40
NormalVisualizer::Mode mode;
42
@@ -29,14 +29,14 @@ namespace {
43
osg::Vec3Array* normals;
44
osg::Vec3Array::iterator normalIter;
45
osg::UIntArray::iterator normalIndexIter;
48
void extractOverallNormal();
49
void extractPrimitiveSetNormal(const osg::PrimitiveSet* primitiveSet);
50
void extractPrimitiveNormals(
51
- const osg::PrimitiveSet* primitiveSet, osg::Geometry::AttributeBinding binding, int numVertices);
52
+ const osg::PrimitiveSet* primitiveSet, deprecated_osg::Geometry::AttributeBinding binding, int numVertices);
53
void extractPolygonNormals(const osg::PrimitiveSet* primitiveSet);
59
NormalVisualizer::NormalVisualizer(Node *node, float scale, Mode mode)
60
@@ -44,7 +44,7 @@ NormalVisualizer::NormalVisualizer(Node *node, float scale, Mode mode)
61
NormalExtractor extractor(scale, mode);
62
node->accept(extractor);
64
- osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
65
+ osg::ref_ptr<deprecated_osg::Geometry> geom = new deprecated_osg::Geometry;
67
osg::ref_ptr<osg::Vec3Array> lines = extractor.getNormalLines();
68
geom->setVertexArray(lines.get());
69
@@ -52,7 +52,7 @@ NormalVisualizer::NormalVisualizer(Node *node, float scale, Mode mode)
71
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
72
geom->setColorArray(colors.get());
73
- geom->setColorBinding(osg::Geometry::BIND_OVERALL);
74
+ geom->setColorBinding(deprecated_osg::Geometry::BIND_OVERALL);
76
colors->push_back(osg::Vec4(1.0, 0.0, 0.0, 1.0));
77
} else if(mode == VERTEX) {
78
@@ -78,38 +78,40 @@ NormalExtractor::NormalExtractor(float normalScale, NormalVisualizer::Mode mode)
79
void NormalExtractor::apply(osg::Geode& geode)
81
for(size_t i = 0; i < geode.getNumDrawables(); i++ ){
82
- osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
83
+ deprecated_osg::Geometry* geom = dynamic_cast<deprecated_osg::Geometry*>(geode.getDrawable(i));
85
vertices = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
86
if(!vertices) continue;
87
normals = dynamic_cast<osg::Vec3Array*>(geom->getNormalArray());
88
if(!normals) continue;
89
- osg::Geometry::AttributeBinding binding = geom->getNormalBinding();
90
- if(binding == osg::Geometry::BIND_OFF) continue;
91
+ deprecated_osg::Geometry::AttributeBinding binding = geom->getNormalBinding();
92
+ if(binding == deprecated_osg::Geometry::BIND_OFF) continue;
94
- if(binding == osg::Geometry::BIND_OVERALL){
95
+ if(binding == deprecated_osg::Geometry::BIND_OVERALL){
96
extractOverallNormal();
99
- osg::Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList();
101
+ deprecated_osg::Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList();
103
vertexIter = vertices->begin();
104
normalIter = normals->begin();
106
- osg::IntArray* vertexIndices = dynamic_cast<osg::IntArray*>(geom->getVertexIndices());
107
+ osg::IntArray* vertexIndices = const_cast<osg::IntArray*>
108
+ (dynamic_cast<const osg::IntArray*>(geom->getVertexIndices()));
110
vertexIndexIter = vertexIndices->begin();
112
- osg::UIntArray* normalIndices = dynamic_cast<osg::UIntArray*>(geom->getNormalIndices());
113
+ osg::UIntArray* normalIndices = const_cast<osg::UIntArray*>
114
+ (dynamic_cast<const osg::UIntArray*>(geom->getNormalIndices()));
116
normalIndexIter = normalIndices->begin();
119
- osg::Geometry::PrimitiveSetList::iterator it;
121
+ deprecated_osg::Geometry::PrimitiveSetList::iterator it;
122
for(it = primitiveSets.begin(); it != primitiveSets.end(); ++it){
123
osg::PrimitiveSet* primitiveSet = it->get();
125
- if(binding == osg::Geometry::BIND_PER_PRIMITIVE_SET){
126
+ if(binding == deprecated_osg::Geometry::BIND_PER_PRIMITIVE_SET){
127
extractPrimitiveSetNormal(primitiveSet);
129
switch(primitiveSet->getMode()){
130
@@ -165,30 +167,30 @@ void NormalExtractor::extractPrimitiveSetNormal(const osg::PrimitiveSet* primiti
133
void NormalExtractor::extractPrimitiveNormals
134
-(const osg::PrimitiveSet* primitiveSet, osg::Geometry::AttributeBinding binding, int numVertices)
135
+(const osg::PrimitiveSet* primitiveSet, deprecated_osg::Geometry::AttributeBinding binding, int numVertices)
137
for(size_t i=0; i < primitiveSet->getNumPrimitives(); ++i){
139
- if(mode == NormalVisualizer::SURFACE || binding == osg::Geometry::BIND_PER_PRIMITIVE){
141
+ if(mode == NormalVisualizer::SURFACE || binding == deprecated_osg::Geometry::BIND_PER_PRIMITIVE){
142
osg::Vec3 n(0.0, 0.0, 0.0);
143
- if(binding == osg::Geometry::BIND_PER_PRIMITIVE){
144
+ if(binding == deprecated_osg::Geometry::BIND_PER_PRIMITIVE){
146
- } else if(binding == osg::Geometry::BIND_PER_VERTEX){
147
+ } else if(binding == deprecated_osg::Geometry::BIND_PER_VERTEX){
148
for(int j = 0; j < numVertices; ++j){
149
n += *(normalIter++);
156
osg::Vec3 v(0.0, 0.0, 0.0);
157
for(int j = 0; j < numVertices; ++j){
158
v += *(vertexIter++);
163
normalLines->push_back(v);
164
normalLines->push_back(v + n * scale);
167
} else if(mode == NormalVisualizer::VERTEX){
168
for(int j = 0; j < numVertices; ++j){
169
osg::Vec3& v = *(vertexIter++);
170
diff --git a/src/Base/ScenePieces.cpp b/src/Base/ScenePieces.cpp
171
index 85e44d1..72fc803 100644
172
--- a/src/Base/ScenePieces.cpp
173
+++ b/src/Base/ScenePieces.cpp
174
@@ -15,9 +15,9 @@ using namespace cnoid;
178
- osg::Geometry* createCrossGeometry(const osg::Vec4& color, float size, float lineWidth)
179
+ deprecated_osg::Geometry* createCrossGeometry(const osg::Vec4& color, float size, float lineWidth)
181
- osg::Geometry* geom = new osg::Geometry;
182
+ deprecated_osg::Geometry* geom = new deprecated_osg::Geometry;
183
osg::StateSet* state = geom->getOrCreateStateSet();
185
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
186
@@ -204,7 +204,7 @@ AttitudeDragger::AttitudeDragger()
187
const int y = axes[i][1];
188
const int z = axes[i][2];
190
- osg::Geometry* geometry = new osg::Geometry();
191
+ deprecated_osg::Geometry* geometry = new deprecated_osg::Geometry();
192
osg::Vec3Array* vertices = new osg::Vec3Array();
193
osg::DrawElementsUShort* face = new osg::DrawElementsUShort(osg::PrimitiveSet::QUADS, 0);
195
diff --git a/src/Base/ScenePieces.h b/src/Base/ScenePieces.h
196
index 4a7c38c..bfc4c07 100644
197
--- a/src/Base/ScenePieces.h
198
+++ b/src/Base/ScenePieces.h
199
@@ -39,7 +39,7 @@ namespace cnoid {
200
void setCross(const osg::Vec4& color, float size, float lineWidth = 1.0f);
202
osg::ref_ptr<osg::Sphere> sphere;
203
- osg::ref_ptr<osg::Geometry> cross;
204
+ osg::ref_ptr<deprecated_osg::Geometry> cross;
207
class CNOID_EXPORT BBMarker : public osg::Geode
208
diff --git a/src/Base/SceneView.cpp b/src/Base/SceneView.cpp
209
index 07befae..0a44154 100644
210
--- a/src/Base/SceneView.cpp
211
+++ b/src/Base/SceneView.cpp
212
@@ -664,7 +664,7 @@ void SceneViewImpl::setupHUD()
213
bb.expandBy(geode->getDrawable(i)->getBound());
216
- osg::Geometry* geom = new osg::Geometry;
217
+ deprecated_osg::Geometry* geom = new deprecated_osg::Geometry;
219
osg::Vec3Array* vertices = new osg::Vec3Array;
220
float depth = bb.zMin()-0.1;
221
@@ -677,12 +677,12 @@ void SceneViewImpl::setupHUD()
222
osg::Vec3Array* normals = new osg::Vec3Array;
223
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
224
geom->setNormalArray(normals);
225
- geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
226
+ geom->setNormalBinding(deprecated_osg::Geometry::BIND_OVERALL);
228
osg::Vec4Array* colors = new osg::Vec4Array;
229
colors->push_back(osg::Vec4(1.0f,1.0,0.8f,0.2f));
230
geom->setColorArray(colors);
231
- geom->setColorBinding(osg::Geometry::BIND_OVERALL);
232
+ geom->setColorBinding(deprecated_osg::Geometry::BIND_OVERALL);
234
geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
236
@@ -892,7 +892,7 @@ void SceneViewImpl::updateFloorGridLines()
237
floorGridNode->removeDrawables(0, prevNumDrawables);
240
- osg::Geometry* geom = new osg::Geometry;
241
+ deprecated_osg::Geometry* geom = new deprecated_osg::Geometry;
242
osg::Vec3Array* v = new osg::Vec3Array;
243
geom->setVertexArray(v);
245
diff --git a/src/Base/VrmlToOsgConverter.cpp b/src/Base/VrmlToOsgConverter.cpp
246
index 8093c1f..461f4be 100644
247
--- a/src/Base/VrmlToOsgConverter.cpp
248
+++ b/src/Base/VrmlToOsgConverter.cpp
249
@@ -42,7 +42,7 @@ namespace cnoid {
250
osg::Group* createTransformNode(VrmlTransform* vt);
251
osg::Node* convertShapeNode(VrmlNode* vnode);
252
osg::Material* createMaterial(VrmlMaterial* vm);
253
- osg::Geometry* createGeometryFromIndexedFaceSet(VrmlIndexedFaceSet* vface, float alpha);
254
+ deprecated_osg::Geometry* createGeometryFromIndexedFaceSet(VrmlIndexedFaceSet* vface, float alpha);
256
VrmlMaterialPtr defaultMaterial;
257
osg::ref_ptr<osg::StateSet> stateSetForTransformWithScaling;
258
@@ -54,7 +54,7 @@ namespace cnoid {
259
typedef map<VrmlNode*, osg::Node*> VrmlNodeToOsgNodeMap;
260
VrmlNodeToOsgNodeMap vrmlNodeToOsgNodeMap;
262
- typedef map<VrmlGeometry*, osg::Geometry*> VrmlGeometryToOsgGeometryMap;
263
+ typedef map<VrmlGeometry*, deprecated_osg::Geometry*> VrmlGeometryToOsgGeometryMap;
264
VrmlGeometryToOsgGeometryMap vrmlGeometryToOsgGeometryMap;
266
osgUtil::Optimizer optimizer;
267
@@ -223,7 +223,7 @@ osg::Node* VrmlToOsgConverterImpl::convertShapeNode(VrmlNode* vnode)
268
float alpha = 1.0 - vm->transparency;
270
osg::Geode* geode = 0;
271
- osg::Geometry* geometry = 0;
272
+ deprecated_osg::Geometry* geometry = 0;
273
VrmlGeometry* vrmlGeometry = dynamic_node_cast<VrmlGeometry>(vrmlShape->geometry).get();
276
@@ -307,9 +307,9 @@ osg::Material* VrmlToOsgConverterImpl::createMaterial(VrmlMaterial* vm)
280
-osg::Geometry* VrmlToOsgConverterImpl::createGeometryFromIndexedFaceSet(VrmlIndexedFaceSet* vface, float alpha)
281
+deprecated_osg::Geometry* VrmlToOsgConverterImpl::createGeometryFromIndexedFaceSet(VrmlIndexedFaceSet* vface, float alpha)
283
- osg::Geometry* geometry = new osg::Geometry;
284
+ deprecated_osg::Geometry* geometry = new deprecated_osg::Geometry;
287
osg::StateSet* stateSet = geometry->getOrCreateStateSet();
288
@@ -382,9 +382,9 @@ osg::Geometry* VrmlToOsgConverterImpl::createGeometryFromIndexedFaceSet(VrmlInde
289
normals->push_back(osg::Vec3(vec[i][0], vec[i][1], vec[i][2]));
291
geometry->setNormalArray(normals);
294
if(vface->normalIndex.empty()){
295
- geometry->setNormalIndices(geometry->getVertexIndices());
296
+ geometry->setNormalIndices((osg::IndexArray*)geometry->getVertexIndices());
298
int size = vface->normalIndex.size();
299
osg::UIntArray* indices = new osg::UIntArray;
300
@@ -397,12 +397,12 @@ osg::Geometry* VrmlToOsgConverterImpl::createGeometryFromIndexedFaceSet(VrmlInde
301
geometry->setNormalIndices(indices);
303
if(vface->normalPerVertex == true){
304
- geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
305
+ geometry->setNormalBinding(deprecated_osg::Geometry::BIND_PER_VERTEX);
307
- geometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
308
+ geometry->setNormalBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
314
MFColor& c = vface->color->color;
316
@@ -412,16 +412,16 @@ osg::Geometry* VrmlToOsgConverterImpl::createGeometryFromIndexedFaceSet(VrmlInde
317
colors->push_back(osg::Vec4(c[i][0], c[i][1], c[i][2], alpha));
319
geometry->setColorArray(colors);
322
if(vface->colorIndex.empty()){
323
- geometry->setColorIndices(geometry->getVertexIndices());
324
+ geometry->setColorIndices((osg::IndexArray*)geometry->getVertexIndices());
326
int size = vface->colorIndex.size();
327
osg::UIntArray* indices = new osg::UIntArray;
330
// osg::TemplateIndexArray <unsigned int, osg::Array::UIntArrayType,4,4> *indices;
331
// indices = new osg::TemplateIndexArray<unsigned int, osg::Array::UIntArrayType,4,4>;
334
for(int i=0; i < size; i++){
335
int index = vface->colorIndex[i];
337
@@ -430,18 +430,18 @@ osg::Geometry* VrmlToOsgConverterImpl::createGeometryFromIndexedFaceSet(VrmlInde
339
geometry->setColorIndices(indices);
343
if(vface->colorPerVertex == true){
344
- geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
345
+ geometry->setColorBinding(deprecated_osg::Geometry::BIND_PER_VERTEX);
347
- geometry->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
348
+ geometry->setColorBinding(deprecated_osg::Geometry::BIND_PER_PRIMITIVE);
355
osgUtil::SmoothingVisitor::smooth(*geometry);