Where is ID3DXSprite?

Started by
2 comments, last by Trip99 18 years, 7 months ago
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.
Advertisement
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
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.
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
------------------------See my games programming site at: www.toymaker.info

This topic is closed to new replies.

Advertisement