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

天行健 君子當自強而不息

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>
            葵司免费一区二区三区四区五区| 欧美黑人多人双交| 午夜精品久久久久影视 | 嫩草成人www欧美| 激情丁香综合| 久久蜜臀精品av| 亚洲欧美国产精品桃花| 国产精品久久久久久户外露出| 一本色道久久88亚洲综合88| 亚洲黄色高清| 久久婷婷一区| 一区二区在线视频| 免费在线播放第一区高清av| 久久久久久久97| 亚洲国产成人精品视频| 牛牛影视久久网| 欧美岛国激情| 国产精品99久久久久久www| 日韩网站在线| 国产精品久在线观看| 久久av在线看| 久久一区激情| 亚洲精品孕妇| 亚洲社区在线观看| 国产精品一区毛片| 久久精品九九| 欧美成人国产| 亚洲午夜精品久久| 午夜综合激情| 亚洲国产精品久久久久秋霞影院| 亚洲国产导航| 欧美性事在线| 久久久久久香蕉网| 欧美h视频在线| 亚洲免费视频观看| 久久国产精品网站| 亚洲精品一区二区三区av| 99综合在线| 欧美成人免费在线| 日韩一级精品视频在线观看| 国产精品嫩草久久久久| 久久久在线视频| 欧美不卡视频一区| 亚洲欧美综合另类中字| 美国十次成人| 欧美影院精品一区| 欧美成人情趣视频| 欧美一级在线亚洲天堂| 欧美成年人视频网站| 亚洲欧美日韩久久精品| 久久综合久久久久88| 香蕉乱码成人久久天堂爱免费 | 亚洲高清av| 国产精品欧美激情| 亚洲高清三级视频| 国产亚洲女人久久久久毛片| 亚洲精品乱码久久久久久| 国产一区二区三区黄视频| 亚洲美女视频网| **性色生活片久久毛片| 亚洲一区二区欧美日韩| 亚洲精品影院| 久久久久国产精品一区三寸| 亚洲欧美日韩国产综合精品二区| 蜜臀av国产精品久久久久| 久久se精品一区二区| 欧美色视频一区| 亚洲风情在线资源站| 精品成人国产| 亚洲男人av电影| 亚洲午夜精品久久久久久浪潮 | 国产精品亚洲综合久久| 亚洲日本欧美| 亚洲人成网站精品片在线观看| 欧美一区二区视频97| 午夜在线精品| 国产精品看片资源| 一本一本a久久| 中日韩美女免费视频网址在线观看| 欧美在线视频免费播放| 久久超碰97人人做人人爱| 国产精品免费区二区三区观看| 亚洲精选在线| 一本色道久久88综合亚洲精品ⅰ | 午夜亚洲福利| 欧美一级淫片aaaaaaa视频| 国产精品久久福利| 亚洲午夜未删减在线观看| 亚洲一区精品视频| 欧美丝袜一区二区三区| 日韩午夜在线| 亚洲欧美国产va在线影院| 国产精品国码视频| 亚洲综合日韩中文字幕v在线| 亚洲尤物精选| 久久精品国产精品亚洲精品| 1769国产精品| 久久天天躁狠狠躁夜夜av| 噜噜噜在线观看免费视频日韩 | 亚洲欧洲在线一区| 噜噜爱69成人精品| 亚洲高清二区| 在线视频亚洲欧美| 欧美日韩激情网| 一区二区三区欧美在线观看| 亚洲永久免费av| 国产精品亚洲美女av网站| 久久精品91久久香蕉加勒比| 欧美bbbxxxxx| 99精品热视频只有精品10| 欧美午夜精品久久久久久浪潮| 亚洲欧美福利一区二区| 免费av成人在线| 日韩天堂av| 国产精品午夜视频| 欧美在线一二三| 亚洲国产欧美一区二区三区久久 | 国产精品丝袜91| 欧美中文在线观看| 亚洲国产合集| 亚洲欧美日韩一区在线| 狠狠色狠色综合曰曰| 欧美黄色视屏| 午夜精品久久久久久99热软件 | 欧美视频一区二区| 欧美综合二区| 日韩一区二区电影网| 久久―日本道色综合久久| 亚洲精品国产精品国自产在线 | 欧美猛交免费看| 亚洲欧美日韩国产一区二区| 欧美成人午夜影院| 亚洲在线视频网站| 亚洲国产91| 国产欧美一区二区在线观看| 蜜乳av另类精品一区二区| 亚洲视频精选在线| 欧美激情第10页| 久久精品视频亚洲| 亚洲一区999| 亚洲人成在线播放网站岛国| 国产精品永久免费观看| 欧美国产三级| 久久免费高清视频| 亚洲欧美日韩精品| 日韩视频永久免费| 欧美韩日亚洲| 麻豆久久婷婷| 久久久久九九九| 午夜精品亚洲| 亚洲一区二区三区高清不卡| 最新国产成人在线观看| 国产综合在线看| 国产精品社区| 欧美先锋影音| 欧美日韩福利视频| 欧美日韩在线影院| 久久久免费av| 久久不见久久见免费视频1| 亚洲欧美韩国| 亚洲视频每日更新| 一本到12不卡视频在线dvd| 亚洲国产精品视频| 激情文学综合丁香| 国产一区二区视频在线观看| 国产精品久久久久秋霞鲁丝 | 国产精品系列在线| 国产精品久久一区二区三区| 欧美日韩亚洲不卡| 欧美日韩国产综合久久| 欧美国产欧美亚洲国产日韩mv天天看完整 | 日韩亚洲欧美在线观看| 亚洲国产精品一区制服丝袜| 精品成人一区二区三区四区| 狠狠久久亚洲欧美| 在线不卡亚洲| 最新中文字幕亚洲| 亚洲免费观看| 在线亚洲欧美视频| 正在播放亚洲| 亚洲男女自偷自拍| 欧美亚洲一区二区在线观看| 欧美在线观看视频在线| 久久久久女教师免费一区| 久久亚洲精品一区| 欧美成人有码| 亚洲精品免费一区二区三区| 亚洲精品一区二区三区婷婷月| 亚洲精品免费在线观看| 99视频在线观看一区三区| 亚洲视频在线观看一区| 午夜日韩在线观看| 久久精品一级爱片| 欧美mv日韩mv亚洲| 欧美日韩一本到| 国产欧美丝祙| 亚洲国产精品第一区二区| 99热精品在线观看| 欧美一区成人| 欧美电影在线观看完整版|