Directx9线翻译

时间:2018-11-19 21:23:24

标签: matrix directx-9

我无法翻译一行

功能

void DrawLine(LPDIRECT3DDEVICE9 d3ddev, float x, float y, float x2, float y2, DWORD color)
{
    D3DXMATRIX world, t, r;
    LPDIRECT3DVERTEXBUFFER9 vBuffer = NULL;
    VERTEXDATA2 vertex[] =
    {
        { -1.0f, -1.0f ,1.0f, color, },
        { 1.0f,  1.0f, 1.0f, color, },
    };
    Vec2 diff(x2 - x, y2 - y);
    D3DXMatrixTranslation(&t, TransfromNormalizeX(x , (float)SCREEN_WIDTH), TransfromNormalizeY(y, (float)SCREEN_HEIGHT), 0);
    D3DXMatrixRotationZ(&r, -D3DXToRadian(45));
    D3DXMatrixIdentity(&world);
    world._11 = NormalizeSacle(diff.x, (float)SCREEN_WIDTH);
    world._22 = NormalizeSacle(diff.y, (float)SCREEN_HEIGHT);
    world = world  * r ;
    d3ddev->SetTransform(D3DTS_WORLD,&world);

    d3ddev->SetFVF(CUSTOMFVF);
    d3ddev->SetStreamSource(0, vBuffer, 0, sizeof(VERTEXDATA2));
    d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 1);
}

我的问题是我如何缩放旋转并适当地转换它 因为确实画对了 感谢您提供的所有信息

0 个答案:

没有答案