errolian

How would I approach a 3D representation of a playing card(s)

If using a model, would 52 different models be required so that each card has it's own texture

Can user primitives (i.e. 2 triangles to make a card shape) have different textures on each side

What would be the best method for this


Re: XNA Game Studio Express 3D Playing Cards ?

zxdgsadf

C# is heavily object oriented. You would be smart to learn all you can about objects and instances for the moment, but continue to learn beyond that.

The reason I say that is when you approach this question from an object oriented standpoint, the answer falls in your lap. You would want a class called card and create 52 instances of your class with each one having a unique value for Card.rank and then key what texture gets loaded depending on the value of a particular instances Card.rank property.

C#, and so Xna, is so heavily structured with object oriented concepts that understanding them is a must. Fortunately there is more than enough free info out there on the web and learning all you can about OOP will serve you well long after you're finished with this idea and have moved on to other things.

Hint: To make the math easier when dealing with cards, instead of only one property called rank you can use two properties, rank and suit. This makes comparative functions for dealing with AI decisions in card games much easier to write.

Scott





Re: XNA Game Studio Express 3D Playing Cards ?

Bill Reiss

I don't think this answered the question asked. The question is would you have 52 models that include texture definitions, or would you "skin" the model with a different face texture based on its value and store the textures separately associating them programmatically with the card at run time

I'm interested in opinions on this as well, it may be easier programmatically to create 52 separate models in a modeling program, but there is so much that is duplicated.

I'm leaning toward programmatically adding the textures, because then you could also have different faces and backs available to the player, where if they are static in the models there is much less flexibility.

If someone comes up with a good 3D card rendering engine for XNA, please let me know, one project I have wanted to work on is a card game engine which would make it easy to implement card games and solitaire games.






Re: XNA Game Studio Express 3D Playing Cards ?

XNA Rockstar

I would be very interested in a card game engine too.



Re: XNA Game Studio Express 3D Playing Cards ?

Fluxtah

Is it possible to use one card, and one texture containing all the cards and the back, then possibly make a shader that takes in a card number parameter that can be used to offset the texture accordingly

I am just speculating here but I cant see why it wouldnt work :)





Re: XNA Game Studio Express 3D Playing Cards ?

Fluxtah

 errolian wrote:

If using a model, would 52 different models be required so that each card has it's own texture

No you should just need 52 Card instances that use the same Model or vertex / index buffer, see my post above about the textures, just an idea.

 errolian wrote:

Can user primitives (i.e. 2 triangles to make a card shape) have different textures on each side

What would be the best method for this

if not you could make a flat box





Re: XNA Game Studio Express 3D Playing Cards ?

errolian

Bill, yes you are right as always. I know about objects and instancing.

What I don't know is the best or indeed any method by which you can use a single model and use different textures for the face and back of the model for each instance.

Fluxtah, shaders I know very very little about so maybe someone who does can answer that part of the question.






Re: XNA Game Studio Express 3D Playing Cards ?

dczraptor

errolian wrote:
Bill, yes you are right as always. I know about objects and instancing.

What I don't know is the best or indeed any method by which you can use a single model and use different textures for the face and back of the model for each instance.

Fluxtah, shaders I know very very little about so maybe someone who does can answer that part of the question.


You can use one model, and use a BasicEffect to change the texture on the model. You can export a plane that has both texturing on the front and back, and then set the texture UVs accordingly. Once in the program, you can use this bit of code to render your cards after you load in your textures into an array. Or you could load the textures only as you need them, or any host of other methods of data organization.

public enum Cards{Clubs1 = 0, Clubs2 = 1, Clubs3 = 2, etc}

BasicEffect effect = (BasicEffect)mesh.Effects[0];

effect.Texture = cardTextures[Cards.Clubs2];

mesh.Draw();






Re: XNA Game Studio Express 3D Playing Cards ?

Fluxtah

hmm well I am by no means an expert and I could only direct you to some of the shader books I have, which will not immediately help you.





Re: XNA Game Studio Express 3D Playing Cards ?

Bill Reiss

And when I say I'd like a 3D card rendering engine, I'm not talking about the dime-a-dozen card engines out there, I'm talking about something almost photo-realistic for the cards (similar to how pretty the Pocket-Jongg sample in the video montage makes those mah-jongg tiles look). And I'd like it to be free to the XNA community. Hey well I can dream. So who wants to take that project on

Bill






Re: XNA Game Studio Express 3D Playing Cards ?

errolian

Bill Reiss wrote:

