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.

So I was playing around with XNA working on a 3d engine with 2d sprites as characters and objects. After a while I became very unhappy with the way the sprites were being scaled and billboarded so I created a GameSprite class that takes all the information from the texture2D(pngs) and turns it into VertexPositionColor quads on init.

these are drawn with a basic effect, a struct quad, and a quadList.

basicEffect.CurrentTechnique.Passes[0].Apply();
        foreach (ColorQuad quad in currentFrame.quadList)
        {
            graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                PrimitiveType.TriangleList,
                quad.Vertices,
                0,
                quad.Vertices.Length,
                quad.Indices,
                0,
                quad.Indices.Length / 3);
        }

(frames are different quads chopped up from the original image for animation, like a sprite sheet)

This creates a great 3D recreation of the sprite that can be zoom entirely with no blur.

Each GameSprite has its own basic effect file.

I was wondering if there was a way, maybe during LoadContent, that I could create these vertices and turn them into models for easier drawing and rendering in this 3D world and if this is even a good way to go about this and if I might experience longerterm problems using lots of these GameSprites and their many quads.

Thanks for reading!

share|improve this question
    
It's definitely doable, either before run time (Make a content processor that creates a Mesh) or at runtime (Much the same, or you can do something like what you're doing now). A problem you will have though is that you're doing a draw call for each region in the picture, which means you have about 500 ColorQuad regions before you're being bottlenecked. You should be taking all those vertices and making them a single buffer of triangles, and drawing an entire sprite (or hell, even and entire group of sprites) in one draw call. –  Phil Jan 13 '13 at 5:34
    
This seems like very much the wrong approach. Why not draw the sprites with SamplerState.PointClamp? (see this question) –  Andrew Russell Jan 13 '13 at 5:55
    
Thanks for both your answers thats exactly the kind of information I was looking for. –  Theodore Enderby Jan 13 '13 at 6:31

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.