Sign in to follow this  
QuinnJohns

A Playing Card

Recommended Posts

Assuming I'm using D3DXSprite, to display a playing card's face, how do I have the other sprite per-se on the backside of it? do I just set the z, down by like 0.001f, or something? and when I rotate the sprite on any axis it'll show? Thanks for any insight.

Share this post


Link to post
Share on other sites
Actually if you put both faces in the same position but with one sprite rotated 180 degrees around the y-axis, and then enable back-face culling, you'll always only render the front-facing side of the card. Just make sure you apply this rotation before any other transforms, like this:


// Set transform for the front face of the card
matTransform = matScale * matRotation * matTranslation:
pSpriteInterface->SetTransform(&matTransform);
pSprite->Draw(pFrontFaceTexture, ...);

// Set transform for the back face
D3DXMatrixRotationY(matRotation, D3DX_PI); // flip it around
D3DXMatrixTranslationX(matTranslation, textureDesc.Width, 0, 0); // move it back to its original position, since rotation it will offset it
matTransform = matRotation * matTranslation * matTransform;
pSpriteInterface->SetTransform(&matTransform);
pSprite->Draw(pBackFaceTexture, ...);


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