Disappearring instances of VertexPositionColor using MonoGame

Posted by Rosko on Game Development See other posts from Game Development or by Rosko
Published on 2013-01-19T18:35:26Z Indexed on 2013/10/18 22:19 UTC
Read the original article Hit count: 231

Filed under:
|
|

I am a complete beginner in graphics developing with XNA/Monogame. Started my own project using Monogame 3.0 for WinRT. I have this unexplainable issue that some of the vertices disappear while doing some updates on them.

Basically, it is a game with balls who collide with the walls and with each other and in certain conditions they explode. When they explode they disappear. Here is a video demonstrating the issue. I used wireframes so that it is easier to see how vertices are missing. The perfect exploding balls are the ones which are result by user input with mouse clicking. Thanks for the help.

The situations is: I draw user primitives with triangle strips using like this

graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, circleVertices, 0, primitiveCount);

All of the primitives are in the z-plane (z = 0), I thought that it is the culling in action. I tried setting the culling mode to none but it did not help.

Here is the code responsible for the explosion

private void Explode(GameTime gameTime, ref List<Circle> circles)
    {
        if (this.isExploding)
        {
            for (int i = 0; i < this.circleVertices.Length; i++)
            {
                if (this.circleVertices[i] != this.circleCenter)
                {
                    if (Vector3.Distance(this.circleVertices[i].Position, this.circleCenter.Position) < this.explosionRadius * precisionCoefficient)
                    {
                        var explosionVector = this.circleVertices[i].Position - this.circleCenter.Position;
                        explosionVector.Normalize();
                        explosionVector *= explosionSpeed;
                        circleVertices[i].Position += explosionVector * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    else
                    {
                        circles.Remove(this);
                    }
                }
            }
        }
    }

I'd be really greatful if anyone has suggestions about how to fix this issue.

© Game Development or respective owner

Related posts about XNA

Related posts about vertex