예제 #1
0
파일: BSPTree.cs 프로젝트: Mantora/GA
 //fügt ein GraphicsEntity den nodes hinzu
 public void addObject(GraphicsEntity ent)
 {
     if (!this.root.AddObject(ent))
     {
         throw new Exception("BSP to small for world!");
     }
 }
예제 #2
0
파일: BSPTree.cs 프로젝트: Mantora/GA
        //Methode zum hinzufügen eines objektes
        //return: ist das Object vollständig in diesem BSPNode
        public bool AddObject(GraphicsEntity ent)
        {
            //prüfen ob dieses Object komplett in diesem Bereich liegt
            //ja: liegt in dieser Ebene
            //nein: eine eben tiefer kontrollieren

            switch (this.bb.Contains(ent.BoundingBox))
            {
            case ContainmentType.Contains:
                //beinhaltet

                //unterboxen erstellen zum kontrollieren
                initChildNotes();
                //unterboxen durchgehen
                foreach (BSPNode node in this.childNodes)
                {
                    if (node.AddObject(ent))
                    {
                        return(true);
                    }
                }
                this.contents.Add(ent);
                return(true);

                break;
            }
            return(false);
        }
예제 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Model shipmodel = Content.Load <Model>("Models//sphere");

            Texture2D[] textures = new Texture2D[3];
            textures[0] = Content.Load <Texture2D>("Textures/checker1");
            textures[1] = Content.Load <Texture2D>("Textures/checker2");
            textures[2] = Content.Load <Texture2D>("Textures/checker3");

            this.spheres = new List <GraphicsEntity>();
            for (int i = 0; i < numSpheres; ++i)
            {
                GraphicsEntity newShip = new GraphicsEntity();
                newShip.Position    = new Vector3(this.randomFloat(minX, maxX), this.randomFloat(minY, maxY), this.randomFloat(minZ, maxZ));
                newShip.Model       = shipmodel;
                newShip.BoundingBox = new BoundingBox(new Vector3(-0.4f, -0.4f, -0.4f), new Vector3(0.4f, 0.4f, 0.4f));
                newShip.Texture     = textures[this.rand.Next(0, 3)];

                this.spheres.Add(newShip);
                this.bsp.addObject(newShip);
            }

            this.font = Content.Load <SpriteFont>("Fonts//SpriteFont1");
        }