]> git.mxchange.org Git - simgear.git/commitdiff
Add writeLocalData functions for internal scenegraph classes
authorTim Moore <timoore@redhat.com>
Tue, 28 Jul 2009 04:39:55 +0000 (06:39 +0200)
committerTim Moore <timoore@redhat.com>
Tue, 22 Sep 2009 10:56:28 +0000 (12:56 +0200)
This makes the scenegraph dump more complete and therefore more useful.

simgear/scene/model/SGPagedLOD.cxx
simgear/scene/model/animation.cxx
simgear/scene/model/animation.hxx
simgear/scene/util/SGSceneUserData.cxx
simgear/scene/util/SGSceneUserData.hxx

index ddd6dabd43c57232bf75be5e5712896f43f5ea6b..faaf42bb23f3ead4667dc06cf2b2a8800858d1ed 100644 (file)
@@ -19,6 +19,8 @@
 #endif
 
 #include <osgDB/ReadFile>
+#include <osgDB/Input>
+#include <osgDB/ParameterOutput>
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/OSGVersion.hxx>
@@ -70,3 +72,19 @@ void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp)
                          _readerWriterOptions.get());
 }
 
+bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
+{
+    return true;
+}
+
+namespace
+{
+osgDB::RegisterDotOsgWrapperProxy sgPagedLODProxy
+(
+    new SGPagedLOD,
+    "simgear::SGPagedLOD",
+    "Object Node LOD PagedLOD SGPagedLOD Group",
+    0,
+    &SGPagedLOD_writeLocalData
+    );
+}
index 22ba28258a4bdd64209ea18de9af4963cd1be766..80c08be2bfc5b002f68728229b3644471df9b3b4 100644 (file)
 #include <osg/Texture2D>
 #include <osg/Transform>
 #include <osgDB/ReadFile>
+#include <osgDB/Registry>
+#include <osgDB/Input>
+#include <osgDB/ParameterOutput>
+
 
 #include <simgear/math/interpolater.hxx>
 #include <simgear/props/condition.hxx>
@@ -971,6 +975,15 @@ osg::StateSet* getNormalizeStateSet()
 
 class SGDistScaleAnimation::Transform : public osg::Transform {
 public:
+  Transform() : _min_v(0.0), _max_v(0.0), _factor(0.0), _offset(0.0) {}
+  Transform(const Transform& rhs,
+            const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
+    : osg::Transform(rhs, copyOp), _table(rhs._table), _center(rhs._center),
+      _min_v(rhs._min_v), _max_v(rhs._max_v), _factor(rhs._factor),
+      _offset(rhs._offset)
+  {
+  }
+  META_Node(simgear, SGDistScaleAnimation::Transform);
   Transform(const SGPropertyNode* configNode)
   {
     setName(configNode->getStringValue("name", "dist scale animation"));
@@ -1018,6 +1031,16 @@ public:
     return true;
   }
 
+  static bool writeLocalData(const osg::Object& obj, osgDB::Output& fw)
+  {
+    const Transform& trans = static_cast<const Transform&>(obj);
+    fw.indent() << "center " << trans._center << "\n";
+    fw.indent() << "min_v " << trans._min_v << "\n";
+    fw.indent() << "max_v " << trans._max_v << "\n";
+    fw.indent() << "factor " << trans._factor << "\n";
+    fw.indent() << "offset " << trans._offset << "\n";
+    return true;
+  }
 private:
   double computeScaleFactor(osg::NodeVisitor* nv) const
   {
@@ -1061,6 +1084,17 @@ SGDistScaleAnimation::createAnimationGroup(osg::Group& parent)
   return transform;
 }
 
+namespace
+{
+  osgDB::RegisterDotOsgWrapperProxy distScaleAnimationTransformProxy
+  (
+   new SGDistScaleAnimation::Transform,
+   "SGDistScaleAnimation::Transform",
+   "Object Node Transform SGDistScaleAnimation::Transform Group",
+   0,
+   &SGDistScaleAnimation::Transform::writeLocalData
+   );
+}
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of flash animation
@@ -1068,6 +1102,19 @@ SGDistScaleAnimation::createAnimationGroup(osg::Group& parent)
 
 class SGFlashAnimation::Transform : public osg::Transform {
 public:
+  Transform() : _power(0.0), _factor(0.0), _offset(0.0), _min_v(0.0),
+                _max_v(0.0), _two_sides(false)
+  {}
+
+  Transform(const Transform& rhs,
+            const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
+    : osg::Transform(rhs, copyOp), _center(rhs._center), _axis(rhs._axis),
+      _power(rhs._power), _factor(rhs._factor), _offset(rhs._offset),
+      _min_v(rhs._min_v), _max_v(rhs._max_v), _two_sides(rhs._two_sides)
+  {
+  }
+  META_Node(simgear, SGFlashAnimation::Transform);
+
   Transform(const SGPropertyNode* configNode)
   {
     setReferenceFrame(RELATIVE_RF);
@@ -1124,6 +1171,21 @@ public:
     return true;
   }
 
+  static bool writeLocalData(const osg::Object& obj, osgDB::Output& fw)
+  {
+    const Transform& trans = static_cast<const Transform&>(obj);
+    fw.indent() << "center " << trans._center[0] << " "
+                << trans._center[1] << " " << trans._center[2] << " " << "\n";
+    fw.indent() << "axis " << trans._axis[0] << " "
+                << trans._axis[1] << " " << trans._axis[2] << " " << "\n";
+    fw.indent() << "power " << trans._power << " \n";
+    fw.indent() << "min_v " << trans._min_v << "\n";
+    fw.indent() << "max_v " << trans._max_v << "\n";
+    fw.indent() << "factor " << trans._factor << "\n";
+    fw.indent() << "offset " << trans._offset << "\n";
+    fw.indent() << "twosides " << (trans._two_sides ? "true" : "false") << "\n";
+    return true;
+  }
 private:
   double computeScaleFactor(osg::NodeVisitor* nv) const
   {
@@ -1178,13 +1240,29 @@ SGFlashAnimation::createAnimationGroup(osg::Group& parent)
   return transform;
 }
 
+namespace
+{
+  osgDB::RegisterDotOsgWrapperProxy flashAnimationTransformProxy
+  (
+   new SGFlashAnimation::Transform,
+   "SGFlashAnimation::Transform",
+   "Object Node Transform SGFlashAnimation::Transform Group",
+   0,
+   &SGFlashAnimation::Transform::writeLocalData
+   );
+}
 \f
 ////////////////////////////////////////////////////////////////////////
-// Implementation of flash animation
+// Implementation of billboard animation
 ////////////////////////////////////////////////////////////////////////
 
 class SGBillboardAnimation::Transform : public osg::Transform {
 public:
+  Transform() : _spherical(true) {}
+  Transform(const Transform& rhs,
+            const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
+    : osg::Transform(rhs, copyOp), _spherical(rhs._spherical) {}
+  META_Node(simgear, SGBillboardAnimation::Transform);
   Transform(const SGPropertyNode* configNode) :
     _spherical(configNode->getBoolValue("spherical", true))
   {
@@ -1221,7 +1299,13 @@ public:
     // Hmm, don't yet know how to get that back ...
     return false;
   }
+  static bool writeLocalData(const osg::Object& obj, osgDB::Output& fw)
+  {
+    const Transform& trans = static_cast<const Transform&>(obj);
 
+    fw.indent() << (trans._spherical ? "true" : "false") << "\n";
+    return true;
+  }
 private:
   bool _spherical;
 };
@@ -1241,6 +1325,17 @@ SGBillboardAnimation::createAnimationGroup(osg::Group& parent)
   return transform;
 }
 
+namespace
+{
+  osgDB::RegisterDotOsgWrapperProxy billboardAnimationTransformProxy
+  (
+   new SGBillboardAnimation::Transform,
+   "SGBillboardAnimation::Transform",
+   "Object Node Transform SGBillboardAnimation::Transform Group",
+   0,
+   &SGBillboardAnimation::Transform::writeLocalData
+   );
+}
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of a range animation
index eec16bc4b89fb2036e3b030d591e45a58498f2d5..4ea07fd271ca12cbd35b543e2c8e0728585c3cad 100644 (file)
@@ -174,7 +174,6 @@ public:
   SGDistScaleAnimation(const SGPropertyNode* configNode,
                        SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
   class Transform;
 };
 
@@ -188,7 +187,7 @@ public:
   SGFlashAnimation(const SGPropertyNode* configNode,
                    SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
+public:
   class Transform;
 };
 
@@ -202,7 +201,6 @@ public:
   SGBillboardAnimation(const SGPropertyNode* configNode,
                        SGPropertyNode* modelRoot);
   virtual osg::Group* createAnimationGroup(osg::Group& parent);
-private:
   class Transform;
 };
 
index c08fce0e824c8a30ef7d7abf1a91e9a21039379b..2388f09daf8906ebc7064e9d59bf0a46db681054 100644 (file)
 #  include <simgear_config.h>
 #endif
 
+#include <osgDB/Registry>
+#include <osgDB/Input>
+#include <osgDB/ParameterOutput>
+
 #include "SGSceneUserData.hxx"
 
 SGSceneUserData*
@@ -86,3 +90,38 @@ SGSceneUserData::addPickCallback(SGPickCallback* pickCallback)
     return;
   _pickCallbacks.push_back(pickCallback);
 }
+
+bool SGSceneUserData_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
+{
+    const SGSceneUserData& data = static_cast<const SGSceneUserData&>(obj);
+
+    unsigned numPickCallbacks = data.getNumPickCallbacks();
+    if (numPickCallbacks > 0)
+        fw.indent() << "num_pickCallbacks " << numPickCallbacks << "\n";
+    if (data.getBVHNode())
+        fw.indent() << "hasBVH true\n";
+    const SGSceneUserData::Velocity* vel = data.getVelocity();
+    if (vel) {
+        fw.indent() << "velocity {\n";
+        fw.moveIn();
+        fw.indent() << "linear " << vel->linear << "\n";
+        fw.indent() << "angular " << vel->angular << "\n";
+        fw.indent() << "referenceTime " << vel->referenceTime << "\n";
+        fw.indent() << "id " << static_cast<unsigned>(vel->id) << "\n";
+        fw.moveOut();
+        fw.indent() << "}\n";
+    }
+    return true;
+}
+
+namespace
+{
+osgDB::RegisterDotOsgWrapperProxy SGSceneUserDataProxy
+(
+    new SGSceneUserData,
+    "simgear::SGSceneUserData",
+    "Object simgear::SGSceneUserData",
+    0,
+    &SGSceneUserData_writeLocalData
+    );
+}
index 4f3f38fc6d2aa48ee413e83cbec541cb9ebfaf3b..1296e9c348f321719d7bcad89736c7b918c49a11 100644 (file)
 #define SG_SCENE_USERDATA_HXX
 
 #include <vector>
-#include <osg/Referenced>
 #include <osg/Node>
+#include <osg/Object>
 #include <simgear/scene/bvh/BVHNode.hxx>
 #include "SGPickCallback.hxx"
 
-class SGSceneUserData : public osg::Referenced {
+class SGSceneUserData : public osg::Object {
 public:
+  META_Object(simgear, SGSceneUserData);
+  SGSceneUserData() {}
+  SGSceneUserData(const SGSceneUserData& rhs,
+                  const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY)
+    : _bvhNode(rhs._bvhNode), _velocity(rhs._velocity),
+      _pickCallbacks(rhs._pickCallbacks)
+  {
+  }
   static SGSceneUserData* getSceneUserData(osg::Node* node);
   static const SGSceneUserData* getSceneUserData(const osg::Node* node);
   static SGSceneUserData* getOrCreateSceneUserData(osg::Node* node);