コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Camera"/> class.
 /// </summary>
 public Camera()
 {
     this.fieldOfView       = (float)Math.PI / 4.0f;
     this.aspectRatio       = 1.33f;
     this.nearPlaneDistance = 1.0f;
     this.farPlaneDistance  = 800f;
     this.x              = 1;
     this.y              = 1;
     this.z              = 1;
     this.offset         = new Vector3(0, 0, 0);
     this.frustumPlanes  = new Plane[6];
     this.frustumVectors = new Vector3[8];
     UpdateProjectionMatrix();
     this.visibleObjects = new ViewableObjectCollection();
 }
コード例 #2
0
        /// <summary>
        /// Builds the terrain for the engine based upon the information about
        /// the <see cref="LJM.Similization.Server.Grid"/>.
        /// </summary>
        /// <param name="tileset"></param>
        public void InitializeEngine(Tileset tileset)
        {
            float[,] elevationData;
            elevationData = new float[this.grid.Size.Width, this.grid.Size.Height];
            OnStatusChanged(new StatusChangedEventArgs("Reading Elevation Data...", 0));

            for (int i = 0; i < this.grid.Size.Width; i++)
            {
                for (int j = 0; j < this.grid.Size.Height; j++)
                {
                    elevationData[i, j] = this.grid.GetCell(new Point(i, j)).Altitude;
                }
            }

            OnStatusChanged(new StatusChangedEventArgs("Building Quad Tree...", 10));
            Rectangle bounds = new Rectangle(0, 0, (int)(this.grid.Size.Width * 10.9), (int)(this.grid.Size.Height * 10.9));

            topNode = new QuadTreeNode(bounds, 0, 7, null);

            OnStatusChanged(new StatusChangedEventArgs("Building terrain...", 25));
            this.terrain = new Terrain(this.grid);
            this.terrain.LoadProgress += new EventHandler <StatusChangedEventArgs>(this.TerrainLoadProgress);
            this.terrain.Load(tileset);

            OnStatusChanged(new StatusChangedEventArgs("Creating Camera...", 80));
            this.currentCamera = new Camera();
            this.cameras       = new Collection <Camera>();
            this.cameras.Add(this.currentCamera);

            OnStatusChanged(new StatusChangedEventArgs("Building SkyBox...", 85));
            this.skyBox = new SkyBox(
                @"SkyBox\Dunes_Front.tga",
                @"SkyBox\Dunes_Right.tga",
                @"SkyBox\Dunes_Back.tga",
                @"SkyBox\Dunes_Left.tga",
                @"SkyBox\Dunes_Top.tga",
                @"SkyBox\Dunes_Bottom.tga");

            OnStatusChanged(new StatusChangedEventArgs("Adding Objects...", 90));
            this.viewableObjects = new ViewableObjectCollection();

            this.ready = true;
            OnStatusChanged(new StatusChangedEventArgs("Engine Loaded Successfully.", 100));
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewableObjectCollection"/> class.
 /// </summary>
 public ViewableObject()
 {
     this.quadTreeNodes = new Collection <QuadTreeNode>();
     this.children      = new ViewableObjectCollection();
 }