码迷,mamicode.com
首页 > 其他好文 > 详细

【DirectX12】第六章-练习

时间:2017-09-08 09:59:03      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:src   效果   sda   int   world   ati   9.png   es2017   获得   

练习3.

(a)

技术分享

//LINELIST

    std::array<VPosData, 8> posData = {
        VPosData({ XMFLOAT3(-2.0f, -1.0f, +1.0f) }),
        VPosData({ XMFLOAT3(-1.5f, +1.0f, +1.0f) }),
        VPosData({ XMFLOAT3(-1.0f, -0.3f, +1.0f) }),
        VPosData({ XMFLOAT3(-0.3f, +0.7f, +1.0f) }),
        VPosData({ XMFLOAT3(-0.0f, -0.3f, +1.0f) }),
        VPosData({ XMFLOAT3(+1.0f, +0.7f, +1.0f) }),
        VPosData({ XMFLOAT3(+2.0f, +0.0f, +1.0f) }),
        VPosData({ XMFLOAT3(+2.7f, +1.5f, +1.0f) }),
    };

    std::array<std::uint16_t, 36> indices =
    {
        0,1,2,
        1,2,3,
        2,3,4,
        3,4,5,
        4,5,6,
        5,6,7,
    };

 (b)

技术分享

//LINELIST

    std::array<std::uint16_t, 36> indices =
    {
        0,1,2,3,4,5,6,7
    };

(c)

//LINELIST
std::array<std::uint16_t, 36> indices =
    {
        0,1,
        1,2,
        0,2,
        1,3,
        2,3,
        3,4,
        2,4,
        3,5,
        4,5,
        5,6,
        4,6,
        5,7,
        6,7
    };

 

技术分享

 

 

练习4:

技术分享

//TRIANGLESTRIP

std::array<VPosData, 5> posData = {
        VPosData({ XMFLOAT3(-1.0f, -1.0f, -1.0f) }),
        VPosData({ XMFLOAT3(+1.0f, -1.0f, -1.0f) }),
        VPosData({ XMFLOAT3(+1.0f, -1.0f, +1.0f) }),
        VPosData({ XMFLOAT3(-1.0f, -1.0f, +1.0f) }),
        VPosData({ XMFLOAT3(-0.0f, +0.78f, +0.0f) }),

    };

    std::array<VColorData, 5> colorData{
        VColorData({ XMFLOAT4(Colors::Green) }),
        VColorData({ XMFLOAT4(Colors::Green) }),
        VColorData({ XMFLOAT4(Colors::Green) }),
        VColorData({ XMFLOAT4(Colors::Green) }),
        VColorData({ XMFLOAT4(Colors::Red) })
    };

    std::array<std::uint16_t, 36> indices =
    {
        0,1,2,
        0,3,2,

        0,1,4,
        0,3,4,
        1,2,4,
        2,3,4,
    };

 在update中添加代码获得旋转效果:

    XMMATRIX Ry;

    static float Y = 0.0f;
    Ry = XMMatrixRotationY(Y);
    Y += 0.001;  
    XMStoreFloat4x4(&mWorld, Ry);

 

【DirectX12】第六章-练习

标签:src   效果   sda   int   world   ati   9.png   es2017   获得   

原文地址:http://www.cnblogs.com/liez/p/7492743.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!