X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fmodel%2Fmodel.cxx;h=3d7cf5f3f8493ee3244905fde46a991cc959a19f;hb=bda112297f2d81bd752b758bbb42485ccbf6a89e;hp=39eb41c5c4fac25301b89d38928ec0f87eeca0b7;hpb=aa67c738a115c04dd841eb0f6a53cd47aeeca542;p=simgear.git diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index 39eb41c5..3d7cf5f3 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -28,19 +28,41 @@ SG_USING_STD(vector); + +//////////////////////////////////////////////////////////////////////// +// Global state +//////////////////////////////////////////////////////////////////////// +static bool +model_filter = true; + //////////////////////////////////////////////////////////////////////// // Static utility functions. //////////////////////////////////////////////////////////////////////// +static int +model_filter_callback (ssgEntity * entity, int mask) +{ + return model_filter ? 1 : 0; +} + /** * Callback to update an animation. */ static int animation_callback (ssgEntity * entity, int mask) { - ((SGAnimation *)entity->getUserData())->update(); - return true; + return ((SGAnimation *)entity->getUserData())->update(); +} + +/** + * Callback to restore the state after an animation. + */ +static int +restore_callback (ssgEntity * entity, int mask) +{ + ((SGAnimation *)entity->getUserData())->restore(); + return 1; } @@ -132,6 +154,10 @@ sgMakeAnimation( ssgBranch * model, animation = new SGBlendAnimation(prop_root, node); } else if (!strcmp("alpha-test", type)) { animation = new SGAlphaTestAnimation(node); + } else if (!strcmp("flash", type)) { + animation = new SGFlashAnimation(node); + } else if (!strcmp("dist-scale", type)) { + animation = new SGDistScaleAnimation(node); } else { animation = new SGNullAnimation(node); SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type); @@ -175,6 +201,7 @@ sgMakeAnimation( ssgBranch * model, animation->init(); branch->setUserData(animation); branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback); + branch->setTravCallback(SSG_CALLBACK_POSTTRAV, restore_callback); } @@ -187,7 +214,7 @@ sgMakeAnimation( ssgBranch * model, 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; @@ -223,6 +250,8 @@ sgLoad3DModel( const string &fg_root, const string &path, // 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, @@ -236,6 +265,18 @@ sgLoad3DModel( const string &fg_root, const string &path, unsigned int i; + if ( load_panel ) { + // Load panels + vector 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 model_nodes = props.getChildren("model"); for (i = 0; i < model_nodes.size(); i++) { @@ -252,7 +293,7 @@ sgLoad3DModel( const string &fg_root, const string &path, 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); @@ -271,5 +312,13 @@ sgLoad3DModel( const string &fg_root, const string &path, return alignmainmodel; } +bool +sgSetModelFilter( bool filter ) +{ + bool old = model_filter; + model_filter = filter; + return old; +} + // end of model.cxx