Beispiel #1
0
//======================
// 表情をブレンドで適用
//======================
void cPMDFace::blendFace( Vector3 *pvec3Vertices, float fRate )
{
	if( !m_pFaceVertices )	return;

	PMD_FaceVtx		*pVertex = m_pFaceVertices;
	unsigned long	ulIndex;
	for( unsigned long i = 0 ; i < m_ulNumVertices ; i++, pVertex++ )
	{
		ulIndex = pVertex->ulIndex;
		Vector3Lerp( &pvec3Vertices[ulIndex], &pvec3Vertices[ulIndex], &pVertex->vec3Pos, fRate );
	}
}
Beispiel #2
0
	Vector3 cCurveWithTime::GetPositionByTime(float e_fTime)
	{
		if( e_fTime <= 0.f )
		{
			return m_OriginalPointList[0];
		}
		assert(e_fTime>=0.f&&"time is smaller than 0");
		assert(m_FinalTimeList.size()&&"there is no any time data");

		Vector3	l_Vector3;
		int	l_iNum = (int)m_FinallyPointList.size();
		//first time is 0,neglect it
		float	l_fPerviousTime = 0.f;
		Vector3	l_PerviousPos = this->m_OriginalPointList[0];
		//check time is over last time and it's loop,if it is,let time be the right between range
		float	l_fLastTime = this->m_FinalTimeList[l_iNum-1];
		if(e_fTime>m_FinalTimeList[l_iNum-1]&&this->m_bCurveLoop)
		{
			if( l_fLastTime != 0.f )
				e_fTime = UT::GetFloatModulus(e_fTime,l_fLastTime);
		}
		for( int i=1;i<l_iNum;++i )
		{
			float	l_fCurrentTime = m_FinalTimeList[i];
			Vector3	l_vCurrentPos = this->m_FinallyPointList[i];
			if( l_fCurrentTime>=e_fTime )
			{
				this->m_iCurrentPointIndex = i-1;
				float	l_fTimeDis = l_fCurrentTime-l_fPerviousTime;
				//the time  is though closet point,LERP
				float	l_fStepThough = 1-((l_fCurrentTime-e_fTime)/l_fTimeDis);
				m_fCurrentLERPTime = l_fStepThough;
				//end point minus step distance
				Vector3	l_vCurrentPos = Vector3Lerp(l_PerviousPos,m_FinallyPointList[i],l_fStepThough);
				if(this->m_bCalculateAngle)
				{
					//so weired here must minus 180.
					this->m_fCurrentPosToNextPointAngle = GetAngleByFinalListIndex(m_iCurrentPointIndex);
				}
				return l_vCurrentPos;
			}
			l_PerviousPos = l_vCurrentPos;
			l_fPerviousTime = l_fCurrentTime;
		}
		this->m_iCurrentPointIndex = l_iNum-1;
		return m_FinallyPointList[l_iNum-1];
	}