Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

stevenmarky

Simple Matrices question - HELP!

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

Im usually a 2d programmer, but I want to take use of the DrawTransform function of ID3DXSprite (so I can specify Z order etc). All I want to know is how to set up a Matrix, I know about scaling, transformation etc, all I don't know is how to actually put the information in the matrix and use it (without getting errors), here is what I do:
    

float s=1.0f;

D3DMATRIX scale = {
    s,               0.0f,            0.0f,            0.0f,
    0.0f,            s,               0.0f,            0.0f,
    0.0f,            0.0f,            s,               0.0f,
    0.0f,            0.0f,            0.0f,            1.0f
};

hr = g_lpSprite->DrawTransform(g_pTextureThree, NULL, &scale,dwColor);

    
I get the following errors from Visual C++ 6.0: C:\ZOrdering\Main.cpp(123) : error C2664: 'DrawTransform' : cannot convert parameter 3 from 'struct _D3DMATRIX *' to 'const struct D3DXMATRIX *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Why is this? I think I am doing something wrong, does anyone know? Thanks, Steven R Edited by - stevenmarky on February 2, 2002 5:59:18 AM

Share this post


Link to post
Share on other sites
Advertisement
DrawTransform() is a D3DX function, which takes D3DXMATRIX types (note the 'X' after D3D). You've created a D3DMATRIX (note no X after D3D) so the compiler is moaning that they are different data types. In reality, D3DX matrices are just wrappers on top of D3D matrices. So you can do either:

    
float s=1.0f;

// note D3D **X** MATRIX

D3DXMATRIX scale = {
s, 0.0f, 0.0f, 0.0f,
0.0f, s, 0.0f, 0.0f,
0.0f, 0.0f, s, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};

hr = g_lpSprite->DrawTransform(g_pTextureThree, NULL, &scale,dwColor);


or


float s=1.0f;

D3DMATRIX scale = {
s, 0.0f, 0.0f, 0.0f,
0.0f, s, 0.0f, 0.0f,
0.0f, 0.0f, s, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};

hr = g_lpSprite->DrawTransform(g_pTextureThree, NULL, (D3DXMATRIX*)&scale, dwColor);


The first method is probably the best one to go for for future compatibility.

--
Simon O'Connor
Creative Asylum Ltd
www.creative-asylum.com

Edited by - s1ca on February 2, 2002 7:23:57 AM

Share this post


Link to post
Share on other sites
Thanks a lot S1CA thats perfect

You''ve helped me out a lot there, I should of looked more closely at the data types in the first place, duh!

Share this post


Link to post
Share on other sites
Nearly, hehe - they are supposed to be parantheses for the function, not brackets (like I also did in the first place thinking it was some sort of array).

Share this post


Link to post
Share on other sites

  • 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!