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

            Codejie's C++ Space

            Using C++

            .x練習(xí) - 建立Mesh

            ??? 終于寫好了供練習(xí)用的.x文件,只是靜態(tài)Mesh內(nèi)容,以后要在這個基礎(chǔ)上添加Animation內(nèi)容的。顯示如下:
            test.x_ok.jpg
            ??? 這里是.x文件內(nèi)容:
            xof?0303txt?0032

            template?Frame?{
            ?
            <3d82ab46-62da-11cf-ab39-0020af71e433>
            ?[]
            }

            template?Matrix4x4?{
            ?
            <f6f23f45-7686-11cf-8f52-0040333594a3>
            ?array?FLOAT?matrix[16];
            }

            template?FrameTransformMatrix?{
            ?
            <f6f23f41-7686-11cf-8f52-0040333594a3>
            ?Matrix4x4?frameMatrix;
            }

            template?Vector?{
            ?
            <3d82ab5e-62da-11cf-ab39-0020af71e433>
            ?FLOAT?x;
            ?FLOAT?z;
            ?FLOAT?y;
            }

            template?MeshFace?{
            ?
            <3d82ab5f-62da-11cf-ab39-0020af71e433>
            ?DWORD?nFaceVertexIndices;
            ?array?DWORD?faceVertexIndices[nFaceVertexIndices];
            }

            template?Mesh?{
            ?
            <3d82ab44-62da-11cf-ab39-0020af71e433>
            ?DWORD?nVertices;
            ?array?Vector?vertices[nVertices];
            ?DWORD?nFaces;
            ?array?MeshFace?faces[nFaces];
            ?[]
            }

            template?MeshNormals?{
            ?
            <f6f23f43-7686-11cf-8f52-0040333594a3>
            ?DWORD?nNormals;
            ?array?Vector?normals[nNormals];
            ?DWORD?nFaceNormals;
            ?array?MeshFace?faceNormals[nFaceNormals];
            }

            template?Coords2d?{
            ?
            <f6f23f44-7686-11cf-8f52-0040333594a3>
            ?FLOAT?u;
            ?FLOAT?v;
            }

            template?MeshTextureCoords?{
            ?
            <f6f23f40-7686-11cf-8f52-0040333594a3>
            ?DWORD?nTextureCoords;
            ?array?Coords2d?textureCoords[nTextureCoords];
            }

            template?ColorRGBA?{
            ?
            <35ff44e0-6c7c-11cf-8f52-0040333594a3>
            ?FLOAT?red;
            ?FLOAT?green;
            ?FLOAT?blue;
            ?FLOAT?alpha;
            }

            template?IndexedColor?{
            ?
            <1630b820-7842-11cf-8f52-0040333594a3>
            ?DWORD?index;
            ?ColorRGBA?indexColor;
            }

            template?MeshVertexColors?{
            ?
            <1630b821-7842-11cf-8f52-0040333594a3>
            ?DWORD?nVertexColors;
            ?array?IndexedColor?vertexColors[nVertexColors];
            }

            template?VertexElement?{
            ?
            <f752461c-1e23-48f6-b9f8-8350850f336f>
            ?DWORD?Type;
            ?DWORD?Method;
            ?DWORD?Usage;
            ?DWORD?UsageIndex;
            }

            template?DeclData?{
            ?
            <bf22e553-292c-4781-9fea-62bd554bdd93>
            ?DWORD?nElements;
            ?array?VertexElement?Elements[nElements];
            ?DWORD?nDWords;
            ?array?DWORD?data[nDWords];
            }
            Frame?Root?{
            ????FrameTransformMatrix?{
            ????1.000000,?0.000000,?0.000000,?0.000000,
            ????0.000000,?1.000000,?0.000000,?0.000000,
            ????0.000000,?0.000000,?1.000000,?0.000000,
            ????0.000000,?0.000000,?0.000000,?1.000000;;
            ????}

            ????Frame?SubFrame?{
            ????????FrameTransformMatrix?{
            ????????1.000000,?0.000000,?0.000000,?0.000000,
            ????????0.000000,?1.000000,?0.000000,?0.000000,
            ????????0.000000,?0.000000,?1.000000,?0.000000,
            ????????0.000000,?0.000000,?0.000000,?1.000000;;
            ????????}????
            ????
            ????????Mesh?MeshObj?{
            ????????????12;
            ????????????0.000000;?0.000000;?1.000000;,
            ????????????1.000000;?0.000000;?1.000000;,
            ????????????1.000000;?1.000000;?1.000000;,
            ????????????0.000000;?1.000000;?1.000000;,
            ????????????0.000000;?0.000000;?0.000000;,
            ????????????1.000000;?0.000000;?0.000000;,
            ????????????1.000000;?1.000000;?0.000000;,
            ????????????0.000000;?1.000000;?0.000000;,
            ????????????0.000000;?0.000000;?-1.000000;,
            ????????????1.000000;?0.000000;?-1.000000;,
            ????????????1.000000;?1.000000;?-1.000000;,
            ????????????0.000000;?1.000000;?-1.000000;;
            ????????????
            ????????????20;
            ????????????3;?0,?4,?1;,
            ????????????3;?4,?5,?1;,
            ????????????3;?1,?2,?0;,
            ????????????3;?2,?3,?0;,
            ????????????3;?6,?2,?5;,
            ????????????3;?2,?1,?5;,
            ????????????3;?3,?2,?7;,
            ????????????3;?2,?6,?7;,
            ????????????3;?7,?4,?3;,
            ????????????3;?4,?0,?3;,
            ????????????3;?4,?8,?5;,
            ????????????3;?5,?8,?9;,
            ????????????3;?5,?9,?6;,
            ????????????3;?9,?10,?6;,
            ????????????3;?6,?10,?11;,
            ????????????3;?7,?6,?11;,
            ????????????3;?7,?11,?8;,
            ????????????3;?4,?7,?8;,
            ????????????3;?8,?10,?9;,
            ????????????3;8,?11,?10;;
            ????????????
            ????????????MeshNormals?{
            ????????????????12;
            ????????????????-0.333333;?-0.333333;?0.333333;,
            ????????????????0.333333;?-0.333333;?0.333333;,
            ????????????????0.333333;?0.333333;?0.333333;,
            ????????????????-0.333333;?0.333333;?0.333333;,
            ????????????????-0.500000;?-0.500000;?0.000000;,
            ????????????????0.500000;?-0.500000;?0.000000;,
            ????????????????0.500000;?0.500000;?0.000000;,
            ????????????????-0.500000;?0.500000;?0.000000;,
            ????????????????-0.333333;?-0.333333;?-0.333333;,
            ????????????????0.333333;?-0.333333;?-0.333333;,
            ????????????????0.333333;?0.333333;?-0.333333;,
            ????????????????-0.333333;?0.333333;?-0.333333;,
            ????????????????
            ????????????????20;
            ????????????????3;?0,?4,?1;,
            ????????????????3;?4,?5,?1;,
            ????????????????3;?1,?2,?0;,
            ????????????????3;?2,?3,?0;,
            ????????????????3;?6,?2,?5;,
            ????????????????3;?2,?1,?5;,
            ????????????????3;?3,?2,?7;,
            ????????????????3;?2,?6,?7;,
            ????????????????3;?7,?4,?3;,
            ????????????????3;?4,?0,?3;,
            ????????????????3;?4,?8,?5;,
            ????????????????3;?5,?8,?9;,
            ????????????????3;?5,?9,?6;,
            ????????????????3;?9,?10,?6;,
            ????????????????3;?6,?10,?11;,
            ????????????????3;?7,?6,?11;,
            ????????????????3;?7,?11,?8;,
            ????????????????3;?4,?7,?8;,
            ????????????????3;?8,?10,?9;,
            ????????????????3;8,?11,?10;;
            ????????????}
            ????????}
            ????}
            ????
            }

            ???? 這里需要說明的是:如何保證一個Mesh(或者叫做MeshFace)的面是“正面”朝上的。這個面的朝向是由MeshNormals定義的,其模版定義如下:
            MeshNormals
            Defines?normals?for?a?mesh.?The?first?array?of?vectors?is?the?normal?vectors?themselves,?and?the?second?array?is?an?array?of?indexes?specifying?which?normals?should?be?applied?to?a?given?face.?The?value?of?the?nFaceNormals?member?should?be?equal?to?the?number?of?faces?in?a?mesh.

            template?MeshNormals
            {
            ????
            <?F6F23F43-7686-11cf-8F52-0040333594A3?>
            ????DWORD?nNormals;
            ????array?Vector?normals[nNormals];
            ????DWORD?nFaceNormals;
            ????array?MeshFace?faceNormals[nFaceNormals];
            }?

            Where:

            nNormals?-?Number?of?normals.?
            array?Vector?normals[nNormals]?-?Array?of?normals.?See?Vector.?
            nFaceNormals?-?Number?of?face?normals.?
            array?MeshFace?faceNormals[nFaceNormals]?-?Array?of?mesh?face?normals.?See?MeshFace.?

            ??? 由其定義可以看出,Vertex的法線向量和Face的法線向量共同決定Triangle的面朝向。如何確定兩個的法線向量呢?有個簡單步驟:首先確定Vertex的法線向量,方法是將使用到指定Vertex的多個面的“正(或朝向)”方向的法線向量相加,再除以面?zhèn)€數(shù),就得到了指定Vertex的法線向量;然后定義Mesh的三個Vertex順序,方法是伸出右手,大拇指指向Mesh“正”方向,彎曲其他四指,則三個Vetex的定義順序按照四指旋轉(zhuǎn)方向確定,簡單點(diǎn)就是繞大拇指,逆時針定義;最后將Mesh的Vertex索引定義,拷貝到MeshNormals模版中即可。下面說個實(shí)例,如下圖所示,我們來定義MeshA和MeshB。
            sample_normals.JPG


            ??? Mesh {
            ????? 8;
            ????? 0.000000;?0.000000;?1.000000;,//0
            ????? 1.000000;?0.000000;?1.000000;,//1
            ????? 1.000000;?1.000000;?1.000000;,//2
            ????? 0.000000;?1.000000;?1.000000;,//3

            ????? ...

            ????? 12;
            ?????? 3;0, 1, 2;,
            ?????? 3;0, 2, 3;,
            ?????? ...

            ????? }

            ????? 則Vertex0的法線向量為((0,0,1) + ( -1,0,0) +(0,-1, 0))/3 = (-0.333333,-0.333333,0.333333)。說明下,由于A,B在同一水平面,因此將AB算作了一個面,因此這認(rèn)為Vertex0被三個面使用,而不是標(biāo)準(zhǔn)的4個面。??????

            ??? 具體可以參考loveddy的“網(wǎng)格模型高級技術(shù)”,寫的很好。

            posted on 2009-04-16 00:43 codejie 閱讀(503) 評論(0)  編輯 收藏 引用 所屬分類: 隨筆而已MPQ - WOW

            公告

            Using C++

            導(dǎo)航

            統(tǒng)計(jì)

            留言簿(73)

            隨筆分類(513)

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            色婷婷久久综合中文久久蜜桃av| 久久国产精品偷99| 久久精品卫校国产小美女| 久久亚洲日韩看片无码| 亚洲AV日韩精品久久久久久久| www性久久久com| 国产日韩久久久精品影院首页| 免费精品久久久久久中文字幕| 欧洲成人午夜精品无码区久久| 久久综合给合久久狠狠狠97色| 国产精品视频久久| 久久受www免费人成_看片中文| 婷婷久久久亚洲欧洲日产国码AV | 久久精品一本到99热免费| 久久夜色精品国产噜噜麻豆| 国产日韩欧美久久| 久久99精品久久久久久hb无码 | 亚洲va中文字幕无码久久| 精品九九久久国内精品| 久久这里都是精品| 久久精品国产一区二区 | 国产精品一区二区久久| 无码国内精品久久综合88| 久久亚洲综合色一区二区三区| 久久人人爽人人爽人人片AV高清| 91精品国产高清久久久久久91| 漂亮人妻被黑人久久精品| 国产99久久久国产精品小说| 日本加勒比久久精品| segui久久国产精品| 中文字幕一区二区三区久久网站 | 久久人人超碰精品CAOPOREN| 日本三级久久网| 久久精品草草草| 国产V亚洲V天堂无码久久久| 久久综合给久久狠狠97色| 久久久久久久久无码精品亚洲日韩 | 国产成人99久久亚洲综合精品| 久久精品国产网红主播| 久久精品人人做人人妻人人玩| 欧洲成人午夜精品无码区久久|