Sign in to follow this  
jf_wangfeng

Where is ID3DXSprite?

Recommended Posts

I want to use ID3DXSprite to make my own GUI.But I have some trouble about its coordinate in the world space and in the view space. The codes : D3DXMATRIXA16 mat ; D3DXMatrixIdentity( &mat) ; g_pSprite->Begin(D3DXSPRITE_BILLBOARD) ; g_pSprite->SetTransform( &mat ) ; g_pSprite->Draw( pTexture , NULL,NULL,NULL,0xffffffff) ;// pTexture:256*256 g_pSprite->End() ; I do not know what is its coordinate(x,y,z) . Also I want to know how to get mouse coordinate in the application window.

Share this post


Link to post
Share on other sites
I have never used ID3DXSprite, but

a) if you have to passa a matrix then you might well have to give it the location coordinates by doing something like this:

D3DXMatrixTranslation( &mat, x, y, z );

x,y and z will probably have to be in pixel coordinates, not -1 to 1 as in 3D space.

b) To get the cursor position you do this:

POINT cursorLoc;

GetCursorPos( &cursorLoc );

To convert the point to window space, from screen space do this:

ScreenToClient( windowHandle, &cursorLoc );

Correct me if im wrong anyone, but im sure b) is correct.

ace

Share this post


Link to post
Share on other sites
I'm not sure myself but I'll give a stab at it. What you're doing is setting the matrix of x & y -1 to 1 and z 0 - 1, so unless your vertices are within those limits they won't get clipped. I'm pretty sure that you're using vertices larger then that so what you'll have to do to get that orthographic projection you want is use D3DXMatrixOrthoOffCenterLH.

Share this post


Link to post
Share on other sites
IF you are passing a matrix to the sprite call I would use D3DXMatrixTransformation2D which will create a matrix from translation and optionally scale and rotation values. To get the mouse screen position using Win32 trap the WM_MOUSEMOVE message sent to your wndproc. For more on sprites see here: http://www.toymaker.info/Games/html/sprites.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this