• <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>

            天行健 君子當(dāng)自強(qiáng)而不息

            網(wǎng)格模型高級(jí)技術(shù)(4)

            為了使一個(gè).x文件產(chǎn)生動(dòng)畫,必須至少提供一個(gè)動(dòng)畫集,每個(gè)動(dòng)畫集都應(yīng)具有一個(gè)對(duì)某個(gè)框架的引用。模板 AnimationSet用來定義動(dòng)畫集:

            Contains one or more Animation objects. Each animation within an animation set has the same time at any given point. Increasing the animation set's time increases the time for all the animations it contains.

            template AnimationSet
            {
            < 3D82AB50-62DA-11cf-AB39-0020AF71E433 >
            [ Animation < 3D82AB4F-62DA-11cf-AB39-0020AF71E433 > ]
            }

            Where:

            • [ Animation < 3D82AB4F-62DA-11cf-AB39-0020AF71E433 > ] - Optional animation template.

            模板Animation的定義如下:

            Contains one or more Animation objects. Each animation within an animation set has the same time at any given point. Increasing the animation set's time increases the time for all the animations it contains.

            template AnimationSet
            {
            < 3D82AB50-62DA-11cf-AB39-0020AF71E433 >
            [ Animation < 3D82AB4F-62DA-11cf-AB39-0020AF71E433 > ]
            }

            Where:

            • [ Animation < 3D82AB4F-62DA-11cf-AB39-0020AF71E433 > ] - Optional animation template.

            很顯然,Animation是一個(gè)完全開放的模板,一般情況下,用模板AnimationKey來填充它,模板AnimationKey的定義如下:

            Defines a set of animation keys. A matrix key is useful for sets of animation data that need to be represented as transformation matrices.

            template AnimationKey
            {
            < 10DD46A8-775B-11CF-8F52-0040333594A3 >
            DWORD keyType;
            DWORD nKeys;
            array TimedFloatKeys keys[nKeys];
            }

            Where:

            • keyType - Specifies whether the keys are rotation, scale, position, or matrix keys (using the integers 0, 1, 2, or 4, respectively).
            • nKeys - Number of keys.
            • keys - An array of keys.

            在模板AnimationKey中,keyType可取的值是0、1、2、4。

            0表示旋轉(zhuǎn)鍵,在.x文件中,用一個(gè)四元數(shù)來實(shí)現(xiàn)模型的旋轉(zhuǎn),旋轉(zhuǎn)值使用4個(gè)分量w、x、y、z來存儲(chǔ),也就是說,此時(shí)變換數(shù)組的大小是4,它依次存儲(chǔ)四元數(shù)的4個(gè)分量。

            1表示縮放鍵,可以使用這種類型的關(guān)鍵幀實(shí)現(xiàn)模型的縮放,此時(shí)變換數(shù)組的大小是3,它們分別對(duì)應(yīng)x、y、z軸的縮放值。

            2表示平移鍵,使用3個(gè)分量實(shí)現(xiàn)模型的平移,此時(shí)變換數(shù)組的大小是3,它們分別對(duì)應(yīng)沿x、y、z軸的平移值。

            4表示變換矩陣鍵,此時(shí)關(guān)鍵幀的變換數(shù)組使用16個(gè)浮點(diǎn)數(shù)來實(shí)現(xiàn)該模型的各種變換。因?yàn)榫仃嚳梢詫?shí)現(xiàn)模型的平移、旋轉(zhuǎn)、縮放以及它們的組合變換。

            模板AnimationKey用來定義一組動(dòng)畫關(guān)鍵幀,而模板TimeFloatKeys用來定義每個(gè)動(dòng)畫關(guān)鍵幀:

            Defines a set of floats and a positive time used in animations.

            template TimedFloatKeys 
            {
            < F406B180-7B3B-11cf-8F52-0040333594A3 >
            DWORD time;
            FloatKeys tfkeys;
            }

            Where:

            • tfkeys - See FloatKeys.

            Defines an array of floating-point numbers (floats) and the number of floats in that array. This is used for defining sets of animation keys.

            template FloatKeys
            {
            < 10DD46A9-775B-11cf-8F52-0040333594A3 >
            DWORD nValues;
            array float values[nValues];
            }
            • nValues - Number of floats.
            • values[nValues] - Array of float values.

            我們?cè)赾ube_3.x的基礎(chǔ)上添加動(dòng)畫部分形成cube_4.x,該動(dòng)畫集定義了立方體繞y軸旋轉(zhuǎn),增加部分如下:

            AnimationSet AnimationSet0 {  //動(dòng)畫集
            Animation Animation0 { //動(dòng)畫
            {CubeFrame} //引用上面的立方體框架,表示下面的動(dòng)畫是針對(duì)立方體框架的
            		AnimationKey {                //動(dòng)畫鍵   沿Y軸旋轉(zhuǎn)網(wǎng)格
            0; // Rotation keys
            10; // 9 keys
            			1000; 4; 0.000000, 0.15643448, 0.000000, 0.98768836;;,
            2000; 4; 0.000000, 0.30901700, 0.000000, 0.95105654;;,
            3000; 4; 0.000000, 0.45399046, 0.000000, 0.89100653;;,
            4000; 4; 0.000000, 0.58778530, 0.000000, 0.80901694;;,
            5000; 4; 0.000000, 0.70710671, 0.000000, 0.70710683;;,
            6000; 4; 0.000000, 0.80901694, 0.000000, 0.58778530;;,
            7000; 4; 0.000000, 0.89100653, 0.000000, 0.45399052;;,
            8000; 4; 0.000000, 0.95105654, 0.000000, 0.30901697;;,
            9000; 4; 0.000000, 0.98768836, 0.000000, 0.15643449;;,
            10000; 4; 0.000000, 1.0000000, 0.000000, 0.00000000;;;
            }
            }
            }

            這里一共定義了10個(gè)關(guān)鍵幀,在第10個(gè)關(guān)鍵幀時(shí)回到初始位置開始新一輪的動(dòng)畫。{CubeFrame}表示該動(dòng)畫集是對(duì)框架CubeFrame進(jìn)行的操作。

            我們?cè)赾ube_3.x的基礎(chǔ)上添加縮放動(dòng)畫形成cube_5.x:

            AnimationSet AnimationSet0 {   //動(dòng)畫集
            Animation Animation0 { //動(dòng)畫
            {CubeFrame} // Use the frame containing the cube.
            		AnimationKey {                 //動(dòng)畫鍵, 放大和縮小網(wǎng)格
            1; // Scaling keys
            9; // 9 keys
            			1000; 3; 1.000000, 1.000000, 1.000000;;,
            2000; 3; 0.800000, 0.800000, 0.800000;;,
            3000; 3; 0.600000, 0.600000, 0.600000;;,
            4000; 3; 0.400000, 0.400000, 0.400000;;,
            5000; 3; 0.200000, 0.200000, 0.200000;;,
            6000; 3; 0.400000, 0.400000, 0.400000;;,
            7000; 3; 0.600000, 0.600000, 0.600000;;,
            8000; 3; 0.800000, 0.800000, 0.800000;;,
            9000; 3; 1.000000, 1.000000, 1.000000;;;
            }
            }
            }

            效果圖:

             

            我們也可以在cube_3.x的基礎(chǔ)上添加一個(gè)沿y軸移動(dòng)的動(dòng)畫形成cube_6.x:

            AnimationSet AnimationSet0 {   //動(dòng)畫集
            Animation Animation0 { //動(dòng)畫
            {CubeFrame} // Use the frame containing the cube.
            		AnimationKey {                 //動(dòng)畫鍵   沿Y軸方向移動(dòng)網(wǎng)格
            2; // Position keys
            19; // 9 keys
            1000; 3; 0.000000, -5.000000, 0.000000;;,
            2000; 3; 0.000000, -4.000000, 0.000000;;,
            3000; 3; 0.000000, -3.000000, 0.000000;;,
            4000; 3; 0.000000, -2.000000, 0.000000;;,
            5000; 3; 0.000000, -1.000000, 0.000000;;,
            6000; 3; 0.000000, 0.000000, 0.000000;;,
            7000; 3; 0.000000, 1.000000, 0.000000;;,
            8000; 3; 0.000000, 2.000000, 0.000000;;,
            9000; 3; 0.000000, 3.000000, 0.000000;;,
            10000; 3; 0.000000, 4.000000, 0.000000;;,
            11000; 3; 0.000000, 5.000000, 0.000000;;,
            12000; 3; 0.000000, 4.000000, 0.000000;;,
            12000; 3; 0.000000, 3.000000, 0.000000;;,
            13000; 3; 0.000000, 2.000000, 0.000000;;,
            14000; 3; 0.000000, 1.000000, 0.000000;;,
            15000; 3; 0.000000, 0.000000, 0.000000;;,
            16000; 3; 0.000000, -1.000000, 0.000000;;,
            17000; 3; 0.000000, -2.000000, 0.000000;;,
            18000; 3; 0.000000, -3.000000, 0.000000;;,
            19000; 3; 0.000000, -4.000000, 0.000000;;,
            }
            }
            }

            效果圖:

             

            包含在.x文件中的動(dòng)畫通常用來實(shí)現(xiàn)模型不同部分之間的相對(duì)運(yùn)動(dòng),對(duì)于一個(gè)模型整體上的運(yùn)動(dòng),應(yīng)該是在程序中通過其世界變換矩陣來實(shí)現(xiàn)。

             

            蒙皮信息

            一個(gè)動(dòng)畫網(wǎng)格模型很多情況下可能涉及到蒙皮信息,模板XSkinMeshHeader僅對(duì)于具有蒙皮信息的網(wǎng)格模型有效,它用來記錄網(wǎng)格模型的蒙皮信息,該模板的定義如下:

            This template is instantiated on a per-mesh basis only in meshes that contain exported skinning information. The purpose of this template is to provide information about the nature of the skinning information that was exported.

            template XSkinMeshHeader 
            {
            < 3CF169CE-FF7C-44ab-93C0-F78F62D172E2 >
            WORD nMaxSkinWeightsPerVertex;
            WORD nMaxSkinWeightsPerFace;
            WORD nBones;
            }

            Where:

            • nMaxSkinWeightsPerVertex - Maximum number of transforms that affect a vertex in the mesh.
            • nMaxSkinWeightsPerFace - Maximum number of unique transforms that affect the three vertices of any face.
            • nBones - Number of bones that affect vertices in this mesh.

            在一個(gè)具有蒙皮信息的網(wǎng)格模型中,可能出現(xiàn)模板SkinWeights的n個(gè)實(shí)例,n等于該網(wǎng)格模型中骨骼的數(shù)量。該模板的每個(gè)實(shí)例都定義了一個(gè)具體的骨骼對(duì)于相應(yīng)頂點(diǎn)的影響權(quán)重,該模板的具體定義如下:

            This template is instantiated on a per-mesh basis. Within a mesh, a sequence of n instances of this template will appear, where n is the number of bones (X file frames) that influence the vertices in the mesh. Each instance of the template basically defines the influence of a particular bone on the mesh. There is a list of vertex indices, and a corresponding list of weights.

            template SkinWeights 
            {
            < 6F0D123B-BAD2-4167-A0D0-80224F25FABB >
            STRING transformNodeName;
            DWORD nWeights;
            array DWORD vertexIndices[nWeights];
            array float weights[nWeights];
            Matrix4x4 matrixOffset;
            }

            Where:

            • The name of the bone whose influence is being defined is transformNodeName, and nWeights is the number of vertices affected by this bone.
            • The vertices influenced by this bone are contained in vertexIndices, and the weights for each of the vertices influenced by this bone are contained in weights.
            • The matrix matrixOffset transforms the mesh vertices to the space of the bone. When concatenated to the bone's transform, this provides the world space coordinates of the mesh as affected by the bone.

             

            下載cube_1.x ~ cube6.x


            posted on 2008-05-27 15:44 lovedday 閱讀(2019) 評(píng)論(1)  編輯 收藏 引用

            評(píng)論

            # re: 網(wǎng)格模型高級(jí)技術(shù)(4) 2013-09-06 17:29 abc

            講的太好了  回復(fù)  更多評(píng)論   


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            公告

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關(guān)鏈接

            搜索

            最新評(píng)論

            精品久久久久久国产| 国产精品久久99| 亚洲国产香蕉人人爽成AV片久久| 9191精品国产免费久久| 久久久精品久久久久久| 欧美伊人久久大香线蕉综合| 午夜精品久久久久久久久| 99久久久精品免费观看国产 | 久久国产精品无码网站| 狠狠色丁香久久婷婷综合_中| 99精品久久久久久久婷婷| 久久香蕉一级毛片| 麻豆久久久9性大片| 99久久免费国产特黄| 亚洲精品97久久中文字幕无码| 久久精品aⅴ无码中文字字幕不卡| 99久久精品费精品国产 | 久久人人爽人人爽人人片AV不| 久久精品无码一区二区无码| 久久久久无码精品| 日本免费久久久久久久网站| 日本五月天婷久久网站| 久久精品国产99久久丝袜| 亚洲中文字幕无码久久2017| 久久综合九色综合欧美就去吻| 久久精品国产亚洲网站| 伊人久久精品无码av一区| 亚洲а∨天堂久久精品9966| 国产精品成人99久久久久| 国产精品欧美久久久久天天影视| 国产精品久久久久久久app| 久久精品国产亚洲AV不卡| 99国产欧美精品久久久蜜芽| 久久这里有精品| 久久国产亚洲精品| 久久久久久午夜精品| 一本大道久久东京热无码AV| 精品久久人人妻人人做精品| 嫩草影院久久99| 精品久久人人妻人人做精品| 人妻丰满?V无码久久不卡|