1
0
Fork 0

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).
This commit is contained in:
david 2002-05-03 21:09:14 +00:00
parent 4306cebe9e
commit cd041af9d8
2 changed files with 51 additions and 0 deletions

View 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)
}
////////////////////////////////////////////////////////////////////////
// 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

View 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