]> git.mxchange.org Git - flightgear.git/commitdiff
Added a new 'billboard' animation type. This animation takes one
authordavid <david>
Fri, 3 May 2002 21:09:14 +0000 (21:09 +0000)
committerdavid <david>
Fri, 3 May 2002 21:09:14 +0000 (21:09 +0000)
subproperty, 'spherical', which is true if the object has spherical
symmetry and should rotate around both the x-axis and z-axis to face
the camera (i.e. a simple cloud), and false if the object has only
cylindrical symmetry and should rotate only around the z-axis (i.e. a
tree).

src/Model/model.cxx
src/Model/model.hxx

index 01f0c2e8c826773fd861b6e0345f8ba70965a8f3..a713ab8346a2f12eeb55efec4382c01d593cba34 100644 (file)
@@ -342,6 +342,8 @@ FG3DModel::make_animation (const char * object_name,
     animation = new NullAnimation();
   } else if (!strcmp("range", type)) {
     animation = new RangeAnimation();
+  } else if (!strcmp("billboard", type)) {
+    animation = new BillboardAnimation();
   } else if (!strcmp("select", type)) {
     animation = new SelectAnimation();
   } else if (!strcmp("spin", type)) {
@@ -448,6 +450,38 @@ FG3DModel::RangeAnimation::update (int dt)
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FG3DModel::BillboardAnimation
+////////////////////////////////////////////////////////////////////////
+
+FG3DModel::BillboardAnimation::BillboardAnimation ()
+  : _branch(0)
+{
+  // Note: we cannot allocate the branch until we know whether
+  // it can rotate around the x axis as well as the z axis.
+}
+
+FG3DModel::BillboardAnimation::~BillboardAnimation ()
+{
+  _branch = 0;
+}
+
+void
+FG3DModel::BillboardAnimation::init (ssgEntity * object,
+                                    SGPropertyNode * props)
+{
+  _branch = new ssgCutout(props->getBoolValue("spherical", true));
+  splice_branch(_branch, object);
+  _branch->setName(props->getStringValue("name", 0));
+}
+
+void
+FG3DModel::BillboardAnimation::update (int dt)
+{
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FG3DModel::SelectAnimation
index 86ceb019fbfc2dd8ad03a5d60ac54fb0744fda4e..266702622179e83f79820ad104c15da5756c54bc 100644 (file)
@@ -19,6 +19,7 @@ SG_USING_STD(vector);
 
 // Don't pull in the headers, since we don't need them here.
 class ssgBranch;
+class ssgCutout;
 class ssgEntity;
 class ssgRangeSelector;
 class ssgSelector;
@@ -166,6 +167,21 @@ private:
   };
 
 
+  /**
+   * Animation to turn and face the screen.
+   */
+  class BillboardAnimation : public Animation
+  {
+  public:
+    BillboardAnimation ();
+    virtual ~BillboardAnimation ();
+    virtual void init (ssgEntity * object, SGPropertyNode * props);
+    virtual void update (int dt);
+  private:
+    ssgCutout * _branch;
+  };
+
+
   /**
    * Animation to select alternative versions of the same object.
    */
@@ -259,6 +275,7 @@ private:
     ssgTransform * _transform;
   };
 
+
 };
 
 #endif // __MODEL_HXX