• Advertisement
Sign in to follow this  

A Playing Card

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

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
Advertisement
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
Sign in to follow this  

  • Advertisement