예제 #1
0
        public void AddCamera(Camera camera)
        {
            if (!cameras.ContainsKey(camera.Id))
            {
                cameras.Add(camera.Id, camera);

                if (cameras.Count == 1)
                    SetActiveCamera(camera.Id);
            }
        }
예제 #2
0
        public void SetActiveCamera(string id)
        {
            if (cameras.ContainsKey(id))
            {
                if (_activeCameraId != id)
                {
                    _activeCamera = cameras[id];
                    _activeCamera.Initialise();

                    _activeCameraId = id;
                }
            }
        }
예제 #3
0
        public override void Draw(Camera camera)
        {
            foreach (ModelMesh mesh in Model3D.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.View = camera.View;
                    effect.Projection = camera.Projection;
                    effect.World = BoneTransforms[mesh.ParentBone.Index] * World;

                    effect.PreferPerPixelLighting = true;
                }
                mesh.Draw();
            }

            base.Draw(camera);
        }
예제 #4
0
        public override void Draw(Camera camera)
        {
            foreach (ModelMesh mesh in Model3D.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.View = camera.View;
                    effect.Projection = camera.Projection;
                    effect.World = BoneTransforms[mesh.ParentBone.Index] * World;

                    effect.PreferPerPixelLighting = true;

                    if (IsHover)  // Add the yellow colour.
                    {
                        effect.FogEnabled = true;
                        effect.FogColor = new Vector3(50.0f, 50.0f, 0.0f);
                    }
                    else if (IsSelected)
                    {
                        effect.FogEnabled = true;
                        effect.FogColor = new Vector3(50.0f, 55.0f, 0.0f);
                    }
                    else if (IsMoveOption)
                    {
                        effect.FogEnabled = true;
                        effect.FogColor = Color.CornflowerBlue.ToVector3();
                    }
                    else
                        effect.FogEnabled = false;

                }
                mesh.Draw();
            }

            base.Draw(camera);
        }
예제 #5
0
        public void Draw(Camera camera)
        {
            if (camera == null) return;
            _effect.View = camera.View;
            _effect.Projection = camera.Projection;

            int vertexCount = ActiveShapes.Sum(shape => shape.LineCount*2);

            if (vertexCount > 0)
            {
                if (_verts.Length < vertexCount)
                {
                    _verts = new VertexPositionColor[vertexCount * 2];
                }

                int lineCount = 0;
                int vertIndex = 0;
                foreach (DebugShape shape in ActiveShapes)
                {
                    lineCount += shape.LineCount;
                    int shapeVerts = shape.LineCount * 2;
                    for (int i = 0; i < shapeVerts; i++)
                        _verts[vertIndex++] = shape.Vertices[i];
                }

                _effect.CurrentTechnique.Passes[0].Apply();

                int vertexOffset = 0;
                while (lineCount > 0)
                {
                    int linesToDraw = Math.Min(lineCount, 65535);

                    Helper.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;

                    Helper.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, _verts, vertexOffset, linesToDraw);

                    vertexOffset += linesToDraw * 2;

                    lineCount -= linesToDraw;
                }
            }

            bool resort = false;
            for (int i = ActiveShapes.Count - 1; i >= 0; i--)
            {
                DebugShape s = ActiveShapes[i];

                if (s.Lifetime <= 0)
                {
                    CachedShapes.Add(s);
                    ActiveShapes.RemoveAt(i);
                    resort = true;
                }
            }

            if (resort)
                CachedShapes.Sort(CachedShapesSort);
        }
예제 #6
0
 public virtual void Draw(Camera camera)
 {
 }
예제 #7
0
        public virtual void Initialize()
        {
            GameBoard = new Board(_IsAnimated);

            TimeWhite = TimeSpan.FromHours(1);
            TimeBlack = TimeSpan.FromHours(1);

            #region Cameras
            CamWhite = new Camera("camWhite",
                new Vector3(1, 60, 60),
                new Vector3(1, 5, 4),
                _aspectRatio);

            CamBlack = new Camera("camBlack",
                new Vector3(0, 60, -61),
                new Vector3(0, 5, -5),
                _aspectRatio);

            Engine.Cameras.AddCamera(CamWhite);
            Engine.Cameras.AddCamera(CamBlack);

            #endregion

            GameBoard.Squares[CurrentI, CurrentJ].IsHover = true;
            foreach (GameObject3D t in SceneObjects)
                t.Initialise();

            MoveGen.Init(GameBoard);
            BitboardHelper.Initialize();
        }