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:
parent
4306cebe9e
commit
cd041af9d8
2 changed files with 51 additions and 0 deletions
|
@ -342,6 +342,8 @@ FG3DModel::make_animation (const char * object_name,
|
||||||
animation = new NullAnimation();
|
animation = new NullAnimation();
|
||||||
} else if (!strcmp("range", type)) {
|
} else if (!strcmp("range", type)) {
|
||||||
animation = new RangeAnimation();
|
animation = new RangeAnimation();
|
||||||
|
} else if (!strcmp("billboard", type)) {
|
||||||
|
animation = new BillboardAnimation();
|
||||||
} else if (!strcmp("select", type)) {
|
} else if (!strcmp("select", type)) {
|
||||||
animation = new SelectAnimation();
|
animation = new SelectAnimation();
|
||||||
} else if (!strcmp("spin", type)) {
|
} 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
|
// Implementation of FG3DModel::SelectAnimation
|
||||||
|
|
|
@ -19,6 +19,7 @@ SG_USING_STD(vector);
|
||||||
|
|
||||||
// Don't pull in the headers, since we don't need them here.
|
// Don't pull in the headers, since we don't need them here.
|
||||||
class ssgBranch;
|
class ssgBranch;
|
||||||
|
class ssgCutout;
|
||||||
class ssgEntity;
|
class ssgEntity;
|
||||||
class ssgRangeSelector;
|
class ssgRangeSelector;
|
||||||
class ssgSelector;
|
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.
|
* Animation to select alternative versions of the same object.
|
||||||
*/
|
*/
|
||||||
|
@ -259,6 +275,7 @@ private:
|
||||||
ssgTransform * _transform;
|
ssgTransform * _transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __MODEL_HXX
|
#endif // __MODEL_HXX
|
||||||
|
|
Loading…
Add table
Reference in a new issue