從網上下了個模型,匯出成.x檔案放程式裡後發現有些問題。雖然模型動作很多,但是所有動作都放到同乙個動畫集裡了。這樣導致的後果就是這個模型只能看不能用。。。
在經過對.x檔案格式分析後,發現可以修改下.x檔案來把所有動作分離出來,放到不同動畫集(animationset)裡去。理論上完全可以。於是便開始手動修改,像老黃牛般的改了乙個多小時,等到頭暈眼花的時侯,才發現手動修改不現實。乙個多小時才完成不到十分之一的工作。。。
於是再對.x進行了分析,發現完全可以寫個程式來進行所有的工作。學以至用,哈哈!從準備寫到最終完成,用了不到三個小時。事實證明,學程式確實有用!
以上都是廢話,哈哈,現在把分析.x得到的經驗總結一下。
1。動作集
animationset stand
2。animation
結構如下:
animation anim-object15
}object15是骨骼名,這個結構可以理解為:在這乙個動作集(比如stand)中,這乙個骨骼(object15)的動畫資訊。
3。animationkey
結構如下:
animationkey
animationkey
}。。。其它骨骼動畫資料
}。。。其它動畫集
//原.x檔案中所有動作都只用了乙個animationset
//通過此程式可分析資料並生成多個animationset
#include
#include
#include
using namespace std;
struct aniset;//
//全域性變數
string g_sin; //原始資料
string g_sframe; //框架資料
string g_stemp;
string g_sout; //重組後的資料
////函式前向宣告
/** 從檔案中讀取資料,並將資料存入記憶體
@param
sfile 源檔名
@param
sbuffer 儲存資料的緩衝
*/bool loaddatafromfile( string sfile, string& sbuffer );
/** 重組資料
*/void rebuilddata();
/** 從原始資料中搜尋子串
@param
skey 搜尋關鍵字
@param
posset 搜尋起點
@param
beg, end 搜尋範圍
*/void getsubstr( string skey, int beg, int end );
/** 把搜尋到的資料插入到最後輸出字串中
@param
skeyset animationset搜尋關鍵字
@param
skeybone animationkey搜尋起點
*/void inserttoanimationkey( string skeyset, string skeybone );
/** 將重組後的資料寫入檔案
*/void writetofile();
int main(void)
//從檔案中讀取資料
bool loaddatafromfile( string sfile, string& sbuffer )
//重組資料
void rebuilddata(),,
,,,,
,,,,
};string animationkey[29] =
","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
"","",
""};
for ( int i=0; i<11; i++ )
}//從源資料中獲得子串
void getsubstr( string skey, int beg, int end )
posbeg = pos+1;
for ( int i=0; ichar a[20];
//重新計算time
pos = 0;
string::size_type posst = 0;
for ( int i=0; i//插入nkeys行
itoa( end-beg+1, a, 10 );
string temp;
temp = " ";
temp += a;
temp += ";/n";
g_stemp.insert( 0, temp );
}void inserttoanimationkey( string skeyset, string skeybone )
g_sout.insert( pos+1, g_stemp );
}void writetofile()
Animations的使用(一)
animation的分類 一,tweened animations。旋轉,移動,伸展,淡出等效果。二,frame by frame animations。可建立乙個drawable序列,按照指定的時間間隔乙個個顯示。tweened animations分類 1,alpha 淡入淡出 2,scale ...
Android之Animations的使用
animations一般分為兩大類,一類是漸變的 tweened 如淡入淡出,旋轉,移動,縮放 另一類是frame by frame,就如電影一般由多張按照一定的時間間隔顯示。使用tweened animations的第一種使用步驟 1.建立乙個animationset物件,animationset...
微軟的 x檔案結構
xmesh 檔案結構 x file 模板解釋 選自direct8.1sdk,共有32個。animation 動作,是乙個完整的動作,包含乙個或幾個動畫鍵 animationkey 動作是指一塊骨骼 關節所變換的結果。包括兩部分 1 動畫鍵 animationkey 2 執行動作的骨骼名稱。anima...