青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Using Key?Framed Skeletal Animation(3)

Assuming you want more than one animation set loaded at once, you can even create a class that contains an array (or rather, a linked list) of cAnimationSet classes, which means that you can access a whole slew of animations with one interface! This class, called cAnimationCollection, is also derived from the cXParser class, so you can parse .X files directly from the class in which you'll be storing the animations.

Here's the class declaration for cAnimationCollection:

class cAnimationCollection : public cXParser
{
public:
DWORD m_NumAnimationSets;
cAnimationSet *m_AnimationSets;
protected:
// Parse an .X file object
BOOL ParseObject(IDirectXFileData *pDataObj,
IDirectXFileData *pParentDataObj,
DWORD Depth,
void **Data, BOOL Reference);
public:
cAnimationCollection();
~cAnimationCollection();
	BOOL Load(char *Filename);
void Free();
void Map(D3DXFRAME *RootFrame);
void Update(char *AnimationSetName, DWORD Time);
};

The details of each function in the cAnimationCollection class are not very important at this point so I'll get back to them in a bit. At this point, all you're interested in is reading in that animation data from an .X file. The custom .X parser contained in the cAnimationCollection class does just that, it loads the data from the Animation objects' data into the dizzying array of objects you've just seen.

For every AnimationSet object you encounter in the .X file being parsed, you need to allocate a cAnimationSet class and add it to the linked list of animation sets already loaded. The most current cAnimationSet object is stored at the start of the linked list, which makes it easy to determine which animation−set data you are currently using.

From here, you can appropriately parse the Animation objects. If you were to keep the most current cAnimationSet object at the start of your linked list, every following Animation object that you parse would belong to that animation−set object. The same goes for the AnimationKey objects, their data would belong to the first cAnimation object in the linked list.

I will skip the constructors and destructors for all the different classes because you only need them to clear and release each class's data. You're only interested in a couple functions, the first being cAnimationCollection::ParseObject, which deals with each animation object being parsed from an .X file.

The ParseObject function starts by checking whether the currently enumerated object is an AnimationSet. If it is, a new cAnimationSet object is allocated and linked to the list of objects, while the animation−set object is simultaneously named for further reference.

