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

天行健 君子當自強而不息

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 閱讀(287) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(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>
            亚洲国产精品久久久久| 国产精品盗摄一区二区三区| 国产日韩av在线播放| 在线一区二区三区四区五区| 亚洲一级电影| 久久久久久一区二区| 亚洲精品自在在线观看| 欧美韩日亚洲| 亚洲精品在线观| 亚洲欧美在线磁力| 国产一区二区三区久久| 久久亚洲私人国产精品va| 欧美成人高清| 一区二区三区高清视频在线观看| 欧美日韩视频一区二区三区| 一区二区国产精品| 久久蜜桃精品| 亚洲六月丁香色婷婷综合久久| 欧美精品97| 亚洲一区二区三区激情| 久久久国产一区二区| 91久久精品网| 欧美日韩在线播| 亚洲欧美另类综合偷拍| 久热这里只精品99re8久| 亚洲国产免费| 欧美日韩亚洲一区二区三区在线观看| 亚洲小视频在线观看| 久热综合在线亚洲精品| 欧美成人免费小视频| 亚洲精品在线三区| 亚洲一区二区三区777| 另类综合日韩欧美亚洲| 日韩视频在线观看| 国产乱人伦精品一区二区| 久久综合狠狠综合久久综合88| 91久久亚洲| 午夜在线精品偷拍| 亚洲精品久久久蜜桃| 国产欧美日韩在线| 欧美日韩在线综合| 久久蜜桃精品| 香蕉免费一区二区三区在线观看| 亚洲国产精品成人久久综合一区| 久久不见久久见免费视频1| 亚洲国产一区二区视频| 国产午夜久久| 国产精品成人在线观看| 欧美黄色网络| 免费欧美日韩国产三级电影| 久久国产精品99久久久久久老狼| 亚洲丰满在线| 欧美11—12娇小xxxx| 亚洲性线免费观看视频成熟| 亚洲国产精品福利| 伊大人香蕉综合8在线视| 国产日韩欧美综合| 亚洲精品美女免费| 亚洲国产婷婷| 欧美福利电影网| 乱人伦精品视频在线观看| 久久国产精品99久久久久久老狼| 中文一区二区在线观看| 日韩视频一区二区三区| 亚洲精品美女在线观看| 亚洲国产成人久久| 亚洲激情在线| 亚洲黄色av一区| 在线国产亚洲欧美| 亚洲国产成人精品视频| 亚洲日本无吗高清不卡| 日韩视频二区| 亚洲一区二区三区777| 亚洲综合色婷婷| 亚洲一区欧美| 久久久久国产精品一区三寸| 久久激情网站| 免费亚洲婷婷| 亚洲国产专区| 亚洲婷婷综合色高清在线| 亚洲免费中文| 久久国产视频网站| 亚洲麻豆国产自偷在线| 亚洲美女中文字幕| 一区二区毛片| 亚洲精品中文字幕在线| 国产日本亚洲高清| 在线精品视频在线观看高清| 亚洲激情偷拍| 亚洲影院色无极综合| 久久av红桃一区二区小说| 裸体一区二区| 亚洲伦理在线观看| 亚洲欧美激情一区二区| 另类尿喷潮videofree | 欧美激情视频在线播放| 亚洲精品久久久久久一区二区| 欧美成人精品不卡视频在线观看 | 久久激情五月激情| 久久一区二区三区四区| 欧美国产一区视频在线观看| 欧美美女日韩| 老司机亚洲精品| 欧美激情一二三区| 欧美电影电视剧在线观看| 欧美精品大片| 国产精品女主播| 国产日韩欧美精品| 91久久在线观看| 中文欧美日韩| 久久久国产精彩视频美女艺术照福利| 国产日韩在线看| 黑人一区二区三区四区五区| 国产午夜精品理论片a级大结局| 国产精品福利久久久| 国产午夜精品一区二区三区欧美 | 久久美女艺术照精彩视频福利播放| 亚洲二区视频在线| 久久国产夜色精品鲁鲁99| 欧美日韩在线综合| 亚洲免费大片| 欧美国产日韩一二三区| 午夜亚洲精品| 欧美极品影院| 亚洲片区在线| 久久精品女人的天堂av| 一本不卡影院| 精品二区视频| 欧美亚洲视频在线看网址| 亚洲日本理论电影| 亚洲丰满在线| 欧美在线黄色| 国产九九精品视频| 新67194成人永久网站| 蜜臀va亚洲va欧美va天堂| 亚洲一区中文| 在线一区欧美| 欧美理论电影网| 亚洲黄色性网站| 欧美激情久久久久| 久久久成人网| 精品成人在线观看| 久久久另类综合| 欧美一区二区免费| 国产亚洲欧美另类一区二区三区| 亚洲一区二区毛片| 一区二区欧美在线观看| 欧美午夜激情视频| 午夜伦欧美伦电影理论片| 亚洲精选中文字幕| 欧美刺激午夜性久久久久久久| 亚洲国产日韩欧美在线99| 欧美成人影音| 欧美精品播放| 亚洲综合视频1区| 99re热精品| 国产精品久久久| 欧美一级专区免费大片| 欧美亚洲一区三区| 韩日精品视频| 亚洲福利电影| 一区二区三区 在线观看视频 | 亚洲第一视频网站| 欧美日韩黄色大片| 亚洲网站视频福利| 欧美日韩成人综合在线一区二区| 久久不射网站| 亚洲黄网站在线观看| 亚洲精品国产拍免费91在线| 欧美不卡高清| 午夜国产精品视频免费体验区| 亚洲一区二区综合| 伊人激情综合| 日韩视频在线观看国产| 国产精品日日做人人爱 | 久久在线免费观看视频| 欧美成人精品h版在线观看| 亚洲欧美成人一区二区在线电影 | 欧美大片在线观看一区| 午夜亚洲影视| 免费欧美网站| 欧美一区1区三区3区公司| 久久精品99无色码中文字幕 | 91久久一区二区| 亚洲视频你懂的| 精品动漫av| 中文欧美在线视频| 亚洲黄色av| 久久狠狠一本精品综合网| 亚洲一区激情| 欧美精品成人一区二区在线观看| 欧美一区二区三区在线视频| 欧美激情视频一区二区三区在线播放 | 欧美国产乱视频| 亚洲一品av免费观看| 久久久久欧美精品| 欧美一区二区三区视频在线观看| 欧美精品激情在线观看| 久久久久久穴| 国产欧美日韩中文字幕在线|