English 中文(简体)
直接 X 压倒性剂量在摄像机轮值时在屏幕上移动
原标题:DirectX primitive doesn t move on screen when rotating camera

I m 试图在屏幕上放置一只ube子......i 有一个照相机,以摩擦和键板的指挥进行轮换和翻译......然而,在运行期间,ube的平方表面在屏幕上平平平平,而照相机正在轮换......屏幕上的其他物品在平方表面上出现......任何人都解释出放火的过程? 事先感谢任何帮助......

#define SQUAREFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE)

struct SQUARE {
    float x, y, z;
    DWORD color;
};

SQUARE vert[] = 
{
    // 1
        { -64.0f,  -64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
        {  -64.0f,  64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
        { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
        {  64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,0,0,255)},
};
bool CGraphics::TerrainTwo(D3DXVECTOR3 minB, D3DXVECTOR3 maxB, int numCellsW, int numCellsL)
{
    HRESULT hr;
    void* pVoid;

    hr = m_d3ddev->CreateVertexBuffer(sizeof(SQUARE)*sizeof(vert),0,
        CUSTOMFVF,D3DPOOL_DEFAULT,&m_terrainVertexBuffer,NULL);
    if(FAILED(hr)){
        MessageBox(NULL, L"Could not Create Vertex Buffer", L"ERROR", MB_OK);
        return false;
    }
    hr = m_terrainVertexBuffer->Lock(0, 0, (void**)&pVoid, NULL);
    if(FAILED(hr)){
        MessageBox(NULL, L"Could not Lock Vertex Buffer", L"ERROR", MB_OK);
        return false;
    }   
    memcpy(pVoid, &vert, sizeof(vert));
    m_terrainVertexBuffer->Unlock();

    /*hr = m_d3ddev->CreateIndexBuffer(sizeof(DWORD)*sizeof(indices),0,
        D3DFMT_INDEX16, D3DPOOL_DEFAULT, &m_terrainIndexBuffer, NULL);
    if(FAILED(hr)){
        MessageBox(NULL, L"Could not Create Index Buffer", L"ERROR", MB_OK);
        return false;
    }   
    hr = m_terrainIndexBuffer->Lock(0, 0, (void**)&pVoid, 0);
    if(FAILED(hr)){
        MessageBox(NULL, L"Could not Create Vertex Buffer", L"ERROR", MB_OK);
        return false;
    }   
    memcpy(pVoid, indices, sizeof(indices));
    if(FAILED(hr)){
        MessageBox(NULL, L"Could not Create Vertex Buffer", L"ERROR", MB_OK);
        return false;
    }   
    m_terrainIndexBuffer->Unlock();*/

    return true;
}
void CGAME::Update()
{

if(m_graphics){
        //m_graphics->UpdateSkyBox();
        D3DXMATRIX matRotX, matRotY, matRotZ, matTrans;

        D3DXMatrixRotationX (&matRotX, 0);
        D3DXMatrixRotationY( &matRotY, 0 );  
        D3DXMatrixRotationZ( &matRotZ, 0 ); 
        // Calculate a translation matrix
        D3DXMatrixTranslation(&matTrans,5.0,1.0,5.0);
        D3DXMATRIX matWorld = (matRotX*matRotY*matRotZ)*matTrans;
        m_graphics->RenderTerrain(matWorld);
    }
}

void CGraphics::RenderTerrain(D3DXMATRIX matW)
{
    m_d3ddev->SetTransform(D3DTS_WORLD, &matW);
    m_d3ddev->SetTexture(0, NULL);
    m_d3ddev->SetStreamSource(0, m_terrainVertexBuffer, 0, sizeof(SQUARE));

    m_d3ddev->SetFVF(CUSTOMFVF);

    m_d3ddev->DrawPrimitive( D3DPT_TRIANGLESTRIP,  0, 2 );
}
问题回答

它包含所有矩阵数学。 只要其阴道的反照相变形(aka照相或视矩阵)转变,其ube子就会轮换(也应当由自己的世界转变矩阵和所谓的预测矩阵加以改变,后者负责视角效应)。

假设你有透镜(固定功能管道已经过时),你们都必须确保这些转变得到应用。 通常的做法是,与世界概览* 预测矩阵进行单一的重复,而我很相信你在某个地方这样做,而且这并非正确。

提供管道有许多很好的来源,但这是正确的,取决于直接X/硬件水平。 在过去15年里,如何将单一价格推向屏幕上,变化很大。

由于你是3D图象,正如我所言,请允许我向大家发出警告: X和开放Gl可以trick笑/无私,3D图形背后的数学一般并非绝对微不足道,两者往往使你们感觉到,有些东西只是打赢的,或者甚至出现在屏幕上。 仅凭图或样本代码对你的代码进行双重核对,......

Where is matrices of the camera dude? You are setting only a world matrix. Before you call DrawPrimitive, you have to set camera matrices like below.

m_d3ddev->SetTransform(D3DTS_WORLD, &matW); // This line is already in your code.
m_d3ddev->SetTransform(D3DTS_VIEW, &camera.m_viewMatrix);
m_d3ddev->SetTransform(D3DTS_PROJECTION, &camera.m_projMatrix);

你可能发现一些地方的照相器。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签