Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mp3butcher committed Mar 18, 2017
1 parent 1354419 commit 8e7dd69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cal3d/examples/miniviewer_gl/src/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ bool Viewer::onInit()
m_calModel->setMaterialSet(0);
std::cout << "Disable internal." << std::endl;
m_calModel->disableInternalData();
//m_calModel->getMorphTargetMixer()->m(0 ,1.0f,0,10.00,true)
m_calModel->getMorphTargetMixer()->blend(0, 1.0f, 0, 1.00, true);//ApplyWeightToMorphMesh("MyMiku_1_5_1_20091010_Face_10_mouth_laugh",1.0);

m_calModel->getMorphTargetMixer()->blend(0, 1.0f, 0, 1.00, true);

// set initial animation state
if (m_calCoreModel->getCoreAnimationCount() > 0)
Expand Down
42 changes: 18 additions & 24 deletions cal3d/src/cal3d/morphtargetmixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,24 @@ bool CalMorphTargetMixer::clear(int id, float delay)
for (itr=tracks.begin(); itr!=tracks.end(); ++itr)
{
const CalCoreMorphTrack *track = &(*itr);
ApplyWeightToMorphMesh(track->getMorphID(), 0.0f);
CalMesh * targetmesh = m_pModel->getVectorMesh()[track->getTargetMesh()];
std::vector<CalSubmesh*>& submeshes= targetmesh->getVectorSubmesh();

if(track->getNumTargetSubMeshes()==0)
{
for(int i=0; i<targetmesh->getSubmeshCount(); i++)
{
submeshes[i]->setMorphTargetWeight(track->getMorphID(), 0);
}
}
else
{
for(int i=0; i<track->getNumTargetSubMeshes(); i++)
{
submeshes[track->getTargetSubMesh(i)]->setMorphTargetWeight(track->getMorphID(), 0);

}
}
}

mAnimList.erase(mAnimList.begin() + index);
Expand Down Expand Up @@ -505,7 +522,6 @@ void CalMorphTargetMixer::SetTrackWeights(const CalCoreAnimatedMorph& morph, Mor

weight *= alpha;

// ApplyWeightToMorphMesh(track->getMorphName(), weight);
CalMesh * targetmesh = m_pModel->getVectorMesh()[track->getTargetMesh()];
std::vector<CalSubmesh*>& submeshes= targetmesh->getVectorSubmesh();

Expand Down Expand Up @@ -608,25 +624,3 @@ float CalMorphTargetMixer::CalcKeyframeWeight(const std::vector<CalCoreMorphKeyf
return (MapRangeValue(elapsedTime, startTime, endTime, startWeight, endWeight));
}

//////////////////////////////////////////////////////////////////////////
void CalMorphTargetMixer::ApplyWeightToMorphMesh(const unsigned int & morphMeshName,
float trackWeight)
{
//Apply the given weight to the morph mesh.

//TODO. This is pretty ugly. Need a better way to find the right CalSubMesh
//to set the morph target weight on.

std::vector<CalMesh*> meshVec = m_pModel->getVectorMesh();
std::vector<CalMesh*>::iterator meshItr;
for (meshItr=meshVec.begin(); meshItr!=meshVec.end(); ++meshItr)
{
std::vector<CalSubmesh*> subMeshVec = (*meshItr)->getVectorSubmesh();
std::vector<CalSubmesh*>::iterator subMeshitr;
for (subMeshitr=subMeshVec.begin(); subMeshitr!=subMeshVec.end(); ++subMeshitr)
{
(*subMeshitr)->setMorphTargetWeight(morphMeshName, trackWeight);
}
}
}
//****************************************************************************//
1 change: 0 additions & 1 deletion cal3d/src/cal3d/morphtargetmixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class CAL3D_API CalMorphTargetMixer

void SetTrackWeights(const CalCoreAnimatedMorph& morph, MorphAnimData& data);

void ApplyWeightToMorphMesh(const unsigned int &morphMeshName, float trackWeight);
};

#endif
Expand Down

0 comments on commit 8e7dd69

Please sign in to comment.