SG_USING_STD(vector);
+\f
+////////////////////////////////////////////////////////////////////////
+// Global state
+////////////////////////////////////////////////////////////////////////
+static bool
+model_filter = true;
+
\f
////////////////////////////////////////////////////////////////////////
// Static utility functions.
////////////////////////////////////////////////////////////////////////
+static int
+model_filter_callback (ssgEntity * entity, int mask)
+{
+ return model_filter;
+}
+
/**
* Callback to update an animation.
*/
ssgBranch *
sgLoad3DModel( const string &fg_root, const string &path,
SGPropertyNode *prop_root,
- double sim_time_sec )
+ double sim_time_sec, ssgEntity *(*load_panel)(SGPropertyNode *) )
{
ssgBranch * model = 0;
SGPropertyNode props;
// Set up the alignment node
ssgTransform * alignmainmodel = new ssgTransform;
+ if ( load_panel == 0 )
+ alignmainmodel->setTravCallback( SSG_CALLBACK_PRETRAV, model_filter_callback );
alignmainmodel->addKid(model);
sgMat4 res_matrix;
sgMakeOffsetsMatrix(&res_matrix,
unsigned int i;
+ if ( load_panel ) {
+ // Load panels
+ vector<SGPropertyNode_ptr> panel_nodes = props.getChildren("panel");
+ for (i = 0; i < panel_nodes.size(); i++) {
+ SG_LOG(SG_INPUT, SG_DEBUG, "Loading a panel");
+ ssgEntity * panel = load_panel(panel_nodes[i]);
+ if (panel_nodes[i]->hasValue("name"))
+ panel->setName((char *)panel_nodes[i]->getStringValue("name"));
+ model->addKid(panel);
+ }
+ }
+
// Load sub-models
vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
for (i = 0; i < model_nodes.size(); i++) {
align->setTransform(res_matrix);
ssgBranch * kid = sgLoad3DModel( fg_root, node->getStringValue("path"),
- prop_root, sim_time_sec );
+ prop_root, sim_time_sec, load_panel );
align->addKid(kid);
align->setName(node->getStringValue("name", ""));
model->addKid(align);
return alignmainmodel;
}
+bool
+sgSetModelFilter( bool filter )
+{
+ bool old = model_filter;
+ model_filter = filter;
+ return old;
+}
+
// end of model.cxx
*/
ssgBranch *
sgLoad3DModel( const string& fg_root, const string &path,
- SGPropertyNode *prop_root, double sim_time_sec );
+ SGPropertyNode *prop_root, double sim_time_sec,
+ ssgEntity *(*load_panel)(SGPropertyNode *) = 0 );
/**
SGPropertyNode_ptr node,
double sim_time_sec );
+/**
+ * Set the filter state on models
+ */
+bool
+sgSetModelFilter( bool filter );
#endif // __MODEL_HXX