首页 > 其他 > 详细

【DirectX12】第六章-练习

时间:2017-09-08 09:25:00      阅读:249      评论:0      收藏:0      [点我收藏+]

练习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】第六章-练习

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!