IgfxObject::IgfxObject(hIMDL mdl) : m_ref(0), m_flag(0), m_mdl(mdl), m_alpha(1.0f), m_pCalModel(0), m_pObjMats(0), m_wrldTrans(0,0,0), m_wrldScl(1,1,1), m_parent(0), m_parentBoneID(-1) { if(!m_mdl) return; memset(m_lights, 0, sizeof(m_lights)); m_mdl->AddRef(); CalCoreModel *pCalCoreModel = m_mdl->GetCalCoreModel(); //create Cal Model instance (if we are using Cal3D model) if(pCalCoreModel) { m_pCalModel = new CalModel; if(!m_pCalModel) { LogMsg(LOG_FILE, L"OBJCreate", L"Unable to allocate Cal3D Model"); return; } if(!m_pCalModel->create(pCalCoreModel)) { tCHAR errStr[MAXCHARBUFF]; mbstowcs(errStr, CalError::getLastErrorText().c_str(), MAXCHARBUFF); LogMsg(LOG_FILE, L"OBJCreate", errStr); return; } // attach all meshes to the model s32 meshId; for(meshId = 0; meshId < pCalCoreModel->getCoreMeshCount(); meshId++) { m_pCalModel->attachMesh(meshId); } // set the material set of the whole model m_pCalModel->setMaterialSet(0); m_pCalModel->update(0); } //create object materials and derive them from model u32 numMat = m_mdl->GetNumMaterial(); if(numMat > 0) { m_pObjMats = (gfxObjMat *)MemAlloc(sizeof(gfxObjMat)*numMat); if(!m_pObjMats) { LogMsg(LOG_FILE, L"OBJCreate", L"Unable to allocate Object Materials"); return; } } ResetMaterial(); MtxIdentity(&m_axis); }
CCal3DSceneNode::CCal3DSceneNode( CCal3DModel* model, ISceneNode* parent, ISceneManager* manager, s32 id, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale ) : ISceneNode( parent, manager, id, position, rotation, scale ) { OverrideMaterial = false; LastUpdateTime = 0; TimeScale = 1.0f; Model = model; CalCoreModel* coreModel = 0; if ( Model != 0 ) { Model->grab(); BoundingBox = Model->getBoundingBox(); coreModel = Model->getCalCoreModel(); } if ( coreModel != 0 ) { calModel = new CalModel( coreModel ); s32 meshCount = coreModel->getCoreMeshCount(); for ( s32 i=0; i<meshCount; i++ ) { calModel->attachMesh(i); } calModel->setMaterialSet(0); calModel->update(0.0f); } else { calModel = 0; } draw_mode = DM_DEFAULT; draw_bbox = false; }