- fbx: NodeAttribute can now be target for AnimCurveNode.

- fbx: rename Camera -> CameraSwitcher.
pull/14/head
Alexander Gessler 2012-07-26 03:58:42 +02:00
parent cab713b4c5
commit d5c05c7d84
5 changed files with 36 additions and 16 deletions

View File

@ -134,7 +134,8 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
}{
// find target node
const std::vector<const Connection*>& conns = doc.GetConnectionsBySourceSequenced(ID(),"Model");
const char* whitelist[] = {"Model","NodeAttribute"};
const std::vector<const Connection*>& conns = doc.GetConnectionsBySourceSequenced(ID(),whitelist,2);
BOOST_FOREACH(const Connection* con, conns) {
@ -143,13 +144,14 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
continue;
}
const Object* ob = con->DestinationObject();
const Object* const ob = con->DestinationObject();
if(!ob) {
DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring",&element);
continue;
}
target = dynamic_cast<const Model*>(ob);
ai_assert(dynamic_cast<const Model*>(ob) || dynamic_cast<const NodeAttribute*>(ob));
target = ob;
if(!target) {
continue;
}
@ -159,7 +161,7 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
}
}
if(!target) {
DOMError("failed to resolve target model for animation node",&element);
DOMError("failed to resolve target Model/NodeAttribute for AnimationCurveNode",&element);
}
}

View File

@ -944,8 +944,11 @@ private:
BOOST_FOREACH(const AnimationCurveNode* node, nodes) {
ai_assert(node);
const Model* model = node->TargetNode();
ai_assert(model);
const Model* const model = dynamic_cast<const Model*>(node->Target());
// this can happen - it could also be a NodeAttribute (i.e. for camera animations)
if(!model) {
continue;
}
const std::string& name = FixNodeName(model->Name());
node_map[name].push_back(node);
@ -1006,7 +1009,8 @@ private:
na->mNodeName.Set(kv.first);
const PropertyTable& props = curve_node->TargetNode()->Props();
ai_assert(curve_node->TargetAsModel());
const PropertyTable& props = curve_node->TargetAsModel()->Props();
// if a particular transformation is not given, grab it from
// the corresponding node to meet the semantics of aiNodeAnim,

View File

@ -467,6 +467,11 @@ const Object* LazyObject::Get(bool dieOnError)
object.reset(new MeshGeometry(id,element,name,doc));
}
}
else if (!strncmp(obtype,"NodeAttribute",length)) {
if (!strcmp(classtag.c_str(),"CameraSwitcher")) {
object.reset(new CameraSwitcher(id,element,doc,name));
}
}
else if (!strncmp(obtype,"Model",length)) {
object.reset(new Model(id,element,doc,name));
}

View File

@ -172,12 +172,12 @@ private:
/** DOM base class for FBX camera settings attached to a node */
class Camera : public NodeAttribute
class CameraSwitcher : public NodeAttribute
{
public:
Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name);
~Camera();
CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name);
~CameraSwitcher();
public:
@ -554,19 +554,28 @@ public:
return curves;
}
/** Model instance the curve is assigned to, this is always non-NULL */
const Model* TargetNode() const {
/** Model or NodeAttribute the curve is assigned to, this is always non-NULL
* and never an objects not deriving one of the two aforementioned classes.*/
const Object* Target() const {
return target;
}
/** Property of TargetNode() that is being animated*/
const Model* TargetAsModel() const {
return dynamic_cast<const Model*>(target);
}
const NodeAttribute* TargetAsNodeAttribute() const {
return dynamic_cast<const NodeAttribute*>(target);
}
/** Property of Target() that is being animated*/
const std::string& TargetProperty() const {
return prop;
}
private:
const Model* target;
const Object* target;
boost::shared_ptr<const PropertyTable> props;
AnimationCurveMap curves;

View File

@ -76,7 +76,7 @@ NodeAttribute::~NodeAttribute()
// ------------------------------------------------------------------------------------------------
Camera::Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name)
CameraSwitcher::CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name)
: NodeAttribute(id,element,doc,name)
{
const Scope& sc = GetRequiredScope(element);
@ -99,7 +99,7 @@ Camera::Camera(uint64_t id, const Element& element, const Document& doc, const s
// ------------------------------------------------------------------------------------------------
Camera::~Camera()
CameraSwitcher::~CameraSwitcher()
{
}