And when I say I'd like a 3D card rendering engine, I'm not talking about the dime-a-dozen card engines out there, I'm talking about something almost photo-realistic for the cards (similar to how pretty the Pocket-Jongg sample in the video montage makes those mah-jongg tiles look). And I'd like it to be free to the XNA community. Hey well I can dream. So who wants to take that project on

Bill



Exactly the same inspiration that I had for playing cards Bill.




Re: XNA Game Studio Express 3D Playing Cards ?

zxdgsadf

 errolian wrote:
How would I approach a 3D representation of a playing card(s)

If using a model, would 52 different models be required so that each card has it's own texture

... is directly answered by...

 zxdgsadf wrote:

C# is heavily object oriented. You would be smart to learn all you can about objects and instances for the moment, but continue to learn beyond that.

The reason I say that is when you approach this question from an object oriented standpoint, the answer falls in your lap. You would want a class called card and create 52 instances of your class with each one having a unique value for Card.rank and then key what texture gets loaded depending on the value of a particular instances Card.rank property.

...but I did miss...

 errolian wrote:
Can user primitives (i.e. 2 triangles to make a card shape) have different textures on each side

What would be the best method for this

... will address in a moment...

 Fluxtah wrote:

Is it possible to use one card, and one texture containing all the cards and the back, then possibly make a shader that takes in a card number parameter that can be used to offset the texture accordingly

I am just speculating here but I cant see why it wouldnt work :)

Could you Absolutely. However, the resolution would, well, suck. All 52 faces on one image would require a monster image or each card to have a small image cover the whole card face. There is a better way...

 dczraptor wrote:
You can use one model, and use a BasicEffect to change the texture on the model. You can export a plane that has both texturing on the front and back, and then set the texture UVs accordingly. Once in the program, you can use this bit of code to render your cards after you load in your textures into an array. Or you could load the textures only as you need them, or any host of other methods of data organization.

public enum Cards{Clubs1 = 0, Clubs2 = 1, Clubs3 = 2, etc}

BasicEffect effect = (BasicEffect)mesh.Effects[0];

effect.Texture = cardTextures[Cards.Clubs2];

mesh.Draw();

This is the perfect solution, if you understand what dczraptor is saying to do. If not, learn every term he says until you understand it perfectly because this is your "Holy Grail" answer.

Microsoft Flight Simulator 2004 uses precisely this approach for it's aircraft. The program maintains a variable for if a part is damaged or not and uses the appropriate texture bitmap for the part depending on if it's damaged / undamaged.

A single plane with 4 verticies that is double sided is the way to go. Use seperate images to map the card face and back and then programatically change the face image that each instance of your card class (your individual card) uses depending on the value of the individual card (Card.rank and Card.suit). You can also offer different decorative card backs the same way.

The simplest way to do that is to make your base card in a program such as Blender3D, which can make the plane double sided and add the base UV textures before exporting to .x format. Make sure that you clear size and rotation before exporting if you're using the automatic bounding box creation .dll because that .dll uses the vertice positions to create the bb without considering any translation matrix for scaling... so if your card is scaled up and exported, the card will look to be the larger size but the bounding box will only be as large as the original box that had unscaled vertice positions.

I'm in the middle of working on a first person card game also but I'm working on the chips at the moment... which have more problems for me than the cards. Well, at least I hope that the cards will be less problematic!

Scott





Re: XNA Game Studio Express 3D Playing Cards ?

errolian

Thanks for the reply, and yes, makes a lot of sense.

I'm guessing that 3DS Max doesn't produce double-sided planes which is where I'm having some trouble at the moment. I guess I'll need to get some other software.




Re: XNA Game Studio Express 3D Playing Cards ?

dczraptor

You can do it in 3dsmax very easily:

1. Create a plane.

2. Duplicate the plane.

3. Rotate one of the planes 180 degrees.

4. (optional) Attach the planes together.

5. Unwrap your planes and make the front and back UVs the same. (if the front and back of the card are identical)

6. Export.






Re: XNA Game Studio Express 3D Playing Cards ?

zxdgsadf

3DS Max has just about the same capabilities as Blender and each one takes a long time to learn. There should be a way to make faces double sided in Max but I don't know it. If you're just learning things like this in Max then don't get down on yourself if you can't get perfect results right away. I've been using Blender on and off for the last 6 years and still don't know how to make it do half the things it can do.

But the more you learn about how to make your tools do what you want them to do, the better your results will be.

I'm thinking about making a deck library that will be all 52 cards modeled, textured and with a couple of decortive backs. Nothing more because then it could be used for any sort of card game. However, at the moment, I'm trying to master getting the bb to move with the model. Once I have that down, doing a deck will simply be a matter of taking the time to code the library.

But, for now, my Eagles are in a dogfight against the Giants and I'm going to go watch the second half!

Scott