diff options
author | Sukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com> | 2011-07-24 00:49:26 +0400 |
---|---|---|
committer | Sukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com> | 2011-07-24 00:49:26 +0400 |
commit | c22f26d2032b7116477e6a378407a10b6d7e3276 (patch) | |
tree | d16d29d4cd89e4915a8ffc782d8c6d0513f64e07 | |
parent | 682cc631613dd8dcdcfec30246e191cec93f4006 (diff) |
Material Hardness Animation Import Complete.
-rw-r--r-- | source/blender/collada/AnimationImporter.cpp | 65 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 16 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.h | 5 |
3 files changed, 46 insertions, 40 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index e6c35b3ffb7..eaf6835420e 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -906,32 +906,29 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , } } - if ( animType->material != 0){ - Material *ma = give_current_material(ob, 1); - if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1); - else act = ma->adt->action; - - ListBase *AnimCurves = &(act->curves); - - const COLLADAFW::InstanceGeometryPointerArray& nodeGeoms = node->getInstanceGeometries(); - for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) { - const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings(); - for (unsigned int j = 0; j < matBinds.getCount(); j++) { - const COLLADAFW::Material *mat = (COLLADAFW::Material *) FW_object_map[matBinds[j].getReferencedMaterial()]; - const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) FW_object_map[mat->getInstantiatedEffect()]; - COLLADAFW::CommonEffectPointerArray commonEffects = ef->getCommonEffects(); - for (unsigned int k = 0; k < commonEffects.getCount(); k++) { - COLLADAFW::EffectCommon *efc = commonEffects[k]; - if((animType->material & MATERIAL_SHININESS) != 0){ - const COLLADAFW::FloatOrParam *shin = &(efc->getShininess()); - const COLLADAFW::UniqueId& listid = shin->getAnimationList(); - Assign_float_animations( listid, AnimCurves , "specular_hardness" ); - } - } - } - } - } + if ( animType->material != 0){ + Material *ma = give_current_material(ob, 1); + if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1); + else act = ma->adt->action; + + ListBase *AnimCurves = &(act->curves); + const COLLADAFW::InstanceGeometryPointerArray& nodeGeoms = node->getInstanceGeometries(); + for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) { + const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings(); + for (unsigned int j = 0; j < matBinds.getCount(); j++) { + const COLLADAFW::UniqueId & matuid = matBinds[j].getReferencedMaterial(); + const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) (FW_object_map[matuid]); + const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects(); + COLLADAFW::EffectCommon *efc = commonEffects[0]; + if((animType->material & MATERIAL_SHININESS) != 0){ + const COLLADAFW::FloatOrParam *shin = &(efc->getShininess()); + const COLLADAFW::UniqueId& listid = shin->getAnimationList(); + Assign_float_animations( listid, AnimCurves , "specular_hardness" ); + } + } + } + } } @@ -940,11 +937,6 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map) { AnimMix *types = new AnimMix(); - //types->transform = INANIMATE ; - //types->light = INANIMATE; - //types->camera = INANIMATE; - //types->material = INANIMATE; - //types->texture = INANIMATE; const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); @@ -999,15 +991,12 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) { const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings(); for (unsigned int j = 0; j < matBinds.getCount(); j++) { - const COLLADAFW::Material *mat = (COLLADAFW::Material *) FW_object_map[matBinds[j].getReferencedMaterial()]; - const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) FW_object_map[mat->getInstantiatedEffect()]; - COLLADAFW::CommonEffectPointerArray commonEffects = ef->getCommonEffects(); - for (unsigned int k = 0; k < commonEffects.getCount(); k++) { - COLLADAFW::EffectCommon *efc = commonEffects[k]; - types->material = setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS); - } + const COLLADAFW::UniqueId & matuid = matBinds[j].getReferencedMaterial(); + const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) (FW_object_map[matuid]); + const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects(); + COLLADAFW::EffectCommon *efc = commonEffects[0]; + types->material = setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS); } - } return types; } diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 2ff791eb91d..d4eeb594922 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -537,7 +537,10 @@ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; this->uid_material_map[cmat->getUniqueId()] = ma; - this->FW_object_map[cmat->getUniqueId()] = cmat; + this->matUidforEffect = &(cmat->getUniqueId()); + /*COLLADAFW::Material * matCopy = new COLLADAFW::Material(&cmat); + this->FW_object_map[cmat->getUniqueId()] = matCopy; + *///matForEff = cmat; return true; } @@ -722,13 +725,21 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect ) return true; const COLLADAFW::UniqueId& uid = effect->getUniqueId(); + if (uid_effect_map.find(uid) == uid_effect_map.end()) { fprintf(stderr, "Couldn't find a material by UID.\n"); return true; } Material *ma = uid_effect_map[uid]; - + std::map<COLLADAFW::UniqueId, Material*>::iterator iter; + for(iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ ) + { + if ( iter->second == ma ) { + this->FW_object_map[iter->first] = effect; + break; + } + } COLLADAFW::CommonEffectPointerArray common_efs = effect->getCommonEffects(); if (common_efs.getCount() < 1) { fprintf(stderr, "Couldn't find <profile_COMMON>.\n"); @@ -739,6 +750,7 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect ) COLLADAFW::EffectCommon *ef = common_efs[0]; write_profile_COMMON(ef, ma); this->FW_object_map[effect->getUniqueId()] = effect; + return true; } diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index ce7a64a600d..8af0996885b 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -38,6 +38,8 @@ #include "COLLADAFWController.h" #include "COLLADAFWMorphController.h" #include "COLLADAFWSkinController.h" +#include "COLLADAFWEffectCommon.h" + #include "BKE_object.h" @@ -155,9 +157,12 @@ private: std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map; std::vector<const COLLADAFW::VisualScene*> vscenes; std::vector<Object*> libnode_ob; + + const COLLADAFW::UniqueId *matUidforEffect; 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 |