我有一个d3d9代理dll。
我需要将D3DXMATRIX保存在SetTransform函数中,以便在另一个函数中使用它。
我在
开头声明它们D3DXMATRIX view_matrix, proj_matrix, world_matrix;
在SetTransform函数中我有:
HRESULT my_IDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix)
{
if (State == D3DTS_VIEW)
{
&view_matrix = pMatrix;
}
if (State == D3DTS_PROJECTION)
{
&proj_matrix = pMatrix;
}
if (State == D3DTS_WORLD)
{
&world_matrix = pMatrix;
}
return(m_pIDirect3DDevice9->SetTransform(State,pMatrix));
}
编译器错误消息:
my_IDirect3DDevice9.cpp
my_IDirect3DDevice9.cpp(838) : error C2440: '=' : cannot convert from 'const D3DMATRIX *' to 'D3DXMATRIX *'
Cast from base to derived requires dynamic_cast or static_cast
my_IDirect3DDevice9.cpp(842) : error C2440: '=' : cannot convert from 'const D3DMATRIX *' to 'D3DXMATRIX *'
Cast from base to derived requires dynamic_cast or static_cast
my_IDirect3DDevice9.cpp(846) : error C2440: '=' : cannot convert from 'const D3DMATRIX *' to 'D3DXMATRIX *'
Cast from base to derived requires dynamic_cast or static_cast
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : return code '0x2'
我稍后需要这3个矩阵进行计算:
m_pIDirect3DDevice9->GetTransform( D3DTS_VIEW, &view_matrix );
m_pIDirect3DDevice9->GetTransform( D3DTS_PROJECTION, &proj_matrix );
m_pIDirect3DDevice9->GetTransform( D3DTS_WORLD, &world_matrix );
m_pIDirect3DDevice9->GetViewport( &d3dvp );
D3DXVec3Project( &vector_2d, &vector_3d, &d3dvp, &proj_matrix, &view_matrix, &world_matrix );
D3DXVec3Unproject( &vector_3d, &vector_2d, &d3dvp, &proj_matrix, &view_matrix, &world_matrix );
因为GetTransform在Windows XP系统上失败了。所以我需要在他们设置好之后才能获得它们。
答案 0 :(得分:0)
& view_matrix是view_matrix的地址,它是一个r值,你不能分配给r值。
试试这个:
if (State == D3DTS_VIEW)
{
view_matrix = *pMatrix;
}
if (State == D3DTS_PROJECTION)
{
proj_matrix = *pMatrix;
}
if (State == D3DTS_WORLD)
{
world_matrix = *pMatrix;
}