Skip to main content
GameDev.net gamedev.net
🔒 Locked

Odd Sprite Question

Started by MarkovChain Feb 17, 2007 at 8:58 AM 1 replies 850+ views
Original Post
MarkovChain
MarkovChain
A bit of a weird question, but does anyone have an idea of how to draw a sprite rotated about its X-axis. I've tried it before by rotating it using D3DXMatixRotationX, but it just gets clipped off at the bottom. I'm trying to get a pseudo-perspective view (ala SNES Mode-7)for a tile based game so any insight you could give would be appreciated. thanks a bunch!
Cigguh
Cigguh
Hi, from DXSDK help:


HRESULT Draw( LPDIRECT3DTEXTURE9 pSrcTexture,
CONST RECT *pSrcRect,
CONST D3DXVECTOR2 *pScaling,
CONST D3DXVECTOR2 *pRotationCenter,
FLOAT Rotation,
CONST D3DVECTOR2 *pTranslation,
D3DCOLOR Color
);



pRotationCenter

Pointer to a D3DXVECTOR2 structure, containing the point in screen pixels that identifies the center of rotation. If this argument is NULL, the point (0,0) is used, which is the upper-left corner of the texture.


Maybe your problem is because rotation is around upper-left corner by default?
i make the game so i be ballin
MarkovChain
MarkovChain
Thanks for the reply.


I construct my matrix like this:

D3DXMatrixScaling(&scale, scalex, scaley, 1.0f);
combined *= scale;

// Rotate the sprite.
D3DXMatrixTranslation(&translate, -64, -64, 0);
combined *= translate;
D3DXMatrixRotationX(&rotation, .04);
combined *= rotation;
D3DXMatrixTranslation(&translate, 64, 64, 0);
combined *= translate;

// Translate the sprite
D3DXMatrixTranslation(&translate, (float)x, (float)y, 0.0f);
combined *= translate;

// Apply the transform.
m_lpSprite->SetTransform(&combined);

// Draw the sprite.
if (FAILED(m_lpSprite->Draw(m_Textures[id].texture, section, NULL, NULL, color)))
DXERROR("Failed to draw the texture.");

The 64 above is just my temp hard coded value, the image is a 128 x 128 bitmap.
the .04 in the RotationX is another hardcode for testing.

The problem is, It will only draw the top 1/4 bricks, and cut the rest off.

I've been thinking about changing the camera system, or as a fail safe, just rendering a custom vertex structure of each tile and just rotating them (which could get interesting).

Any other insight will be appreciated.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.