2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I'm guessing that your Remove function doesn't completely remove something. But it's hard to tell from the video since there are so many particles and they all look the same. This issue is still happening, I would suggest adding numbers to the particles so you can see exactly which two particles explode at the end, and then go back in the video and see when they disappeared initially. Maybe they didn't even initially exist, but it's hard to tell without some way to distinguish them. \$\endgroup\$
    – Vladimir
    Commented Dec 26, 2014 at 16:51

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .