Package: openscenegraph-3.4 / 3.4.1+dfsg1-5

collada.patch Patch series | download
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/CMakeLists.txt b/src/osgPlugins/dae/CMakeLists.txt
index a82481994..af03fb866 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/CMakeLists.txt
+++ b/src/osgPlugins/dae/CMakeLists.txt
@@ -1,5 +1,19 @@
 INCLUDE_DIRECTORIES( ${COLLADA_INCLUDE_DIR} ${COLLADA_INCLUDE_DIR}/1.4)
 
+
+################################################################################
+## Quieten warnings that a due to dae headers
+
+IF(CMAKE_COMPILER_IS_GNUCXX)
+    # Remove -Wextra flag as it barfs on ffmoeg headers
+   STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
+ENDIF()
+
+
 SET(TARGET_SRC
     daeReader.cpp
     daeRAnimations.cpp
@@ -76,5 +90,10 @@ ENDIF()
 
 SET(TARGET_ADDED_LIBRARIES osgSim osgAnimation)
 
+IF(CMAKE_COMPILER_IS_GNUCXX)
+    # Remove -Wshadow flag as it barfs on ffmoeg headers
+   STRING(REGEX REPLACE "-Wshadow" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ENDIF()
+
 #### end var setup  ###
 SETUP_PLUGIN(dae dae)
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.cpp b/src/osgPlugins/dae/ReaderWriterDAE.cpp
index 87cd9db9d..de86b92b3 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.cpp
+++ b/src/osgPlugins/dae/ReaderWriterDAE.cpp
@@ -32,6 +32,12 @@
 
 #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
 
+#if  __cplusplus > 199711L
+    #define smart_ptr std::unique_ptr
+#else
+    #define smart_ptr std::auto_ptr
+#endif
+
 osgDB::ReaderWriter::ReadResult
 ReaderWriterDAE::readNode(std::istream& fin,
         const osgDB::ReaderWriter::Options* options) const
@@ -65,10 +71,14 @@ ReaderWriterDAE::readNode(std::istream& fin,
     if (NULL == pDAE)
     {
         bOwnDAE = true;
+#ifdef COLLADA_DOM_2_4_OR_LATER
+        pDAE = new DAE(NULL,NULL,_specversion);
+#else
         pDAE = new DAE;
+#endif
     }
 
-    std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL);        // Deallocates locally created structure at scope exit
+    smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL);        // Deallocates locally created structure at scope exit
 
     osgDAE::daeReader daeReader(pDAE, &pluginOptions);
 
@@ -139,9 +149,14 @@ ReaderWriterDAE::readNode(const std::string& fname,
     if (NULL == pDAE)
     {
         bOwnDAE = true;
+#ifdef COLLADA_DOM_2_4_OR_LATER
+        pDAE = new DAE(NULL,NULL,_specversion);
+#else
         pDAE = new DAE;
+#endif
     }
-    std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL);        // Deallocates locally created structure at scope exit
+
+    smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL);        // Deallocates locally created structure at scope exit
 
     osgDAE::daeReader daeReader(pDAE, &pluginOptions);
 
@@ -221,6 +236,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
             else if (opt == "daeLinkOriginalTexturesNoForce") { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = false; }
             else if (opt == "daeLinkOriginalTexturesForce")   { pluginOptions.linkOrignialTextures = true; pluginOptions.forceTexture = true; }
             else if (opt == "daeNamesUseCodepage") pluginOptions.namesUseCodepage = true;
+            else if (opt == "daeRenameIds") pluginOptions.renameIds = true;
             else if (!opt.empty())
             {
                 OSG_NOTICE << std::endl << "COLLADA dae plugin: unrecognized option \"" << opt <<  std::endl;
@@ -231,9 +247,13 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
     if (NULL == pDAE)
     {
         bOwnDAE = true;
+#ifdef COLLADA_DOM_2_4_OR_LATER
+        pDAE = new DAE(NULL,NULL,_specversion);
+#else
         pDAE = new DAE;
+#endif
     }
-    std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL);        // Deallocates locally created structure at scope exit
+    smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL);        // Deallocates locally created structure at scope exit
 
     // Convert file name to URI
     std::string fileURI = ConvertFilePathToColladaCompatibleURI(fname);
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.h b/src/osgPlugins/dae/ReaderWriterDAE.h
index 63ee6bd00..2bea1bcf2 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/ReaderWriterDAE.h
+++ b/src/osgPlugins/dae/ReaderWriterDAE.h
@@ -13,6 +13,8 @@ class ReaderWriterDAE : public osgDB::ReaderWriter
 public:
     ReaderWriterDAE()
     {
+        _specversion = "1.4.1";
+
         // Collada document
         supportsExtension("dae","COLLADA 1.4.x DAE format");
         // Collada zip archive (contains one or more dae files and a manifest.xml)
@@ -26,13 +28,14 @@ public:
         supportsOption("daeLinkOriginalTexturesNoForce", "(Write option) Writes reference to the original image if found, instead of writing the image in memory");
         supportsOption("daeLinkOriginalTexturesForce",   "(Write option) Writes reference to the original image even if not found, instead of writing the image in memory");
         supportsOption("daeNamesUseCodepage",            "(Write option) All names except filenames (materials, animation, geometries...) should be considered as encoded using current codepage (UTF8 if not). Filenames follow OSG_USE_UTF8_FILENAME.");
+        supportsOption("daeRenameIds",                   "(Write option) Rename all IDs (geometries, materials, etc.) to remove characters which may be interpreted as an URI. Useful if you want to ensure names having spaces or slashes behave correctly. This may be undesired if original naming must be somewhat kept.");
 
         supportsOption("StrictTransparency", "(Read option) Undocumented");
         supportsOption("daeTessellateNone",              "(Read option) Do not tessellate at all (Polygons are stored as GL_POLYGON - not suitable for concave polygons)");
         supportsOption("daeTessellatePolygonsAsTriFans", "(Read option) Tessellate the old way (default), interpreting polygons as triangle fans (faster, but does not work for concave polygons)");
         supportsOption("daeTessellatePolygons",          "(Read option) Use full tessellation of polygons (slower, works for concave polygons)");
         supportsOption("daeUsePredefinedTextureUnits",   "(Read option) Texture units have fixed uses (0: ambient occlusion, 1: main texture...). May create non contiguous units (default).");
-        supportsOption("daeUsePredefinedTextureUnits",   "(Read option) Texture units are created in sequence (contiguous units).");
+        supportsOption("daeUseSequencedTextureUnits",    "(Read option) Texture units are created in sequence (contiguous units).");
     }
 
     const char* className() const { return "COLLADA 1.4.x DAE reader/writer"; }
@@ -47,6 +50,7 @@ public:
 
 private:
     mutable OpenThreads::ReentrantMutex _serializerMutex;
+    const char* _specversion;
 };
 
 ///////////////////////////////////////////////////////////////////////////
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRAnimations.cpp b/src/osgPlugins/dae/daeRAnimations.cpp
index 63ef93382..cda238b84 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRAnimations.cpp
+++ b/src/osgPlugins/dae/daeRAnimations.cpp
@@ -467,14 +467,14 @@ void daeReader::processAnimationMap(const TargetChannelPartMap& tcm, osgAnimatio
             else if (MatrixCubicBezierKeyframeContainer* cbkfCntr =
                 dynamic_cast<MatrixCubicBezierKeyframeContainer*>(channelPart->keyframes.get()))
             {
-                osgAnimation::MatrixKeyframeContainer* kfCntr = new osgAnimation::MatrixKeyframeContainer;
+                osgAnimation::MatrixKeyframeContainer* cbCntr = new osgAnimation::MatrixKeyframeContainer;
                 for (size_t i = 0; i < cbkfCntr->size(); ++i)
                 {
                     const MatrixCubicBezierKeyframe& cbkf = cbkfCntr->at(i);
-                    kfCntr->push_back(osgAnimation::MatrixKeyframe(cbkf.getTime(), cbkf.getValue().getPosition()));
+                    cbCntr->push_back(osgAnimation::MatrixKeyframe(cbkf.getTime(), cbkf.getValue().getPosition()));
                 }
                 osgAnimation::MatrixLinearChannel* channel = new osgAnimation::MatrixLinearChannel;
-                channel->getOrCreateSampler()->setKeyframeContainer(kfCntr);
+                channel->getOrCreateSampler()->setKeyframeContainer(cbCntr);
                 pOsgAnimationChannel = channel;
             }
         }
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRGeometry.cpp b/src/osgPlugins/dae/daeRGeometry.cpp
index 3258f83a6..088105db7 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRGeometry.cpp
+++ b/src/osgPlugins/dae/daeRGeometry.cpp
@@ -224,10 +224,10 @@ osg::Node* daeReader::processMorph(domMorph* pDomMorph, domBind_material* pDomBi
                             osg::Geode* targetgeode = getOrCreateGeometry(pDomGeometry, NULL);
 
                             // Expects a single geometry inside the geode, should change this
-                            osg::Geometry* pOsgGeometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
-                            if (pOsgGeometry)
+                            osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
+                            if (geometry)
                             {
-                                pOsgMorphGeometry->addMorphTarget(pOsgGeometry);
+                                pOsgMorphGeometry->addMorphTarget(geometry);
                             }
                         }
                         else
@@ -248,10 +248,10 @@ osg::Node* daeReader::processMorph(domMorph* pDomMorph, domBind_material* pDomBi
                             osg::Geode* targetgeode = getOrCreateGeometry(pDomGeometry, NULL);
 
                             // Expects a single geometry inside the geode, should change this
-                            osg::Geometry* pOsgGeometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
-                            if (pOsgGeometry)
+                            osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(targetgeode->getDrawable(0));
+                            if (geometry)
                             {
-                                pOsgMorphGeometry->addMorphTarget(pOsgGeometry);
+                                pOsgMorphGeometry->addMorphTarget(geometry);
                             }
                         }
                         else
@@ -596,10 +596,6 @@ void daeReader::processPolygons(osg::Geode* geode,
         osg::DrawElementsUInt* pDrawElements = new osg::DrawElementsUInt(GL_TRIANGLES);
         geometry->addPrimitiveSet(pDrawElements);
 
-        std::vector<std::vector<GLuint> > indexLists;
-        resolveMeshArrays(group->getP_array(), group->getInput_array(), pDomMesh,
-            geometry, sources, indexLists);
-
         for ( size_t i = 0; i < indexLists.size(); ++i)
         {
             const std::vector<GLuint>& indices = indexLists[i];
@@ -960,18 +956,18 @@ void daeReader::resolveMeshArrays(const domP_Array& domPArray,
             //We keep somewhere the mapping between daeElement id and created arrays
             _texCoordIdMap.insert(std::pair<std::string,size_t>(id,texcoord_set));
             // 2D Texcoords
-            osg::ref_ptr<osg::Array> array( createGeometryArray<osg::Vec2Array, osg::Vec2dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
-            if (array.valid())
+            osg::ref_ptr<osg::Array> array2d( createGeometryArray<osg::Vec2Array, osg::Vec2dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
+            if (array2d.valid())
             {
-                geometry->setTexCoordArray(texcoord_set, array.get());
+                geometry->setTexCoordArray(texcoord_set, array2d.get());
             }
             else
             {
                 // 3D Textcoords
-                osg::ref_ptr<osg::Array> array( createGeometryArray<osg::Vec3Array, osg::Vec3dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
-                if (array.valid())
+                osg::ref_ptr<osg::Array> array3d( createGeometryArray<osg::Vec3Array, osg::Vec3dArray, VertexIndices::TEXCOORD>(sources[texcoord_source], vertexIndicesIndexMap, readDoubleTexcoords, texcoord_set) );
+                if (array3d.valid())
                 {
-                    geometry->setTexCoordArray(texcoord_set, array.get());
+                    geometry->setTexCoordArray(texcoord_set, array3d.get());
                 }
             }
         }
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRMaterials.cpp b/src/osgPlugins/dae/daeRMaterials.cpp
index 158ca35ef..d4c2703b2 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRMaterials.cpp
+++ b/src/osgPlugins/dae/daeRMaterials.cpp
@@ -589,8 +589,6 @@ bool daeReader::processColorOrTextureType(const osg::StateSet* ss,
     }
     bool retVal = false;
 
-    std::string texCoordSet;
-
     //osg::StateAttribute *sa = NULL;
     //TODO: Make all channels process <param ref=""> type of value
     if (channel == osg::Material::EMISSION )
@@ -1017,6 +1015,11 @@ osg::Texture2D* daeReader::processTexture(
     domFx_surface_common *surface = NULL;
     domImage *dImg = NULL;
 
+    if(tex->getTexture() == NULL)
+    {
+        return NULL;
+    }
+
     std::string target = std::string("./") + std::string(tex->getTexture());
     OSG_INFO<<"processTexture("<<target<<")"<<std::endl;
 
@@ -1159,7 +1162,10 @@ osg::Texture2D* daeReader::processTexture(
         _textureParamMap[parameters] = t2D;
     }
 
-    _texCoordSetMap[TextureToCoordSetMap::key_type(ss, tuu)] = tex->getTexcoord();
+    if(tex->getTexcoord() != NULL)
+    {
+        _texCoordSetMap[TextureToCoordSetMap::key_type(ss, tuu)] = tex->getTexcoord();
+    }
 
     return t2D;
 }
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRSceneObjects.cpp b/src/osgPlugins/dae/daeRSceneObjects.cpp
index 9874ed315..9096345a4 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRSceneObjects.cpp
+++ b/src/osgPlugins/dae/daeRSceneObjects.cpp
@@ -361,7 +361,7 @@ osg::Node* daeReader::processLight( domLight *dlight )
     lightmodel->setAmbientIntensity(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
     _rootStateSet->setAttributeAndModes(lightmodel, osg::StateAttribute::ON);
 
-    osg::LightSource* lightsource = new osg::LightSource();
+    osg::ref_ptr<osg::LightSource> lightsource = new osg::LightSource();
     lightsource->setLight(light);
     std::string name = dlight->getId() ? dlight->getId() : "";
     if (dlight->getName())
@@ -520,7 +520,7 @@ osg::Node* daeReader::processLight( domLight *dlight )
         light->setDirection(osg::Vec3(0, 0, -1));
     }
 
-    return lightsource;
+    return lightsource.release();
 }
 
 // <camera>
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRTransforms.cpp b/src/osgPlugins/dae/daeRTransforms.cpp
index 9100b8d0b..be182f854 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeRTransforms.cpp
+++ b/src/osgPlugins/dae/daeRTransforms.cpp
@@ -33,7 +33,7 @@ using namespace osgDAE;
 
 // Note <lookat>, <matrix>, <rotate>, <scale>, <skew> and <translate> may appear in any order
 // These transformations can be combined in any number and ordering to produce the desired
-// coordinate system for the parent <node> element. The COLLADA specificatin requires that the
+// coordinate system for the parent <node> element. The COLLADA specification requires that the
 // transformation elements are processed in order and accumulate the result as if they were
 // converted to column-order matrices and concatenated using matrix post-multiplication.
 osg::Transform* daeReader::processOsgMatrixTransform(domNode *node, bool isBone)
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeReader.cpp b/src/osgPlugins/dae/daeReader.cpp
index e7dbe956e..282389fd0 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeReader.cpp
+++ b/src/osgPlugins/dae/daeReader.cpp
@@ -185,9 +185,9 @@ bool daeReader::processDocument( const std::string& fileURI)
         // identify every node as a joint, making it meaningless.
         std::vector<domInstance_controller*> instanceControllers;
         database->typeLookup(instanceControllers);
-        for (size_t i = 0; i < instanceControllers.size(); ++i)
+        for (size_t controller = 0; controller < instanceControllers.size(); ++controller)
         {
-            domInstance_controller* pInstanceController = instanceControllers[i];
+            domInstance_controller* pInstanceController = instanceControllers[controller];
 
             domController *pDomController = daeSafeCast<domController>(getElementFromURI(pInstanceController->getUrl()));
             if (!pDomController)
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWAnimations.cpp b/src/osgPlugins/dae/daeWAnimations.cpp
index 7bb793125..6927a4afe 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWAnimations.cpp
+++ b/src/osgPlugins/dae/daeWAnimations.cpp
@@ -35,10 +35,10 @@
 using namespace osgDAE;
 
 
-void daeWriter::writeAnimations( osg::Node &node )
+void daeWriter::writeAnimations( osg::Node &wnode )
 {
-    const std::string nodeNameUTF( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(node.getName()) : node.getName() );
-    osg::Callback* ncb = node.getUpdateCallback();
+    const std::string nodeNameUTF( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(wnode.getName()) : wnode.getName() );
+    osg::Callback* ncb = wnode.getUpdateCallback();
     if (ncb)
     {
         osgAnimation::AnimationManagerBase* am = dynamic_cast<osgAnimation::AnimationManagerBase*>(ncb);
@@ -51,12 +51,12 @@ void daeWriter::writeAnimations( osg::Node &node )
             }
 
             osgAnimation::AnimationList animationList = am->getAnimationList();
-            for (size_t i = 0; i < animationList.size(); i++)
+            for (size_t ai = 0; ai < animationList.size(); ai++)
             {
                 domAnimation* pDomAnimation = daeSafeCast< domAnimation >( _domLibraryAnimations->add( COLLADA_ELEMENT_ANIMATION ) );
                 domAnimation* pMainDomAnimation = pDomAnimation;
 
-                osg::ref_ptr<osgAnimation::Animation> animation = animationList[i];
+                osg::ref_ptr<osgAnimation::Animation> animation = animationList[ai];
                 std::string animationName( animation->getName() );
                 if (animationName.empty())
                     animationName = "animation";
@@ -264,7 +264,7 @@ void daeWriter::writeAnimations( osg::Node &node )
                             {
                                 domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
                                 pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
-                                std::string url = "#" + inputSourceName;
+                                url = "#" + inputSourceName;
                                 pDomInput->setSource(url.c_str());
 
                                 pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -280,7 +280,7 @@ void daeWriter::writeAnimations( osg::Node &node )
 
                             // Set sampler as source
                             domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
-                            std::string url = "#" + sourceNameX;
+                            url = "#" + sourceNameX;
                             pDomChannel->setSource(url.c_str());
 
                             // targetName contains the name of the updateCallback
@@ -308,7 +308,7 @@ void daeWriter::writeAnimations( osg::Node &node )
                             {
                                 domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
                                 pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
-                                std::string url = "#" + inputSourceName;
+                                url = "#" + inputSourceName;
                                 pDomInput->setSource(url.c_str());
 
                                 pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -324,7 +324,7 @@ void daeWriter::writeAnimations( osg::Node &node )
 
                             // Set sampler as source
                             domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
-                            std::string url = "#" + sourceNameY;
+                            url = "#" + sourceNameY;
                             pDomChannel->setSource(url.c_str());
 
                             // targetName contains the name of the updateCallback
@@ -352,7 +352,7 @@ void daeWriter::writeAnimations( osg::Node &node )
                             {
                                 domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
                                 pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
-                                std::string url = "#" + inputSourceName;
+                                url = "#" + inputSourceName;
                                 pDomInput->setSource(url.c_str());
 
                                 pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -368,7 +368,7 @@ void daeWriter::writeAnimations( osg::Node &node )
 
                             // Set sampler as source
                             domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
-                            std::string url = "#" + sourceNameZ;
+                            url = "#" + sourceNameZ;
                             pDomChannel->setSource(url.c_str());
 
                             // targetName contains the name of the updateCallback
@@ -438,7 +438,7 @@ void daeWriter::writeAnimations( osg::Node &node )
                         {
                             domInputLocal* pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
                             pDomInput->setSemantic(COMMON_PROFILE_INPUT_INPUT);
-                            std::string url = "#" + inputSourceName;
+                            url = "#" + inputSourceName;
                             pDomInput->setSource(url.c_str());
 
                             pDomInput = daeSafeCast< domInputLocal >(pDomSampler->add(COLLADA_ELEMENT_INPUT));
@@ -454,7 +454,7 @@ void daeWriter::writeAnimations( osg::Node &node )
 
                         // Set sampler as source
                         domChannel* pDomChannel = daeSafeCast< domChannel >(pDomAnimation->add(COLLADA_ELEMENT_CHANNEL));
-                        std::string url = "#" + sourceName;
+                        url = "#" + sourceName;
                         pDomChannel->setSource(url.c_str());
 
                         // targetName contains the name of the updateCallback
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWGeometry.cpp b/src/osgPlugins/dae/daeWGeometry.cpp
index 6eff94141..e7a8788ea 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWGeometry.cpp
+++ b/src/osgPlugins/dae/daeWGeometry.cpp
@@ -175,12 +175,12 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
             int size = 0; // TODO number of animated joints
 
             osgAnimation::VertexInfluenceMap* vim = pOsgRigGeometry->getInfluenceMap();
-            osgAnimation::VertexInfluenceMap::iterator iter =    vim->begin();
-            while (iter != vim->end())
+            osgAnimation::VertexInfluenceMap::iterator vim_iter =    vim->begin();
+            while (vim_iter != vim->end())
             {
-                jointNames.append(iter->first.c_str());
-                //iter->second.getn
-                ++iter;
+                jointNames.append(vim_iter->first.c_str());
+                //vim_iter->second.getn
+                ++vim_iter;
             }
 
             domName_array* pDomJointsNameArray = daeSafeCast< domName_array >(pDomJointsSource->add(COLLADA_ELEMENT_NAME_ARRAY));
@@ -192,7 +192,7 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
                 domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomJointsSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));
 
                 domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR));
-                std::string url = "#" + jointsNameArrayName;
+                url = "#" + jointsNameArrayName;
                 pDomAccessor->setSource(url.c_str());
                 pDomAccessor->setCount(size);
 
@@ -215,7 +215,7 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
                 domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomSkinBindPoseSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));
 
                 domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR));
-                std::string url = "#" + matricesArrayName;
+                url = "#" + matricesArrayName;
                 pDomAccessor->setSource(url.c_str());
                 pDomAccessor->setCount(size);
                 pDomAccessor->setStride(16);
@@ -239,7 +239,7 @@ void daeWriter::writeRigGeometry(osgAnimation::RigGeometry *pOsgRigGeometry)
                 domSource::domTechnique_common* pDomSourceTechniqueCommon = daeSafeCast< domSource::domTechnique_common >(pDomSkinWeightsSource->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));
 
                 domAccessor* pDomAccessor = daeSafeCast< domAccessor >(pDomSourceTechniqueCommon->add(COLLADA_ELEMENT_ACCESSOR));
-                std::string url = "#" + weightsArrayName;
+                url = "#" + weightsArrayName;
                 pDomAccessor->setSource(url.c_str());
                 pDomAccessor->setCount(size);
 
@@ -345,8 +345,8 @@ void daeWriter::writeMorphGeometry(osgAnimation::MorphGeometry *pOsgMorphGeometr
             osgAnimation::MorphGeometry::MorphTargetList morphTargetList = pOsgMorphGeometry->getMorphTargetList();
             for (unsigned int i=0; i < morphTargetList.size(); i++)
             {
-                domGeometry* pDomGeometry = getOrCreateDomGeometry(morphTargetList[i].getGeometry());
-                idrefs.append(pDomGeometry->getId());
+                domGeometry* pRefDomGeometry = getOrCreateDomGeometry(morphTargetList[i].getGeometry());
+                idrefs.append(pRefDomGeometry->getId());
             }
             pDomIDREFArray->setValue(idrefs);
             std::string targetsArrayName = targetsName + "_array";
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWSceneObjects.cpp b/src/osgPlugins/dae/daeWSceneObjects.cpp
index cadb65c98..72dab08c8 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWSceneObjects.cpp
+++ b/src/osgPlugins/dae/daeWSceneObjects.cpp
@@ -436,7 +436,7 @@ void daeWriter::apply( osg::LightSource &node )
     if ((ambientColor.r() != 0) || (ambientColor.g() != 0) || (ambientColor.b() != 0))
     {
         domInstance_light *ambientDomInstanceLight = daeSafeCast< domInstance_light >(currentNode->add( COLLADA_ELEMENT_INSTANCE_LIGHT ));
-        std::string name = node.getName();
+        name = node.getName();
         if (name.empty())
         {
             name = uniquify( "light-ambient" );
@@ -445,7 +445,7 @@ void daeWriter::apply( osg::LightSource &node )
         {
             name += "-ambient";
         }
-        std::string url = "#" + name;
+        url = "#" + name;
         ambientDomInstanceLight->setUrl( url.c_str() );
 
         domLight *ambientDomLight = daeSafeCast< domLight >( lib_lights->add( COLLADA_ELEMENT_LIGHT ) );
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWTransforms.cpp b/src/osgPlugins/dae/daeWTransforms.cpp
index 79d408c4e..a51d9b608 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWTransforms.cpp
+++ b/src/osgPlugins/dae/daeWTransforms.cpp
@@ -39,7 +39,7 @@ void daeWriter::writeUpdateTransformElements(const osg::Vec3 &pos, const osg::Qu
 
     // Make a three rotate place elements for the euler angles
     // TODO decompose quaternion into three euler angles
-    double angle;
+    osg::Quat::value_type angle;
     osg::Vec3 axis;
     q.getRotate( angle, axis );
 
@@ -154,7 +154,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
             scale->getValue().append3( s.x(), s.y(), s.z() );
         }
 
-        double angle;
+        osg::Quat::value_type angle;
         osg::Vec3 axis;
         q.getRotate( angle, axis );
         if ( angle != 0 )
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.cpp b/src/osgPlugins/dae/daeWriter.cpp
index c9089bd54..acd40e96e 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.cpp
+++ b/src/osgPlugins/dae/daeWriter.cpp
@@ -19,16 +19,17 @@
 #include <dom/domConstants.h>
 
 #include <sstream>
+#include <stdexcept>
 #include <osgDB/ConvertUTF>
-
+#include <limits>
 
 namespace osgDAE {
 
-daeWriter::ArrayNIndices::ArrayNIndices( osg::Array* valArray, osg::IndexArray* ind ) :
+daeWriter::ArrayNIndices::ArrayNIndices( osg::Array* vArray, osg::IndexArray* ind ) :
     vec2(0),  vec3(0),  vec4(0),
     vec2d(0), vec3d(0), vec4d(0),
     vec4ub(0),
-    valArray(valArray),
+    valArray(vArray),
     inds( ind ), mode(NONE)
 {
     if ( valArray != NULL )
@@ -71,6 +72,20 @@ daeWriter::ArrayNIndices::ArrayNIndices( osg::Array* valArray, osg::IndexArray*
 }
 
 
+std::string toString(const osg::Vec2f& value)
+{
+    std::stringstream str;
+    str << value.x() << " " << value.y();
+    return str.str();
+}
+
+std::string toString(const osg::Vec2d& value)
+{
+    std::stringstream str;
+    str << value.x() << " " << value.y();
+    return str.str();
+}
+
 std::string toString(const osg::Vec3f& value)
 {
     std::stringstream str;
@@ -85,7 +100,22 @@ std::string toString(const osg::Vec3d& value)
     return str.str();
 }
 
-std::string toString(const osg::Matrix& value)
+std::string toString(const osg::Vec4f& value)
+{
+    std::stringstream str;
+    str << value.x() << " " << value.y() << " " << value.z() << " " << value.w();
+    return str.str();
+}
+
+std::string toString(const osg::Vec4d& value)
+{
+    std::stringstream str;
+    str << value.x() << " " << value.y() << " " << value.z() << " " << value.w();
+    return str.str();
+}
+
+template <typename T>
+std::string matrixToString(T value)
 {
     std::stringstream str;
     str << value(0,0) << " " << value(1,0) << " " << value(2,0) << " " << value(3,0) << " "
@@ -95,6 +125,15 @@ std::string toString(const osg::Matrix& value)
     return str.str();
 }
 
+std::string toString(const osg::Matrixf& value)
+{
+    return matrixToString<osg::Matrixf>(value);
+}
+
+std::string toString(const osg::Matrixd& value)
+{
+    return matrixToString<osg::Matrixd>(value);
+}
 
 daeWriter::Options::Options()
     : usePolygons(false),
@@ -104,7 +143,8 @@ daeWriter::Options::Options()
     linkOrignialTextures(false),
     forceTexture(false),
     namesUseCodepage(false),
-    relativiseImagesPathNbUpDirs(0)
+    relativiseImagesPathNbUpDirs(0),
+    renameIds(false)
 {}
 
 daeWriter::daeWriter( DAE *dae_, const std::string & fileURI, const std::string & directory, const std::string & srcDirectory, const osgDB::ReaderWriter::Options * options, TraversalMode tm, const Options * pluginOptions) : osg::NodeVisitor( tm ),
@@ -209,22 +249,31 @@ void daeWriter::updateCurrentDaeNode()
     }
 }
 
-std::string daeWriter::uniquify( const std::string &_name )
+std::string daeWriter::uniquify( const std::string & uname )
 {
-    const std::string name( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(_name) : _name );
-    std::map< std::string, int >::iterator iter = uniqueNames.find( name );
-    if ( iter != uniqueNames.end() )
+    const std::string baseName( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(uname) : uname );
+    std::string newName( baseName );
+    if (_pluginOptions.renameIds)
     {
-        iter->second++;
-        std::ostringstream num;
-        num << std::dec << iter->second;
-        return name + "_" + num.str();
+        // Turn 'newName' into a simple ID
+        // Note: ConvertFilePathToColladaCompatibleURI(newName) did not the job: names such as "C:\somedir\somefile" become "/C:/somedir/somefile" and are not interpreted as a simple ID within Google Earth.
+        static const char * const REPLACE_CHARS = " /\\:#?=%&*";
+        for(std::size_t found = newName.find_first_of(REPLACE_CHARS); found != std::string::npos; found = newName.find_first_of(REPLACE_CHARS)) newName[found] = '_';
     }
-    else
+
+    // Loop while newName is in use
+    UniqueNames::iterator iter;
+    for (iter = uniqueNames.find(newName); iter != uniqueNames.end(); iter = uniqueNames.find(newName))
     {
-        uniqueNames.insert( std::make_pair( name, 0 ) );
-        return name;
+        if (iter->second == std::numeric_limits<UniqueNames::mapped_type>::max()) throw std::runtime_error("Not implemented: renaming DAE name above given limit.");
+        iter->second++;        // Increment usage count
+        std::ostringstream num;
+        num << std::dec << iter->second;
+        newName = baseName + "_" + num.str();
     }
+
+    uniqueNames.insert( std::make_pair( newName, 0 ) );
+    return newName;
 }
 
 void daeWriter::createAssetTag( bool isZUpAxis )
diff --git a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.h b/src/osgPlugins/dae/daeWriter.h
index a2f18d874..5a74132d9 100644
--- a/home/bcurtis/Workspace/Private/OpenMW/OSG-3.4/OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/dae/daeWriter.h
+++ b/src/osgPlugins/dae/daeWriter.h
@@ -89,9 +89,14 @@ std::string toString(T value)
     return str.str();
 }
 
+std::string toString(const osg::Vec2f& value);
+std::string toString(const osg::Vec2d& value);
 std::string toString(const osg::Vec3f& value);
 std::string toString(const osg::Vec3d& value);
-std::string toString(const osg::Matrix& value);
+std::string toString(const osg::Vec4f& value);
+std::string toString(const osg::Vec4d& value);
+std::string toString(const osg::Matrixf& value);
+std::string toString(const osg::Matrixd& value);
 
 // Collects all nodes that are targeted by an animation
 class FindAnimatedNodeVisitor : public osg::NodeVisitor
@@ -164,6 +169,8 @@ public:
         bool forceTexture;
         bool namesUseCodepage;
         unsigned int relativiseImagesPathNbUpDirs;
+        /** Rename all IDs (geometries, materials, etc.) to remove characters which may be interpreted as an URI. */
+        bool renameIds;
     };
     daeWriter(DAE *dae_, const std::string &fileURI, const std::string & directory, const std::string & srcDirectory, const osgDB::ReaderWriter::Options * options, TraversalMode tm=TRAVERSE_ALL_CHILDREN, const Options * pluginOptions=NULL);
     virtual ~daeWriter();
@@ -264,7 +271,8 @@ protected: //members
     typedef std::map< osgAnimation::RigGeometry*, domController *> OsgRigGeometryDomControllerMap;
     typedef std::map< osgAnimation::MorphGeometry*, domController *> OsgMorphGeometryDomControllerMap;
 
-    std::map< std::string, int > uniqueNames;
+    typedef std::map< std::string, int > UniqueNames;
+    UniqueNames uniqueNames;
     OsgGeometryDomGeometryMap geometryMap;
     OsgRigGeometryDomControllerMap _osgRigGeometryDomControllerMap;
     OsgMorphGeometryDomControllerMap _osgMorphGeometryDomControllerMap;