Direct高级动画制作 第九章 关键帧渐变动画的运用 vs2008 directx 9.0c

书本的上内容,运行起来在vs2008 和 dx 9.0c上有点问题。现改正如下:

class cMorphAnimationCollection : public cXParser
{
  protected:  (只写改正的部分)
    // Parse an .X file for mass and spring data
    BOOL ParseObject(ID3DXFileData *pDataObj,
                       ID3DXFileData *pParentDataObj,
                       DWORD Depth,
                       void **Data, BOOL Reference);
};
BOOL cMorphAnimationCollection::ParseObject(                  \
                    ID3DXFileData *pDataObj,               \
                    ID3DXFileData *pParentDataObj,         \
                    DWORD Depth,                              \
                    void **Data, BOOL Reference)
{
 // const GUID *Type = GetObjectGUID(pDataObj);
  GUID Type;
  pDataObj->GetType(&Type);
  // Read in animation set data
  if(Type == MorphAnimationSet) {

    // Create and link in a cMorphAnimationSet object
    cMorphAnimationSet *AnimSet = new cMorphAnimationSet();
    AnimSet->m_Next = m_AnimationSets;
    m_AnimationSets = AnimSet;

    // Increase # of animation sets
    m_NumAnimationSets++;

    // Set the animation set's name
    AnimSet->m_Name = GetObjectName(pDataObj);

    // Get data pointer
    DWORD *Ptr = (DWORD*)GetObjectData(pDataObj, NULL);

    // Get # of keys and allocate array of keyframe objects
    AnimSet->m_NumKeys = *Ptr++;
    AnimSet->m_Keys = new cMorphAnimationKey[AnimSet->m_NumKeys];

    // Get key data - time and mesh names
    char *PtrTemp=(char*)Ptr;
    for(DWORD i=0;im_NumKeys;i++) {
      //char *t=PtrTemp;
      AnimSet->m_Keys[i].m_Time = *Ptr++;
      PtrTemp=(char*)Ptr;
     // char *g=(char*)PtrTemp;
      AnimSet->m_Keys[i].m_MeshName =strdup((char*)PtrTemp);
//      AnimSet->m_Keys[i].m_MeshName=PtrTemp;
        PtrTemp+=strlen(PtrTemp);
        Ptr+=2;//这个感觉有点牵强  但是谁如果有更好的办法  就更好了
    //  strcpy(AnimSet->m_Keys[i].m_MeshName,(char*)*Ptr++);
    }
    // Store length of animation
    AnimSet->m_Length = AnimSet->m_Keys[AnimSet->m_NumKeys-1].m_Time;
  }
  return ParseChildObjects(pDataObj, Depth, Data, Reference);
}





你可能感兴趣的:(Direct高级动画制作 第九章 关键帧渐变动画的运用 vs2008 directx 9.0c)