CBaseMesh::MorphKeyFrame CMaxMesh::frameForChannel( int i, float timeIn ) { TimeValue time = SecToTicks(timeIn); #if defined(USEMORPHLIB) MaxMorphModifier maxMorphModifier = MaxMorphModifier(FindMorpherModifier(m_pINode)); MaxMorphChannel mmc = maxMorphModifier.GetMorphChannel(i); CBaseMesh::MorphKeyFrame frame; std::tstring cmdname(mmc.GetName()); frame.name = std::string(cmdname.begin(), cmdname.end()); frame.time = timeIn; Interval valid=FOREVER; frame.weight = mmc.GetMorphWeight(time); frame.totalWeight = mmc.GetProgressiveMorphWeight(0); #else MorphR3 * morpherModifier = (MorphR3*)FindMorpherModifier(m_pINode); morphChannel const & chanI = morpherModifier->chanBank[i]; CBaseMesh::MorphKeyFrame frame; std::tstring cmdname(chanI.mName.data()); frame.name = std::string(cmdname.begin(), cmdname.end()); frame.time = timeIn; Interval valid=FOREVER; chanI.cblock->GetValue(0, time, frame.weight, valid); frame.totalWeight = chanI.mTargetPercent; #endif return frame; }
int CMaxMesh::numMorphChannels() { #if defined(USEMORPHLIB) Modifier* m = FindMorpherModifier(m_pINode); if(m == NULL) return 0; MaxMorphModifier maxMorphModifier = MaxMorphModifier(m); int numMC = maxMorphModifier.NumMorphChannels(); int activeCt = 0; for(int i = 0; i < numMC; i++) { MaxMorphChannel mmc = maxMorphModifier.GetMorphChannel(i); if(mmc.IsActive() && _tcscmp(mmc.GetName(), L"- empty -")) activeCt++; } return activeCt; #else MorphR3 * morpherModifier = (MorphR3*)FindMorpherModifier(m_pINode); if( !morpherModifier ) { return 0; } int activeCount = 0; for(size_t i = 0; i < morpherModifier->chanBank.size(); i++) { morphChannel const & chanI = morpherModifier->chanBank[i]; if( chanI.mActive ) { activeCount++; } } return activeCount; #endif }
CBaseMesh::MorphKeyFrame CMaxMesh::frameForChannel( int i, float timeIn ) { TimeValue time = SecToTicks(timeIn); MorphR3 * morpherModifier = (MorphR3*)FindMorpherModifier(m_pINode); morphChannel const & chanI = morpherModifier->chanBank[i]; CBaseMesh::MorphKeyFrame frame; frame.name = chanI.mName.data(); frame.time = timeIn; Interval valid=FOREVER; chanI.cblock->GetValue(0, time, frame.weight, valid); frame.totalWeight = chanI.mTargetPercent; return frame; }
bool CMaxMesh::Create(INode *pINode, Mesh *pIMesh, bool bDelete) { // check for valid mesh if(pIMesh == 0) { theExporter.SetLastError("Invalid handle.", __FILE__, __LINE__); return false; } m_pINode = pINode; m_pIMesh = pIMesh; m_bDelete = bDelete; // recursively create materials if(!CreateMaterial(m_pINode->GetMtl())) return false; // build all normals if necessary m_pIMesh->checkNormals(TRUE); // precalculate the object transformation matrix m_tm = m_pINode->GetObjectTM(SecToTicks(theExporter.GetInterface()->GetCurrentTime())); // try to get the physique modifier m_pModifier = FindPhysiqueModifier(pINode); if(m_pModifier == 0) { // try to get the skin modifier m_pModifier = FindSkinModifier(pINode); if(m_pModifier == 0) { m_pModifier = FindMorpherModifier(pINode); if( m_pModifier == 0 ) { m_modifierType = MODIFIER_NONE; } m_modifierType = MODIFIER_MORPHER; } else { m_modifierType = MODIFIER_SKIN; } } else { m_modifierType = MODIFIER_PHYSIQUE; } return true; }
int CMaxMesh::numMorphChannels() { MorphR3 * morpherModifier = (MorphR3*)FindMorpherModifier(m_pINode); if( !morpherModifier ) { return 0; } int activeCount = 0; for( int i = 0; i < morpherModifier->chanBank.size(); i++ ) { morphChannel const & chanI = morpherModifier->chanBank[i]; if( chanI.mActive ) { activeCount++; } } return activeCount; }