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

            C++ Programmer's Cookbook

            {C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

            Managed Directx ---world matrix , projection matrix , view matrix

            Set Up a View Matrix

            (^_^,只能看到projection以后棱錐上下截面間的部分)
            The three input vectors represent the following, respectively:

            1. The eye point: [0, 3, -5].???? (眼睛)
            2. The camera look-at target: the origin [0, 0, 0]. (眼睛要看的東東)
            3. The current world's up-direction: usually [0, 1, 0].?? (指出那邊是上面)

            ?

            using ?Microsoft.DirectX.Direct3D;

            Device?device?
            = ? null ;?? // ?Create?rendering?device.

            // ?Set?up?the?view?matrix.?A?view?matrix?can?be?defined?given?an?eye?point,
            // ???a?point?to?view,?and?a?direction?for?which?way?is?up.?Here,?you?set?
            // ???the?eye?five?units?back?along?the?z-axis?and?up?three?units,?view?the
            // ???origin,?and?define?"up"?to?be?in?the?y-direction.

            device.Transform.View?
            = ?Microsoft.DirectX.Matrix.LookAtLH(
            ????????????????????????????
            new ?Vector3( 0.0f ,? 3.0f ,? - 5.0f ),
            ????????????????????????????
            new ?Vector3( 0.0f ,? 0.0f ,? 0.0f ),
            ????????????????????????????
            new ?Vector3( 0.0f ,? 1.0f ,? 0.0f ));

            Set Up a Projection Matrix??

            (project以后得到我們能夠看到的所有:一個棱錐上下截面間的部分)

            This example demonstrates how to set up the projection transformation matrix, which transforms 3-D camera or view space coordinates into 2-D screen coordinates.

            See the following C# code example, the Projection transformation matrix is set to be equal to the left-handed (LH) PerspectiveFovLH matrix. Input arguments to PerspectiveFovLH are as follows.

            1. Field of view in radians: pi/4. (一般都為1/4 pi)
            2. Aspect ratio, or view-space height divided by width: 1, for a square window. (長寬的比)
            3. Near clipping plane distance: 1 unit.???? (離眼睛近的點,即棱錐的上面)
            4. Far clipping plane distance: 100 units.? (離眼睛遠的點,即棱錐的下面)

            ?

            using?Microsoft.DirectX;

            Direct3D.Device?device?
            =?null;??//?Create?rendering?device.

            //?For?the?projection?matrix,?you?set?up?a?perspective?transform?(which
            //???transforms?geometry?from?3-D?view?space?to?2-D?viewport?space,?with
            //???a?perspective?divide?making?objects?smaller?in?the?distance).?To?build
            //???a?perspective?transform,?you?need?the?field?of?view?(1/4?pi?is?common),
            //???the?aspect?ratio,?and?the?near?and?far?clipping?planes?(which?define?
            //???the?distances?at?which?geometry?should?no?longer?be?rendered).

            device.Transform.Projection?
            =?Matrix.PerspectiveFovLH(
            ??????????????????????????????(
            float)Math.PI?/?4,?1.0f,?1.0f,?100.0f?);

            What Is a World Transformation?

            A world transformation changes coordinates from model space, where vertices are defined relative to a model's local origin, to world space, where vertices are defined relative to an origin common to all of the objects in a scene. In essence, the world transformation places a model into the world; hence its name.

            Setting Up a World Matrix

            As with any other transformation, you create the world transformation by concatenating a series of transformation matrices into a single matrix that contains the sum total of their effects. In the simplest case, when a model is at the world origin and its local coordinate axes are oriented the same as world space, the world matrix is the identity matrix. More commonly, the world matrix is a combination of a translation into world space and possibly one or more rotations to turn the model as needed.

            The following C# code example, from a fictitious 3-D model class written in C#, creates a world matrix that includes three rotations to orient a model and a translation to relocate it relative to its position in world space.

            ?

            public?class?ModelClass
            {
            ???
            private?float?xPos=0;
            ???
            private?float?yPos=0;
            ???
            private?float?zPos=0;

            ???
            private?float?Pitch=0;
            ???
            private?float?Yaw=0;
            ???
            private?float?Roll=0;

            ???
            //Other?model?properties?and?methods
            ???
            ???
            public?Matrix?MakeWorldMatrix(Matrix?worldMatrix)
            ???
            {
            ??????worldMatrix.Translate(xPos,yPos,zPos);

            ??????Matrix?matRot?
            =?Matrix.Identity;

            ??????matRot.RotateYawPitchRoll(Yaw,Pitch,Roll);
            ??????
            ??????worldMatrix?
            =?Matrix.Multiply(matRot,?worldMatrix);

            ??????
            return?worldMatrix;

            ???}

            }


            Note:?Direct3D uses the world and view matrices that you set to configure several internal data structures. Each time you set a new world or view matrix, the system recalculates the associated internal structures. Setting these matrices frequently—for example, thousands of times per frame—is computationally time-consuming. You can minimize the number of required calculations by concatenating your world and view matrices into a world-view matrix that you set as the world matrix, and then setting the view matrix to the identity. Keep cached copies of individual world and view matrices so that you can modify, concatenate, and reset the world matrix as needed. For clarity, Direct3D samples in this documentation rarely employ this optimization.

            posted on 2006-06-09 15:07 夢在天涯 閱讀(1581) 評論(0)  編輯 收藏 引用 所屬分類: DirectX

            公告

            EMail:itech001#126.com

            導航

            統計

            • 隨筆 - 461
            • 文章 - 4
            • 評論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1807508
            • 排名 - 5

            最新評論

            閱讀排行榜

            久久精品亚洲一区二区三区浴池| 精品九九久久国内精品| 久久综合久久鬼色| 伊色综合久久之综合久久| 久久天天躁狠狠躁夜夜avapp| 亚洲国产精品无码久久一区二区| 人妻少妇久久中文字幕| 伊人丁香狠狠色综合久久| 一本久久a久久精品综合香蕉| 伊人久久无码中文字幕| 99久久精品国产一区二区蜜芽 | 人妻精品久久久久中文字幕一冢本| 国产成人精品综合久久久久 | 伊人久久大香线蕉成人| 久久久久亚洲精品无码蜜桃| 国产精品青草久久久久福利99| 久久久久亚洲AV成人网人人网站 | 日韩精品久久久久久久电影蜜臀| 国产福利电影一区二区三区,免费久久久久久久精| 国产精自产拍久久久久久蜜| 久久久久亚洲AV无码观看| 久久国产视频99电影| 久久亚洲欧美国产精品| 久久综合亚洲色HEZYO国产| 欧美亚洲国产精品久久蜜芽| 性高湖久久久久久久久| 久久99热这里只频精品6| 91亚洲国产成人久久精品网址 | 久久丫精品国产亚洲av| 伊人久久精品影院| 欧美性猛交xxxx免费看久久久| 99久久夜色精品国产网站| 97久久精品无码一区二区| 久久久久亚洲AV无码专区首JN| 色播久久人人爽人人爽人人片aV| 国产精品九九久久免费视频| 2021久久精品国产99国产精品| 97久久香蕉国产线看观看| 久久人人爽人人爽人人片av高请| 亚洲精品乱码久久久久久蜜桃不卡| 狠狠精品久久久无码中文字幕|