diff options
Diffstat (limited to 'source/gameengine/Ketsji/BL_Action.cpp')
-rw-r--r-- | source/gameengine/Ketsji/BL_Action.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index f55d1120a50..ff1f800a626 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -43,6 +43,10 @@ extern "C" { #include "BKE_action.h" #include "RNA_access.h" #include "RNA_define.h" + +// Needed for material IPOs +#include "BKE_material.h" +#include "DNA_material_types.h" } BL_Action::BL_Action(class KX_GameObject* gameobj) @@ -169,6 +173,31 @@ bool BL_Action::Play(const char* name, sg_contr->SetObject(m_obj->GetSGNode()); } + // Now try materials + if (m_obj->GetBlenderObject()->totcol==1) { + Material *mat = give_current_material(m_obj->GetBlenderObject(), 1); + sg_contr = BL_CreateMaterialIpo(m_action, mat, 0, m_obj, kxscene->GetSceneConverter()); + if (sg_contr) { + m_sg_contr_list.push_back(sg_contr); + m_obj->GetSGNode()->AddSGController(sg_contr); + sg_contr->SetObject(m_obj->GetSGNode()); + } + } else { + Material *mat; + STR_HashedString matname; + + for (int matidx = 1; matidx <= m_obj->GetBlenderObject()->totcol; ++matidx) { + mat = give_current_material(m_obj->GetBlenderObject(), matidx); + matname = mat->id.name; + sg_contr = BL_CreateMaterialIpo(m_action, mat, matname.hash(), m_obj, kxscene->GetSceneConverter()); + if (sg_contr) { + m_sg_contr_list.push_back(sg_contr); + m_obj->GetSGNode()->AddSGController(sg_contr); + sg_contr->SetObject(m_obj->GetSGNode()); + } + } + } + // Extra controllers if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT) { |