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.

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.

share|improve this question
add comment

1 Answer 1

From looking at the video and your Explode() method, I am taking a guess that under certain conditions your vertices are located at the center and therefor are not getting updated correctly. Is there any particular reason that this check is in there?

if (this.circleVertices[i] != this.circleCenter)
{
...
}

I would try disabling that condition and see what happens.

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.