BOOL cAnimationCollection::ParseObject( 
IDirectXFileData *pDataObj,
IDirectXFileData *pParentDataObj,
DWORD Depth,
void **Data, BOOL Reference)
{
const GUID *Type = GetObjectGUID(pDataObj);
DWORD i;
	// Check if object is AnimationSet type
if(*Type == TID_D3DRMAnimationSet) {
// Create and link in a cAnimationSet object
cAnimationSet *AnimSet = new cAnimationSet();
AnimSet−>m_Next = m_AnimationSets;
m_AnimationSets = AnimSet;
		// Increase # of animation sets
m_NumAnimationSets++;
		// Set animation set name (set a default one if none)
if(!(AnimSet−>m_Name = GetObjectName(pDataObj)))
AnimSet−>m_Name = strdup("NoName");
}

As you can see, nothing special goes on with the animation set objects, you're merely allocating an object that will eventually hold the upcoming Animation data objects. Speaking of which, you want to parse the Animation objects next.

// Check if object is Animation type
if(*Type == TID_D3DRMAnimation && m_AnimationSets) {
// Add a cAnimation class to top−level cAnimationSet
cAnimation *Anim = new cAnimation();
Anim−>m_Next = m_AnimationSets−>m_Animations;
m_AnimationSets−>m_Animations = Anim;
	// Increase # of animations
m_AnimationSets−>m_NumAnimations++;
}

Again, nothing special going on there. In the preceding code, you're simply ensuring that there's a cAnimationSet object allocated at the start of the linked list. If there is, you can allocate and link a cAnimation object to the list in the cAnimationSet object.

While we're on the topic of the cAnimation object, the next bit of code retrieves the name of the frame instance located within the Animation object.

// Check if a frame reference inside animation object
if(*Type == TID_D3DRMFrame && Reference == TRUE && m_AnimationSets && m_AnimationSets−>m_Animations) {
// Make sure parent object is an Animation object
if(pParentDataObj && *GetObjectGUID(pParentDataObj) == TID_D3DRMAnimation) {
// Get name of frame and store it as animation
if(!(m_AnimationSets−>m_Animations−>m_Name = GetObjectName(pDataObj)))
m_AnimationSets−>m_Animations−>m_Name=strdup("NoName");
}
}

You can see in this code that only referenced frame objects are allowed in the Animation object, a fact that you can verify by checking the parent object's template GUID. Whew! So far this code is pretty easy, isn't it? Well, I don't want to burst your bubble, but the hardest is yet to come! In fact, the most difficult part of loading animation data from an .X file is loading the key data. Don't let me scare you away, though; the key data is nothing more than a time value and an array of values that represent the key data.

The remaining code in the ParseObject function checks to see which type of key data an AnimationKey object holds. Depending on the type of data, the code branches off and reads the data into the specific key objects (m_RotationKeys, m_TranslationKeys, m_ScaleKeys, and m_MatrixKeys) inside the current cAnimation object. Take a closer look to see how simple this code really is.

// Check if object is AnimationKey type
if(*Type == TID_D3DRMAnimationKey && m_AnimationSets && m_AnimationSets−>m_Animations) {
// Get a pointer to top−level animation object
cAnimation *Anim = m_AnimationSets−>m_Animations;
	// Get a data pointer
DWORD *DataPtr = (DWORD*)GetObjectData(pDataObj, NULL);
	// Get key type
DWORD Type = *DataPtr++;
	// Get # of keys to follow
DWORD NumKeys = *DataPtr++;

In addition to checking to see whether there are valid cAnimationSet and cAnimation objects at the start of the linked list of objects, the preceding code gets a pointer to the key data and pulls out the key type value and the number of keys to follow. Using the key type, the code then branches off to allocate the key−frame objects and load in the key data.

// Branch based on key type
switch(Type) {
case 0: // Rotation
delete [] Anim−>m_RotationKeys;
Anim−>m_NumRotationKeys = NumKeys;
Anim−>m_RotationKeys = new cAnimationQuaternionKey[NumKeys];
	for(i=0;i<NumKeys;i++) {
// Get time
Anim−>m_RotationKeys[i].m_Time = *DataPtr++;
		if(Anim−>m_RotationKeys[i].m_Time > m_AnimationSets−>m_Length)
m_AnimationSets−>m_Length = Anim−>m_RotationKeys[i].m_Time;
		// Skip # keys to follow (should be 4)
DataPtr++;
		// Get rotational values
		float *fPtr = (float*)DataPtr;
		Anim−>m_RotationKeys[i].m_quatKey.w = *fPtr++;
Anim−>m_RotationKeys[i].m_quatKey.x = *fPtr++;
Anim−>m_RotationKeys[i].m_quatKey.y = *fPtr++;
Anim−>m_RotationKeys[i].m_quatKey.z = *fPtr++;
		DataPtr+=4;
}
	break;

You'll recall from earlier in this chapter that rotation keys use quaternion values. These values are stored in w, x, y, z order; to make sure you use the proper values, you must read them into the key's quaternion object appropriately.

Next comes the code to load in the scaling and translation keys, which both use vectors to store the x−, y−, and z−axis information.

case 1: // Scaling
delete [] Anim−>m_ScaleKeys;
Anim−>m_NumScaleKeys = NumKeys;
Anim−>m_ScaleKeys = new cAnimationVectorKey[NumKeys];
	for(i=0;i<NumKeys;i++) {
// Get time
Anim−>m_ScaleKeys[i].m_Time = *DataPtr++;
		if(Anim−>m_ScaleKeys[i].m_Time > m_AnimationSets−>m_Length)
m_AnimationSets−>m_Length = Anim−>m_ScaleKeys[i].m_Time;
		// Skip # keys to follow (should be 3)
DataPtr++;
		// Get scale values
D3DXVECTOR3 *vecPtr = (D3DXVECTOR3*)DataPtr;
Anim−>m_ScaleKeys[i].m_vecKey = *vecPtr;
DataPtr+=3;
}
	break;
case 2: // Translation
delete [] Anim−>m_TranslationKeys;
Anim−>m_NumTranslationKeys = NumKeys;
Anim−>m_TranslationKeys = new cAnimationVectorKey[NumKeys];
	for(i=0;i<NumKeys;i++) {
// Get time
Anim−>m_TranslationKeys[i].m_Time = *DataPtr++;
		if(Anim−>m_TranslationKeys[i].m_Time > m_AnimationSets−>m_Length)
m_AnimationSets−>m_Length = Anim−>m_TranslationKeys[i].m_Time;
		// Skip # keys to follow (should be 3)
DataPtr++;
		// Get translation values
D3DXVECTOR3 *vecPtr = (D3DXVECTOR3*)DataPtr;
Anim−>m_TranslationKeys[i].m_vecKey = *vecPtr;
DataPtr+=3;
}
	break;

Last is the code to read an array of transformation matrix keys.

	case 4: // Transformation matrix
delete [] Anim−>m_MatrixKeys;
Anim−>m_NumMatrixKeys = NumKeys;
Anim−>m_MatrixKeys = new cAnimationMatrixKey[NumKeys];
		for(i=0;i<NumKeys;i++) {
// Get time
Anim−>m_MatrixKeys[i].m_Time = *DataPtr++;
			if(Anim−>m_MatrixKeys[i].m_Time > m_AnimationSets−>m_Length)
m_AnimationSets−>m_Length = Anim−>m_MatrixKeys[i].m_Time;
			// Skip # keys to follow (should be 16)
DataPtr++;
			// Get matrix values
D3DXMATRIX *mPtr = (D3DXMATRIX *)DataPtr;
Anim−>m_MatrixKeys[i].m_matKey = *mPtr;
DataPtr += 16;
}
		break;
}
}

Okay now, take a quick breather and look back at what you've just accomplished. So far, you've processed every AnimationSet, Animation, and AnimationKey object (not to mention referenced Frame objects that contain the bones' names), plus you've loaded the key objects full of the animation data. You're almost ready to start animating!

Almost is right; there is one small step left: matching the animation objects to their respective bone objects.


posted on 2008-04-24 19:27 lovedday 閱讀(284) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            红桃视频欧美| 亚洲国产99| 欧美在线综合视频| 欧美在线播放| 亚洲国产精品ⅴa在线观看| 亚洲大胆视频| 欧美日韩精品免费观看视一区二区 | 在线欧美影院| 亚洲国产精品视频| 欧美亚日韩国产aⅴ精品中极品| 亚洲欧美色一区| 欧美在线综合| 亚洲另类黄色| 亚洲欧美一级二级三级| 伊人成人在线| 一本久道久久综合中文字幕| 国产偷国产偷精品高清尤物| 欧美激情第一页xxx| 欧美日韩国产免费| 久久精品国产2020观看福利| 美女主播一区| 午夜视频在线观看一区二区三区| 久久精品欧美日韩精品| 一本久久综合亚洲鲁鲁| 欧美亚洲免费电影| 亚洲蜜桃精久久久久久久| 亚洲先锋成人| 亚洲精品极品| 久久国产精品一区二区三区四区| 日韩视频一区二区在线观看 | 亚洲精品欧美激情| 亚洲欧美色婷婷| 日韩图片一区| 久久久久久欧美| 午夜精品久久久久久久99热浪潮 | 国产日韩欧美在线观看| 91久久精品国产91性色tv| 国产一区二区三区最好精华液| 亚洲清纯自拍| 亚洲国产裸拍裸体视频在线观看乱了| 国产精品99久久久久久有的能看| 亚洲精品黄网在线观看| 久久久九九九九| 亚洲欧美国产一区二区三区| 欧美成人免费网站| 久久综合伊人77777| 国产精品欧美一区二区三区奶水 | 99re6这里只有精品视频在线观看| 黄色一区二区三区| 亚洲欧美日韩中文在线制服| 亚洲一区二区三区高清不卡| 欧美精品网站| 亚洲人成网站999久久久综合| 在线免费观看视频一区| 久久国产色av| 久久精品亚洲| 国产一区二区成人| 亚洲欧美中文日韩v在线观看| 亚洲一区二区在线播放| 欧美日韩中文字幕日韩欧美| 亚洲日韩成人| 一本大道久久a久久精二百| 欧美第十八页| 最近中文字幕mv在线一区二区三区四区| 狠狠色噜噜狠狠狠狠色吗综合| 午夜欧美大尺度福利影院在线看| 午夜亚洲一区| 国产亚洲欧美色| 久久久久久久久伊人| 看片网站欧美日韩| 亚洲国产婷婷香蕉久久久久久99 | 欧美一区二区三区免费视| 午夜亚洲伦理| 激情丁香综合| 六月婷婷一区| 亚洲人成小说网站色在线| 99精品视频网| 国产精品福利在线| 亚洲欧美在线播放| 久久综合色天天久久综合图片| 亚洲国产精品精华液2区45| 欧美jjzz| 亚洲综合另类| 欧美阿v一级看视频| 亚洲欧洲偷拍精品| 欧美午夜精彩| 欧美一区二区三区日韩| 欧美大片免费观看| 在线视频欧美一区| 国产日本欧美一区二区三区在线 | 久久久视频精品| 亚洲精品视频在线播放| 欧美一区二区三区喷汁尤物| 在线观看日韩av| 欧美日韩免费观看中文| 欧美一区二区三区的| 亚洲经典在线看| 久久国产精品99国产| 亚洲精选视频在线| 国产美女诱惑一区二区| 蜜臀av国产精品久久久久| 亚洲午夜在线| 亚洲国产精品久久久久秋霞蜜臀| 香蕉尹人综合在线观看| 亚洲日本中文字幕免费在线不卡| 国产精品免费看| 欧美激情aⅴ一区二区三区| 小黄鸭精品密入口导航| 最新成人av网站| 久久人人爽人人爽爽久久| 亚洲图片欧洲图片av| 亚洲第一福利视频| 国产精品有限公司| 欧美日韩国产影片| 久热精品视频| 亚洲制服av| 中文国产成人精品| 亚洲黄色免费电影| 久久视频国产精品免费视频在线| 在线亚洲欧美视频| 亚洲精品少妇| 亚洲国产高清aⅴ视频| 韩日午夜在线资源一区二区| 国产精品五区| 欧美日韩精品免费观看视一区二区 | 国产日韩欧美在线播放不卡| 欧美视频在线观看| 欧美韩日一区| 免费在线看一区| 久久人人97超碰国产公开结果| 欧美专区18| 久久久久国产精品人| 欧美在线网址| 久久激情视频久久| 欧美一级久久| 久久精品2019中文字幕| 欧美一区2区三区4区公司二百 | 欧美国产精品人人做人人爱| 久久免费国产| 免费观看成人www动漫视频| 久久嫩草精品久久久久| 可以看av的网站久久看| 久久天堂av综合合色| 久久躁日日躁aaaaxxxx| 久久亚洲免费| 欧美激情中文字幕一区二区| 欧美激情欧美激情在线五月| 亚洲电影自拍| 99精品99久久久久久宅男| 一区二区欧美视频| 亚洲性xxxx| 欧美一区二区精品| 久久综合伊人77777| 欧美极品一区二区三区| 欧美日韩一区二区在线视频| 国产精品黄色在线观看| 国产视频在线观看一区 | 欧美色视频日本高清在线观看| 欧美视频中文在线看| 国产女主播在线一区二区| 国产在线精品一区二区夜色| 亚洲国产精品嫩草影院| 国产精品99久久久久久白浆小说| 亚洲一级网站| 久久噜噜亚洲综合| 亚洲国产精品一区二区尤物区| 夜夜爽夜夜爽精品视频| 性欧美激情精品| 欧美成人中文| 国产精品xxxxx| **性色生活片久久毛片| 一区二区三区欧美在线观看| 午夜在线播放视频欧美| 欧美高清在线视频| 夜夜爽99久久国产综合精品女不卡| 翔田千里一区二区| 欧美国产先锋| 国产三级精品在线不卡| 亚洲精选成人| 老司机免费视频久久| 亚洲裸体俱乐部裸体舞表演av| 性欧美长视频| 欧美日本一道本在线视频| 国产一区av在线| 一区二区三区视频在线播放| 欧美wwwwww| 欧美一区二区三区播放老司机 | 欧美亚洲免费| 国产精品jizz在线观看美国| 亚洲丶国产丶欧美一区二区三区| 亚洲一区二区精品在线观看| 亚洲电影免费观看高清完整版| 亚洲女人av| 欧美日韩美女在线| 亚洲国产精品一区二区三区| 久久久亚洲欧洲日产国码αv| 一区二区三区黄色| 欧美精品色综合| 亚洲精品日韩在线观看| 久久综合久久久久88|