Frederic: Ignore display lists when using the blend animation.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include <string.h> // for strcmp()
|
#include <string.h> // for strcmp()
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include <plib/sg.h>
|
#include <plib/sg.h>
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
#include "model.hxx"
|
#include "model.hxx"
|
||||||
|
|
||||||
SG_USING_STD(vector);
|
SG_USING_STD(vector);
|
||||||
|
SG_USING_STD(set);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -122,8 +124,10 @@ sgMakeAnimation( ssgBranch * model,
|
|||||||
vector<SGPropertyNode_ptr> &name_nodes,
|
vector<SGPropertyNode_ptr> &name_nodes,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr node,
|
SGPropertyNode_ptr node,
|
||||||
double sim_time_sec )
|
double sim_time_sec,
|
||||||
|
set<ssgBranch *> &ignore_branches )
|
||||||
{
|
{
|
||||||
|
bool ignore = false;
|
||||||
SGAnimation * animation = 0;
|
SGAnimation * animation = 0;
|
||||||
const char * type = node->getStringValue("type", "none");
|
const char * type = node->getStringValue("type", "none");
|
||||||
if (!strcmp("none", type)) {
|
if (!strcmp("none", type)) {
|
||||||
@@ -152,6 +156,7 @@ sgMakeAnimation( ssgBranch * model,
|
|||||||
animation = new SGTexMultipleAnimation(prop_root, node);
|
animation = new SGTexMultipleAnimation(prop_root, node);
|
||||||
} else if (!strcmp("blend", type)) {
|
} else if (!strcmp("blend", type)) {
|
||||||
animation = new SGBlendAnimation(prop_root, node);
|
animation = new SGBlendAnimation(prop_root, node);
|
||||||
|
ignore = true;
|
||||||
} else if (!strcmp("alpha-test", type)) {
|
} else if (!strcmp("alpha-test", type)) {
|
||||||
animation = new SGAlphaTestAnimation(node);
|
animation = new SGAlphaTestAnimation(node);
|
||||||
} else if (!strcmp("flash", type)) {
|
} else if (!strcmp("flash", type)) {
|
||||||
@@ -204,19 +209,22 @@ sgMakeAnimation( ssgBranch * model,
|
|||||||
branch->setUserData(animation);
|
branch->setUserData(animation);
|
||||||
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
|
branch->setTravCallback(SSG_CALLBACK_PRETRAV, animation_callback);
|
||||||
branch->setTravCallback(SSG_CALLBACK_POSTTRAV, restore_callback);
|
branch->setTravCallback(SSG_CALLBACK_POSTTRAV, restore_callback);
|
||||||
|
if ( ignore ) {
|
||||||
|
ignore_branches.insert( branch );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void makeDList( ssgBranch *b )
|
static void makeDList( ssgBranch *b, const set<ssgBranch *> &ignore )
|
||||||
{
|
{
|
||||||
int nb = b->getNumKids();
|
int nb = b->getNumKids();
|
||||||
for (int i = 0; i<nb; i++) {
|
for (int i = 0; i<nb; i++) {
|
||||||
ssgEntity *e = b->getKid(i);
|
ssgEntity *e = b->getKid(i);
|
||||||
if (e->isAKindOf(ssgTypeLeaf())) {
|
if (e->isAKindOf(ssgTypeLeaf())) {
|
||||||
((ssgLeaf*)e)->makeDList();
|
((ssgLeaf*)e)->makeDList();
|
||||||
} else if (e->isAKindOf(ssgTypeBranch())) {
|
} else if (e->isAKindOf(ssgTypeBranch()) && ignore.find((ssgBranch *)e) == ignore.end()) {
|
||||||
makeDList( (ssgBranch*)e );
|
makeDList( (ssgBranch*)e, ignore );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,12 +278,6 @@ sgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
if (model == 0)
|
if (model == 0)
|
||||||
throw sg_exception("Failed to load 3D model");
|
throw sg_exception("Failed to load 3D model");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PLIB_VERSION > 183
|
|
||||||
if ( model != 0 ) {
|
|
||||||
makeDList( model );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Set up the alignment node
|
// Set up the alignment node
|
||||||
ssgTransform * alignmainmodel = new ssgTransform;
|
ssgTransform * alignmainmodel = new ssgTransform;
|
||||||
if ( load_panel == 0 )
|
if ( load_panel == 0 )
|
||||||
@@ -293,18 +295,6 @@ sgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
|
|
||||||
unsigned int i;
|
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
|
// Load sub-models
|
||||||
vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
|
vector<SGPropertyNode_ptr> model_nodes = props.getChildren("model");
|
||||||
for (i = 0; i < model_nodes.size(); i++) {
|
for (i = 0; i < model_nodes.size(); i++) {
|
||||||
@@ -328,21 +318,34 @@ sgLoad3DModel( const string &fg_root, const string &path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load animations
|
// Load animations
|
||||||
|
set<ssgBranch *> ignore_branches;
|
||||||
vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
|
vector<SGPropertyNode_ptr> animation_nodes = props.getChildren("animation");
|
||||||
for (i = 0; i < animation_nodes.size(); i++) {
|
for (i = 0; i < animation_nodes.size(); i++) {
|
||||||
const char * name = animation_nodes[i]->getStringValue("name", 0);
|
const char * name = animation_nodes[i]->getStringValue("name", 0);
|
||||||
vector<SGPropertyNode_ptr> name_nodes =
|
vector<SGPropertyNode_ptr> name_nodes =
|
||||||
animation_nodes[i]->getChildren("object-name");
|
animation_nodes[i]->getChildren("object-name");
|
||||||
sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
|
sgMakeAnimation( model, name, name_nodes, prop_root, animation_nodes[i],
|
||||||
sim_time_sec);
|
sim_time_sec, ignore_branches);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if PLIB_VERSION > 183
|
||||||
if ( model != 0 ) {
|
if ( model != 0 ) {
|
||||||
makeDList( model );
|
makeDList( model, ignore_branches );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return alignmainmodel;
|
return alignmainmodel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ sgMakeAnimation( ssgBranch * model,
|
|||||||
vector<SGPropertyNode_ptr> &name_nodes,
|
vector<SGPropertyNode_ptr> &name_nodes,
|
||||||
SGPropertyNode *prop_root,
|
SGPropertyNode *prop_root,
|
||||||
SGPropertyNode_ptr node,
|
SGPropertyNode_ptr node,
|
||||||
double sim_time_sec );
|
double sim_time_sec,
|
||||||
|
vector<ssgBranch *> &ignore_branches );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the filter state on models
|
* Set the filter state on models
|
||||||
|
|||||||
Reference in New Issue
Block a user