Sign in to follow this  

Beginner's question about embedded objects and directX

This topic is 2346 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

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"][size="2"]if (meshContainer->pSkinInfo)[/size][/font][/font][font="Consolas"][size="2"][font="Consolas"][size="2"]

{

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.

[/size][/font][/size][/font]

Share this post


Link to post
Share on other sites
[quote]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?

Share this post


Link to post
Share on other sites
the compiler error reads:

[size="3"]"[/size][font="Consolas"][size="1"][font="Consolas"][size="1"][size="3"] 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
[/size]

[size="3"]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?

[/size]
[/size][/font][/size][/font]

Share this post


Link to post
Share on other sites
[quote name='sturmritter' timestamp='1313479227' post='4849736'][size="3"]"[/size][font="Consolas"][size="1"][font="Consolas"][size="1"][size="3"] 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[/size][/size][/font][/size][/font][/quote]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]?[quote]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...

Share this post


Link to post
Share on other sites
Actually you may have hit on the solution with writing in GetD3DXMATRIX routine. Let me try that and get back to you.

Share this post


Link to post
Share on other sites
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"][size="2"][font="Consolas"][size="2"]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.

[/size][/font][/size][/font]

Share this post


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