#include <simgear/structure/exception.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
+#include <simgear/props/condition.hxx>
#include "animation.hxx"
#include "model.hxx"
return 1;
}
+/**
+ * Callback and userData class for conditional rendering.
+ */
+class SGConditionalRender : public ssgBase {
+public:
+ SGConditionalRender(SGCondition *c) : _condition(c) {}
+ bool test() { return _condition->test(); }
+private:
+ SGCondition *_condition;
+};
+
+static int
+model_condition_callback (ssgEntity * entity, int mask)
+{
+ return ((SGConditionalRender *)entity->getUserData())->test();
+}
+
/**
* Locate a named SSG node in a branch.
SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage());
throw;
}
+
+ SGPropertyNode_ptr cond_node = node->getNode("condition", false);
+ if (cond_node) {
+ align->setUserData(new SGConditionalRender(sgReadCondition(prop_root, cond_node)));
+ align->setTravCallback(SSG_CALLBACK_PRETRAV, model_condition_callback);
+ }
+
align->addKid(kid);
align->setName(node->getStringValue("name", ""));
model->addKid(align);