[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38640] branches/soc-2011-pepper/source/ blender/collada: Material Hardness Animation Import Complete.
Sukhitha Jayathilake
pr.jayathilake at gmail.com
Sat Jul 23 22:49:26 CEST 2011
Revision: 38640
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38640
Author: phabtar
Date: 2011-07-23 20:49:26 +0000 (Sat, 23 Jul 2011)
Log Message:
-----------
Material Hardness Animation Import Complete.
Modified Paths:
--------------
branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-07-23 18:59:18 UTC (rev 38639)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp 2011-07-23 20:49:26 UTC (rev 38640)
@@ -906,32 +906,29 @@
}
}
- 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 @@
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 @@
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;
}
Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp 2011-07-23 18:59:18 UTC (rev 38639)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp 2011-07-23 20:49:26 UTC (rev 38640)
@@ -537,7 +537,10 @@
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 @@
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 @@
COLLADAFW::EffectCommon *ef = common_efs[0];
write_profile_COMMON(ef, ma);
this->FW_object_map[effect->getUniqueId()] = effect;
+
return true;
}
Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h 2011-07-23 18:59:18 UTC (rev 38639)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h 2011-07-23 20:49:26 UTC (rev 38640)
@@ -38,7 +38,9 @@
#include "COLLADAFWController.h"
#include "COLLADAFWMorphController.h"
#include "COLLADAFWSkinController.h"
+#include "COLLADAFWEffectCommon.h"
+
#include "BKE_object.h"
#include "TransformReader.h"
@@ -155,9 +157,12 @@
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
More information about the Bf-blender-cvs
mailing list