From cd041af9d8d601739b334e1f97df7fb00899f984 Mon Sep 17 00:00:00 2001 From: david <david> Date: Fri, 3 May 2002 21:09:14 +0000 Subject: [PATCH] Added a new 'billboard' animation type. This animation takes one 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 | 34 ++++++++++++++++++++++++++++++++++ src/Model/model.hxx | 17 +++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/Model/model.cxx b/src/Model/model.cxx index 01f0c2e8c..a713ab834 100644 --- a/src/Model/model.cxx +++ b/src/Model/model.cxx @@ -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) } + +//////////////////////////////////////////////////////////////////////// +// 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) +{ +} + + //////////////////////////////////////////////////////////////////////// // Implementation of FG3DModel::SelectAnimation diff --git a/src/Model/model.hxx b/src/Model/model.hxx index 86ceb019f..266702622 100644 --- a/src/Model/model.hxx +++ b/src/Model/model.hxx @@ -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