Jump to content
  • Advertisement
Sign in to follow this  
sastryvpr

Direct3D9: (INFO) :Cannot invert projection matrix, assuming identity

This topic is 2904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,

I am a newbie to DirectX

I was trying to render a cube using triangle strips, i was successful in projecting the front face
when i tried to project one triangle on the top face, i got the following error:

D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.58456e+029f. This is ok.
Direct3D9: (WARN) :Cannot compute WNear and WFar from the supplied projection matrix

Direct3D9: (WARN) :Setting wNear to 0.0 and wFar to 1.0

Direct3D9: (INFO) :Cannot invert projection matrix, assuming identity

Code Snippet:
void CD3DApp1Dlg::Render(void)
{
if (g_pd3dDevice != NULL)
{
// Clear the back buffer and the z buffer
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

// Begin the scene
if(SUCCEEDED(g_pd3dDevice->BeginScene()))
{
////Draw stuff here
g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
//g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 3);

// End the scene
g_pd3dDevice->EndScene();
}
// Present the back buffer contents to the display
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}
}

{
// TODO: Add your control notification handler code here
if(NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
return;

DWORD QualityLevel;
if( SUCCEEDED(g_pD3D->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
FALSE, D3DMULTISAMPLE_2_SAMPLES, &QualityLevel ) ) )
{
// MultiSampling would be set below in presentation parameters
}

//Pointer to a Direct3D device
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = 1600;
d3dpp.BackBufferHeight = 900;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
d3dpp.MultiSampleQuality = QualityLevel-1;
// Create the D3DDevice
HRESULT hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, GetSafeHwnd(),
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice);


g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

D3DXMatrixTranslation( &g_worldTransform, 1/50.0f, 1/50.0f, 1/50.0f );
g_pd3dDevice->SetTransform(D3DTS_WORLD, &g_worldTransform);

D3DXMatrixPerspectiveFovLH( &g_Projection, D3DXToRadian( 45 ), 1600/900.0, 0.0, 1.0 );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &g_Projection );

D3DXVECTOR3 Eye(15, 5, -100);
D3DXVECTOR3 LookAt(15, 5, 100);
D3DXVECTOR3 Up(0, 1, 0);
D3DXMatrixLookAtLH(&g_View, &Eye, &LookAt, &Up);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &g_View);

if (g_pd3dDevice->CreateVertexBuffer(sizeof(CUSTOMVERTEX)*9,
0, D3DFVF_CUSTOMVERTEX,
D3DPOOL_SYSTEMMEM,
&g_pVB, NULL) != D3D_OK)
{
AfxMessageBox("Create VertexBuffer Failed");
return;
}

CUSTOMVERTEX cube_vertices[] =
{
{ 10, 0, 10, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) }, // Triangle #1
{ 10, 10, 10, D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },
{ 20, 10, 10, D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },

{ 10, 0, 10, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) }, // Triangle #2
{ 20, 10, 10, D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },
{ 20, 0, 10, D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },

{ 10, 10, 10, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) }, // Triangle #3
{ 10, 10, 20, D3DCOLOR_COLORVALUE( 0.0, 0.0, 1.0, 1.0 ) },
{ 20, 10, 10, D3DCOLOR_COLORVALUE( 0.0, 1.0, 0.0, 1.0 ) },
};

VOID* pCubeVertices = NULL;
if(FAILED(g_pVB->Lock(0, sizeof(cube_vertices), (void**)&pCubeVertices, 0)))
return;
memcpy(pCubeVertices, cube_vertices, sizeof(cube_vertices));
g_pVB->Unlock();


// Retrieving the BackBuffer
if (g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &g_pd3dBackBuffer) != D3D_OK)
{
AfxMessageBox("GetBackBuffer Failed");
}

// Hide Window Controls
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);

// Force repaint
Render();

return;
}

Whats wrong in the code above?

Share this post


Link to post
Share on other sites
Advertisement
You can't set a z-near value of 0, the math doesn't work that way and the matrix becomes bogus. You need to use some non-zero value, even if very small. Typical values are 0.1 or 1.0.

Share this post


Link to post
Share on other sites
hi Promit,

thnx, it works now.

But these functions confuse me;

all the values that i pass to any of the DirectX functions like

(eg. D3DXMatrixPerspectiveFovLH, D3DXMatrixLookAtLH, & the vertices that i specify for the objects - vector - { 1, 0, 1, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) })

Do these values need to be normalised, i.e., do they have to be always in the range 0 - 1? Am i not supposed to pass world coordinates like { 10, 0, 10, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) }?

And can i set my eye, lookat, projection matrix to some model COORDINATE values; i mean does directx talk to outside world only in normalized values not in COORDINATE values?

Share this post


Link to post
Share on other sites
Quote:
But these functions confuse me;

all the values that i pass to any of the DirectX functions like

(eg. D3DXMatrixPerspectiveFovLH, D3DXMatrixLookAtLH, & the vertices that i specify for the objects - vector - { 1, 0, 1, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) })

Do these values need to be normalised, i.e., do they have to be always in the range 0 - 1? Am i not supposed to pass world coordinates like { 10, 0, 10, D3DCOLOR_COLORVALUE( 1.0, 0.0, 0.0, 1.0 ) }?

And can i set my eye, lookat, projection matrix to some model COORDINATE values; i mean does directx talk to outside world only in normalized values not in COORDINATE values?
Some values are typically normalized, and some aren't. For colors expressed using floats, the elements are usually in the range [0, 1]. Spatial coordinates, on the other hand, can have arbitrary values (10, 0, 10, for example, is fine).

If there are particular values or arguments you're wondering about, you can always ask about them specifically.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!