*/
static void
make_offsets_matrix (sgMat4 * result, double h_rot, double p_rot, double r_rot,
- double x_off, double y_off, double z_off)
+ double x_off, double y_off, double z_off)
{
sgMat4 rot_matrix;
sgMat4 pos_matrix;
vector<SGPropertyNode_ptr> entries = table_node->getChildren("entry");
for (unsigned int i = 0; i < entries.size(); i++)
table->addEntry(entries[i]->getDoubleValue("ind", 0.0),
- entries[i]->getDoubleValue("dep", 0.0));
+ entries[i]->getDoubleValue("dep", 0.0));
return table;
} else {
return 0;
animation = new SelectAnimation(node);
} else if (!strcmp("spin", type)) {
animation = new SpinAnimation(node);
+ } else if (!strcmp("timed", type)) {
+ animation = new TimedAnimation(node);
} else if (!strcmp("rotate", type)) {
animation = new RotateAnimation(node);
} else if (!strcmp("translate", type)) {
oldParent->removeKid(object);
}
+ animation->init();
branch->setUserData(animation);
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
}
modelpath.append(props.getStringValue("/path"));
} else {
if (model == 0)
- model = new ssgBranch;
+ model = new ssgBranch;
}
}
align->addKid(model);
sgMat4 res_matrix;
make_offsets_matrix(&res_matrix,
- props.getFloatValue("/offsets/heading-deg", 0.0),
- props.getFloatValue("/offsets/roll-deg", 0.0),
- props.getFloatValue("/offsets/pitch-deg", 0.0),
- props.getFloatValue("/offsets/x-m", 0.0),
- props.getFloatValue("/offsets/y-m", 0.0),
- props.getFloatValue("/offsets/z-m", 0.0));
+ props.getFloatValue("/offsets/heading-deg", 0.0),
+ props.getFloatValue("/offsets/roll-deg", 0.0),
+ props.getFloatValue("/offsets/pitch-deg", 0.0),
+ props.getFloatValue("/offsets/x-m", 0.0),
+ props.getFloatValue("/offsets/y-m", 0.0),
+ props.getFloatValue("/offsets/z-m", 0.0));
align->setTransform(res_matrix);
// Load animations
model->addKid(panel);
}
- // Load sub-models
+ // Load sub-models
vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
for (i = 0; i < model_nodes.size(); i++) {
SGPropertyNode_ptr node = model_nodes[i];
ssgTransform * align = new ssgTransform;
sgMat4 res_matrix;
make_offsets_matrix(&res_matrix,
- node->getFloatValue("offsets/heading-deg", 0.0),
- node->getFloatValue("offsets/roll-deg", 0.0),
- node->getFloatValue("offsets/pitch-deg", 0.0),
- node->getFloatValue("offsets/x-m", 0.0),
- node->getFloatValue("offsets/y-m", 0.0),
- node->getFloatValue("offsets/z-m", 0.0));
+ node->getFloatValue("offsets/heading-deg", 0.0),
+ node->getFloatValue("offsets/roll-deg", 0.0),
+ node->getFloatValue("offsets/pitch-deg", 0.0),
+ node->getFloatValue("offsets/x-m", 0.0),
+ node->getFloatValue("offsets/y-m", 0.0),
+ node->getFloatValue("offsets/z-m", 0.0));
align->setTransform(res_matrix);
ssgBranch * kid = fgLoad3DModel(node->getStringValue("path"));
{
}
+void
+Animation::init ()
+{
+}
+
+void
+Animation::update ()
+{
+}
+
\f
////////////////////////////////////////////////////////////////////////
{
}
-void
-NullAnimation::update ()
-{
-}
-
\f
////////////////////////////////////////////////////////////////////////
{
}
-void
-RangeAnimation::update ()
-{
-}
-
\f
////////////////////////////////////////////////////////////////////////
{
}
-void
-BillboardAnimation::update ()
-{
-}
-
\f
////////////////////////////////////////////////////////////////////////
}
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of TimedAnimation
+////////////////////////////////////////////////////////////////////////
+
+TimedAnimation::TimedAnimation (SGPropertyNode_ptr props)
+ : Animation(props, new ssgSelector),
+ _duration_sec(props->getDoubleValue("duration-sec", 1.0)),
+ _last_time_sec(0),
+ _step(-1)
+{
+}
+
+TimedAnimation::~TimedAnimation ()
+{
+}
+
+void
+TimedAnimation::update ()
+{
+ float sim_time_sec = globals->get_sim_time_sec();
+ if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
+ _last_time_sec = sim_time_sec;
+ if (_step >= getBranch()->getNumKids())
+ _step = 0;
+ else
+ _step++;
+ ((ssgSelector *)getBranch())->selectStep(_step);
+ }
+}
+
+
\f
////////////////////////////////////////////////////////////////////////
// Implementation of RotateAnimation
void
FGModelPlacement::setOrientation (double roll_deg, double pitch_deg,
- double heading_deg)
+ double heading_deg)
{
_roll_deg = roll_deg;
_pitch_deg = pitch_deg;