Example #1
0
 public void GenereSommets(int xMin, int xMax, int yMin, int yMax, bool auto)
 {
     if (auto)
     {
         int nbPoints = rnd.Next(8, __NBSOMMETS + 1);
         for (int i = 0; i < nbPoints; i++)
         {
             float  partieDecimaleX = (float)rnd.NextDouble();
             float  partieDecimaleY = (float)rnd.NextDouble();
             float  x = rnd.Next(xMin + 1, xMax - 1) + partieDecimaleX;
             float  y = rnd.Next(yMin + 1, yMax - 1) + partieDecimaleY;
             Sommet s = new Sommet(x, y, true);
             if (!Sommets.Exists(z => z.IsEqual(s) || (z.CalculeDistance(s) < 1))) //si le sommet s n'est pas déjà dans les sommets du graphe et à une distance >= 1 des autres sommets
             {
                 Sommets.Add(s);
             }
         }
     }
     else
     {
         Sommets.Add(new Sommet((float)1.8, (float)9, true));
         Sommets.Add(new Sommet((float)1.3, (float)6.5, true));
         Sommets.Add(new Sommet((float)2.9, (float)4.5, true));
         Sommets.Add(new Sommet((float)3.8, (float)7, true));
         Sommets.Add(new Sommet((float)4.5, (float)5.5, true));
         Sommets.Add(new Sommet((float)5.3, (float)7, true));
         Sommets.Add(new Sommet((float)6.5, (float)4.5, true));
         Sommets.Add(new Sommet((float)9, (float)4.5, true));
     }
 }
Example #2
0
        public Sommet DeterminePointFinal(bool auto)
        {
            Sommet s;

            if (auto)
            {
                int compteur = 0;
                //on ne veut pas prendre le SommetInitial comme SommetFinal donc on le supprime des sommets à tester
                List <int> indicesDejaTestes = new List <int>(Sommets.IndexOf(SommetInitial));
                int        n = Sommets.Count;
                do
                {
                    int k;
                    do
                    {
                        k = rnd.Next(n);
                    }while (indicesDejaTestes.Contains(k));
                    indicesDejaTestes.Add(k);
                    s = Sommets[k];
                    compteur++;
                }
                //tant que les sommets initial et final ne sont pas assez éloignés et qu'on a pas parcouru tous les sommets du graphe
                while (PointsInitialFinalAssezEloignes(s) == false && compteur < n);
            }
            else
            {
                s = Sommets[6];
            }
            return(s);
        }
Example #3
0
        public override void Draw(GameTime gameTime)
        {
            DepthStencilState ancienDepthStencilState = GraphicsDevice.DepthStencilState;
            DepthStencilState temporaire = new DepthStencilState();

            temporaire.DepthBufferEnable     = false;
            GraphicsDevice.DepthStencilState = temporaire;
            GraphicsDevice.RasterizerState   = RasterizerState.CullClockwise;
            EffetDeBase.World      = GetMonde();
            EffetDeBase.View       = CaméraJeu.Vue;
            EffetDeBase.Projection = CaméraJeu.Projection;

            foreach (VertexPositionColor[] Sommets in ListeSommets)
            {
                foreach (EffectPass passeEffet in EffetDeBase.CurrentTechnique.Passes)
                {
                    passeEffet.Apply();
                    NbDeTriangles = Sommets.Count() - 2;
                    if (NbDeTriangles > 0)
                    {
                        GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.TriangleStrip, Sommets, 0, NbDeTriangles);
                        //GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, SommetsPointillés, 0, NbDeTriangles);
                    }
                }
            }

            GraphicsDevice.DepthStencilState = ancienDepthStencilState;
            GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;
        }