Light Animation Identification.

This commit is contained in:
2011-07-03 11:07:34 +00:00
parent 46d12b480e
commit a632091176
4 changed files with 26 additions and 9 deletions

View File

@@ -675,7 +675,8 @@ void AnimationImporter:: Assign_transform_animations(std::vector<float>* frames,
void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
std::map<COLLADAFW::UniqueId, Object*>& object_map )
std::map<COLLADAFW::UniqueId, Object*>& object_map,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
{
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
@@ -684,7 +685,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
if ( ! is_object_animated(node) ) return ;
if ( ! is_object_animated(node, FW_object_map) ) return ;
char joint_path[200];
@@ -776,13 +777,11 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node ,
ob->rotmode = ROT_MODE_EUL;
}
}
}
}
//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
bool AnimationImporter::is_object_animated ( const COLLADAFW::Node * node )
bool AnimationImporter::is_object_animated ( const COLLADAFW::Node * node , std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map )
{
bool exists = false;
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
@@ -800,7 +799,22 @@ bool AnimationImporter::is_object_animated ( const COLLADAFW::Node * node )
break;
}
}
const COLLADAFW::InstanceLightPointerArray& nodeLights = node->getInstanceLights();
for (unsigned int i = 0; i < nodeLights.getCount(); i++) {
const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()];
const COLLADAFW::Color *col = &(light->getColor());
const COLLADAFW::UniqueId& listid = col->getAnimationList();
//check if color has animations
if (animlist_map.find(listid) == animlist_map.end()) continue ;
else
{
exists = true;
break;
}
}
return exists;
}

View File

@@ -37,6 +37,7 @@
#include "COLLADAFWAnimationList.h"
#include "COLLADAFWNode.h"
#include "COLLADAFWUniqueId.h"
#include "COLLADAFWLight.h"
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
@@ -97,9 +98,10 @@ public:
void translate_Animations_NEW ( COLLADAFW::Node * Node ,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
std::map<COLLADAFW::UniqueId, Object*>& object_map );
std::map<COLLADAFW::UniqueId, Object*>& object_map ,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map);
bool is_object_animated ( const COLLADAFW::Node * node ) ;
bool is_object_animated ( const COLLADAFW::Node * node , std::map<COLLADAFW::UniqueId,const COLLADAFW::Object*> FW_object_map ) ;
void Assign_transform_animations(std::vector<float>* frames,

View File

@@ -252,7 +252,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
//for (i = 0; i < 4; i++)
//ob =
anim_importer.translate_Animations_NEW(node, root_map, object_map);
anim_importer.translate_Animations_NEW(node, root_map, object_map, FW_object_map);
COLLADAFW::NodePointerArray &children = node->getChildNodes();
for (i = 0; i < children.getCount(); i++) {
@@ -1051,6 +1051,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
}
this->uid_lamp_map[light->getUniqueId()] = lamp;
this->FW_object_map[light->getUniqueId()] = light;
return true;
}

View File

@@ -157,7 +157,7 @@ private:
std::vector<Object*> libnode_ob;
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map;
};
#endif