- fbx: NodeAttribute can now be target for AnimCurveNode.
- fbx: rename Camera -> CameraSwitcher.pull/14/head
parent
cab713b4c5
commit
d5c05c7d84
|
@ -134,7 +134,8 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
|
||||||
}{
|
}{
|
||||||
|
|
||||||
// find target node
|
// 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) {
|
BOOST_FOREACH(const Connection* con, conns) {
|
||||||
|
|
||||||
|
@ -143,13 +144,14 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Object* ob = con->DestinationObject();
|
const Object* const ob = con->DestinationObject();
|
||||||
if(!ob) {
|
if(!ob) {
|
||||||
DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring",&element);
|
DOMWarning("failed to read destination object for AnimationCurveNode->Model link, ignoring",&element);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
target = dynamic_cast<const Model*>(ob);
|
ai_assert(dynamic_cast<const Model*>(ob) || dynamic_cast<const NodeAttribute*>(ob));
|
||||||
|
target = ob;
|
||||||
if(!target) {
|
if(!target) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +161,7 @@ AnimationCurveNode::AnimationCurveNode(uint64_t id, const Element& element, cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!target) {
|
if(!target) {
|
||||||
DOMError("failed to resolve target model for animation node",&element);
|
DOMError("failed to resolve target Model/NodeAttribute for AnimationCurveNode",&element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -944,8 +944,11 @@ private:
|
||||||
BOOST_FOREACH(const AnimationCurveNode* node, nodes) {
|
BOOST_FOREACH(const AnimationCurveNode* node, nodes) {
|
||||||
ai_assert(node);
|
ai_assert(node);
|
||||||
|
|
||||||
const Model* model = node->TargetNode();
|
const Model* const model = dynamic_cast<const Model*>(node->Target());
|
||||||
ai_assert(model);
|
// this can happen - it could also be a NodeAttribute (i.e. for camera animations)
|
||||||
|
if(!model) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& name = FixNodeName(model->Name());
|
const std::string& name = FixNodeName(model->Name());
|
||||||
node_map[name].push_back(node);
|
node_map[name].push_back(node);
|
||||||
|
@ -1006,7 +1009,8 @@ private:
|
||||||
|
|
||||||
na->mNodeName.Set(kv.first);
|
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
|
// if a particular transformation is not given, grab it from
|
||||||
// the corresponding node to meet the semantics of aiNodeAnim,
|
// the corresponding node to meet the semantics of aiNodeAnim,
|
||||||
|
|
|
@ -467,6 +467,11 @@ const Object* LazyObject::Get(bool dieOnError)
|
||||||
object.reset(new MeshGeometry(id,element,name,doc));
|
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)) {
|
else if (!strncmp(obtype,"Model",length)) {
|
||||||
object.reset(new Model(id,element,doc,name));
|
object.reset(new Model(id,element,doc,name));
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,12 +172,12 @@ private:
|
||||||
|
|
||||||
|
|
||||||
/** DOM base class for FBX camera settings attached to a node */
|
/** DOM base class for FBX camera settings attached to a node */
|
||||||
class Camera : public NodeAttribute
|
class CameraSwitcher : public NodeAttribute
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name);
|
||||||
~Camera();
|
~CameraSwitcher();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -554,19 +554,28 @@ public:
|
||||||
return curves;
|
return curves;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Model instance the curve is assigned to, this is always non-NULL */
|
/** Model or NodeAttribute the curve is assigned to, this is always non-NULL
|
||||||
const Model* TargetNode() const {
|
* and never an objects not deriving one of the two aforementioned classes.*/
|
||||||
|
const Object* Target() const {
|
||||||
return target;
|
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 {
|
const std::string& TargetProperty() const {
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const Model* target;
|
const Object* target;
|
||||||
boost::shared_ptr<const PropertyTable> props;
|
boost::shared_ptr<const PropertyTable> props;
|
||||||
AnimationCurveMap curves;
|
AnimationCurveMap curves;
|
||||||
|
|
||||||
|
|
|
@ -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)
|
: NodeAttribute(id,element,doc,name)
|
||||||
{
|
{
|
||||||
const Scope& sc = GetRequiredScope(element);
|
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()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue