Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

since now I always used sprited to draw in 2D:

spriteBatch.Draw(myTexture, rectangle, color);

(I suppose the texture is binded internally to 2 triangles and then scaled.)

Now, I'm porting my game in 3D and I have to draw several planes (walls, floor, roof,..). Do I need to manually binding a texture to a geometry (for example using VertexPositionColorTexture with VertexBuffer and IndexBuffer), or is there any simpler way to do that?

I'm looking for something like spriteBatch.Draw with the rectangle clip specified in 3d space:

spriteBatch.Draw(myTexture, rectangleIn3D, color);
share|improve this question
3  
You need a manual implementation, Google 'billboards' - unfortunately SpriteBatch is built exclusively for 2D stuff. –  Jonathan Dickinson Nov 24 '11 at 15:51
    
While you can "kind of" use SpriteBatch in 3D (starting point), you probably shouldn't for what you're doing. –  Andrew Russell Nov 25 '11 at 6:45
add comment

2 Answers

up vote 2 down vote accepted

As a complement to Andrew's link, here's a more recent post Shawn wrote on this:

http://blogs.msdn.com/b/shawnhar/archive/2011/01/12/spritebatch-billboards-in-a-3d-world.aspx

But I don't recommend it either. That technique might be neat to create billboards and impostors, or placing text within a 3D world. But not to generate the floors and walls of an entire level.

If you're thinking about taking your 2D level data and procedurally generating a 3D level, I think you'd be better off writing an algorithm to generate all of the geometry from it (i.e. create and fill vertex index buffers, etc.).

share|improve this answer
    
Thanks.. that's what I was looking for. I know that isn't a good approach using 2d to simulate 3d, but I need it only for debug purposes. It saves me a lot of time. –  Heisenbug Dec 8 '11 at 12:26
    
Always good to have some shortcuts at hand for prototyping. :) –  David Gouveia Dec 8 '11 at 20:28
add comment

Model and texturize your scenario with a 3d modeler like blender or 3ds max, export it to fbx, and load it as a 3d model in xna.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.