strange .x problem

Started by
11 comments, last by Sheep 22 years, 1 month ago
Ok...didnt think that it would matter because I am not attempting to invert the view matrix, but here it is:

      //-----------------------------------------------------------------------------// Name: SetWorld()// Desc: Sets and returns the world matrix//-----------------------------------------------------------------------------D3DXMATRIX CWorld::SetWorld( LPDIRECT3DDEVICE8 pDevice ){	D3DXMATRIX matWorld;								// Create the world matrix		pDevice->SetTransform( D3DTS_WORLD, &matWorld );	// Set world matrix to &matWorld		return matWorld;									// Return the world matrix}//-----------------------------------------------------------------------------// Name: SetView()// Desc: Sets and returns the view matrix//-----------------------------------------------------------------------------D3DXMATRIX CWorld::SetView( LPDIRECT3DDEVICE8 pDevice, const D3DXVECTOR3* pEye, 			const D3DXVECTOR3* pAt,			const D3DXVECTOR3* pUp ){	D3DXMATRIX matView;								// Create the view matrix		// Look at the *pAt parameter passed in	D3DXMatrixLookAtLH( &matView, pEye,								  pAt,                                  pUp );		pDevice->SetTransform( D3DTS_VIEW, &matView ); // Set the view matrix to &matView	return matView;								   // Return the view matrix}//-----------------------------------------------------------------------------// Name: SetProjection()// Desc: Sets and returns the projection matrix//-----------------------------------------------------------------------------D3DXMATRIX CWorld::SetProjection( LPDIRECT3DDEVICE8 pDevice ){	// Create the projection matrix	D3DXMATRIX matProj;											// Set the perspective	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );		// Set the view matrix to &matProj	pDevice->SetTransform( D3DTS_PROJECTION, &matProj );	// return the projection matrix	return matProj;}      


Any ideas?

Edited by - Sheep on February 27, 2002 1:41:34 PM

Edited by - Sheep on February 27, 2002 8:24:07 PM
Advertisement
Here's a problem:

    D3DXMATRIX CWorld::SetWorld( LPDIRECT3DDEVICE8 pDevice ){  D3DXMATRIX matWorld;	// Create the world matrix  // PROBLEM HERE  // Set world matrix to &matWorld  pDevice->SetTransform(D3DTS_WORLD, &matWorld );    return matWorld;  // Return the world matrix}  


There's nothing set in the matWorld - you want to set it to identity at least with D3DXMatrixIdentity(&matWorld) before setting it via SetTransform. The rest looks fine.

Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX"


Edited by - jim adams on February 28, 2002 1:44:53 AM
Hmmm...thanks for the tip, but that didn''t do it. I think I have tracked the error (if the debugger isnt lying) to my render function:

  HRESULT CX::Render( LPDIRECT3DDEVICE8 pDevice ){	for( DWORD i=0; i<m_dwNumMaterials; i++ )    {        // Set the material for this subset        pDevice->SetMaterial( &m_pMeshMaterials[i] );                // Draw the mesh subset        m_pMesh->DrawSubset( i ); // I get the error here.                                  // Any ideas?    }	return S_OK;}   


Thanks

This topic is closed to new replies.

Advertisement