Hello all,
I'm attempting to encapsulate a couple of objects and am running into difficulty with the compiler not being able to identify the D3DXMatrix that the draw mesh function is looking for:
[font="Consolas"][font="Consolas"]if (meshContainer->pSkinInfo)[/font][/font][font="Consolas"][font="Consolas"]
{
m_pGraphics->GetDeviceCOM()->SetTransform(D3DTS_WORLD, m_WorldPos.GetMatrix());
}
where m_WorldPos is a private member class (of the object calling the function) which encapsulates the world transformation matrix. Unfortunately, the compiler gives me an error as the SetTransform function is looking for a constant pointer, and the encapsulated version is giving a "type qualifiers incompatible with member function" error.
Is there a method to work around this problem? I need to get something like &m_WorldPos.GetMatrix(), but I don't know the syntax to accomplish that.
[/font][/font]
Beginner's question about embedded objects and directX
is giving a "type qualifiers incompatible with member function" error.[/quote]This is just a C++ mistake, not a DX-specific problem.
SetTransform expects a [font="'Lucida Console"]const D3DMATRIX * [/font]-- what type does your [font="'Lucida Console"]GetMatrix[/font] function return?
the compiler error reads:
"[font="Consolas"][size="1"][font="Consolas"][size="1"] error C2664: 'IDirect3DDevice9::SetTransform' : cannot convert parameter 2 from 'const KEWorldPosition *' to 'const D3DMATRIX *'1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
So but the GetMatrix() ought to return a D3DXMATRIX* as that is the way it is coded. Even if I switch the declaration to const D3DXMATRIX* the compiler is still showing the parameter as part of the larger encapsulated object (KEWorldPosition)
Is there a way to get the compiler to identify the encapsulated D3DXMTRIX pointer, and not the encapsualted object?
[/font][/font]
"[font="Consolas"][size="1"][font="Consolas"][size="1"] error C2664: 'IDirect3DDevice9::SetTransform' : cannot convert parameter 2 from 'const KEWorldPosition *' to 'const D3DMATRIX *'1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
So but the GetMatrix() ought to return a D3DXMATRIX* as that is the way it is coded. Even if I switch the declaration to const D3DXMATRIX* the compiler is still showing the parameter as part of the larger encapsulated object (KEWorldPosition)
Is there a way to get the compiler to identify the encapsulated D3DXMTRIX pointer, and not the encapsualted object?
[/font][/font]
"[font="Consolas"][size="1"][font="Consolas"][size="1"] error C2664: 'IDirect3DDevice9::SetTransform' : cannot convert parameter 2 from 'const KEWorldPosition *' to 'const D3DMATRIX *'1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast[/font][/font]Ok, so [font="'Courier New"]GetMatrix[/font] returns your own "world position" type from GetMatrix, right?
Perhaps your [font="'Courier New"]KEWorldPosition[/font] class could have a "[font="'Courier New"]GetD3DMatrix[/font]" function? So then you could write [font="'Courier New"]SetTransform(D3DTS_WORLD, m_WorldPos.GetMatrix().GetD3DMatrix());[/font]?
Even if I switch the declaration to const D3DXMATRIX* the compiler is still showing the parameter as part of the larger encapsulated object (KEWorldPosition)[/quote]What does this mean?
Perhaps you should post some code regarding KEWorldPosition / GetMatrix...
Actually you may have hit on the solution with writing in GetD3DXMATRIX routine. Let me try that and get back to you.
I found an inelegant but workable solution:
Instead of passing the class instance of KEWorldPosition, I included a D3XMATRIX m_matWorld in my encapsulation class, then manually set the matrix variables as follows:
[font="Consolas"][font="Consolas"]m_matWorld._11 = m_WorldPos.GetMatrix()->_11;
...
m_matWorld._44 = m_WorldPos.GetMatrix()->_44;
Now I can simply pass the m_matWorld pointer address to SetTransform function. Thanks for your putting me on the right path.
[/font][/font]
Instead of passing the class instance of KEWorldPosition, I included a D3XMATRIX m_matWorld in my encapsulation class, then manually set the matrix variables as follows:
[font="Consolas"][font="Consolas"]m_matWorld._11 = m_WorldPos.GetMatrix()->_11;
...
m_matWorld._44 = m_WorldPos.GetMatrix()->_44;
Now I can simply pass the m_matWorld pointer address to SetTransform function. Thanks for your putting me on the right path.
[/font][/font]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement