EnableDefaultLighting() публичный Метод

public EnableDefaultLighting ( ) : void
Результат void
Пример #1
0
        public GameMap(Game game, Map map)
        {
            _game = game;
            _map = map;
            _width =(int) map.Sizes.X + 1;
            _height = (int)map.Sizes.Y + 1;
            _basicEffect = new BasicEffect(game.GraphicsDevice)
                                            {
                                                FogEnabled = map.FogEnabled,
                                                FogStart = map.ForStart,
                                                FogEnd = map.FogEnd,
                                                FogColor = map.FogColor,
                                            };

            _basicEffect.LightingEnabled = map.LightingEnabled;
            if (map.DirectionalLight0 != null)
                map.DirectionalLight0.Fill(_basicEffect.DirectionalLight0);
            if (map.DirectionalLight1 != null)
                map.DirectionalLight1.Fill(_basicEffect.DirectionalLight1);
            if (map.DirectionalLight2 != null)
                map.DirectionalLight2.Fill(_basicEffect.DirectionalLight2);

            if (map.EnableDefaultLighting)
                _basicEffect.EnableDefaultLighting();

            CreateVertices();
        }
Пример #2
0
        public void LoadContent(IServiceProvider services)
        {
            // Get the necessary services.
            _graphics = ((IGraphicsDeviceService)services.GetService(typeof(IGraphicsDeviceService))).GraphicsDevice;

            // Create a vertex declaration, describing the format of our vertex data.

            // Create a vertex buffer, and copy our vertex data into it.
            _vertexBuffer = new VertexBuffer(_graphics,
                typeof(VertexPositionNormal),
                _vertices.Count, BufferUsage.None);

            _vertexBuffer.SetData(_vertices.ToArray());

            // Create an index buffer, and copy our index data into it.
            _indexBuffer = new IndexBuffer(_graphics, typeof(ushort),
                                          _indices.Count, BufferUsage.None);

            _indexBuffer.SetData(_indices.ToArray());

            // Create a BasicEffect, which will be used to render the primitive.
            _basicEffect = new BasicEffect(_graphics);

            _basicEffect.EnableDefaultLighting();
        }
Пример #3
0
        protected override void LoadContent()
        {
            base.LoadContent();

            _basicEffect = new BasicEffect(GraphicsDevice);
            _basicEffect.EnableDefaultLighting();

            _numVertices = SIZE * SIZE;

            int numInternalRows = SIZE - 2;
            _numIndices = (2 * SIZE * (1 + numInternalRows)) + (2 * numInternalRows);

            VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[_numVertices];
            for (int z = 0; z < SIZE; z++)
            {
                for (int x = 0; x < SIZE; x++)
                {
                    vertices[GetIndex(x, z)] = new VertexPositionNormalTexture(
                        new Vector3(x, 0, -z), new Vector3(0, 1, 0),
                        new Vector2(x / (float)(SIZE - 1) * 8, z / (float)(SIZE - 1) * 8));
                }
            }

            _vertexBuffer = new VertexBuffer(
                this.GraphicsDevice,
                VertexPositionNormalTexture.VertexDeclaration,
                vertices.Length,
                BufferUsage.WriteOnly);
            _vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);

            short[] indices = new short[_numIndices]; int indexCounter = 0;
            for (int z = 0; z < SIZE - 1; z++)
            {
                // insert index for degenerate triangle
                if (z > 0)
                    indices[indexCounter++] = GetIndex(0, z);

                for (int x = 0; x < SIZE; x++)
                {
                    indices[indexCounter++] = GetIndex(x, z);
                    indices[indexCounter++] = GetIndex(x, z + 1);
                }

                // insert index for degenerate triangle
                if (z < SIZE - 2)
                    indices[indexCounter++] = GetIndex(SIZE - 1, z);
            }

            _indexBuffer = new IndexBuffer(
                this.GraphicsDevice,
                typeof(short),
                indices.Length,
                BufferUsage.WriteOnly);
            _indexBuffer.SetData<short>(indices);

            Texture2D texture = Game.Content.Load<Texture2D>(@"Textures\dirt");

            _basicEffect.Texture = texture;
            _basicEffect.TextureEnabled = true;
        }
Пример #4
0
 public BasicEffectWrapper(GraphicsDevice graphicsDevice)
 {
     _innerEffect = new BasicEffect(graphicsDevice);
     _innerEffect.EnableDefaultLighting();
     _innerEffect.PreferPerPixelLighting = true;
     _innerEffect.TextureEnabled = true;
 }
Пример #5
0
 public void Warm(GraphicsDevice device)
 {
     material = new BasicEffect(device);
     material.EnableDefaultLighting();
     material.VertexColorEnabled = true;
     material.PreferPerPixelLighting = true;
 }
Пример #6
0
    public SubmeshSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;
      var delegateGraphicsScreen = new DelegateGraphicsScreen(GraphicsService)
      {
        RenderCallback = Render,
      };
      GraphicsService.Screens.Insert(0, delegateGraphicsScreen);

      // Add a custom game object which controls the camera.
      _cameraObject = new CameraObject(Services);
      GameObjectService.Objects.Add(_cameraObject);

      var graphicsDevice = GraphicsService.GraphicsDevice;

      // The MeshHelper class can create submeshes for several basic shapes:
      _sphere = MeshHelper.CreateUVSphere(graphicsDevice, 20);
      _torus = MeshHelper.CreateTorus(graphicsDevice, 0.5f, 0.667f, 16);
      _teapot = MeshHelper.CreateTeapot(graphicsDevice, 1, 8);

      // MeshHelper.CreateBox() returns a new submesh for a box. Instead we can call
      // MeshHelper.GetBox(), which returns a shared submesh. - GetBox() will always 
      // return the same instance.
      _box = MeshHelper.GetBox(GraphicsService);

      // We can also create a submesh that uses line primitives.
      _cone = MeshHelper.GetConeLines(GraphicsService);

      // We use a normal XNA BasicEffect to render the submeshes.
      _effect = new BasicEffect(graphicsDevice) { PreferPerPixelLighting = true };
      _effect.EnableDefaultLighting();
    }
Пример #7
0
        protected override void LoadContent()
        {
            LineEffect = new BasicEffect(Game.GraphicsDevice);
            LineEffect.EnableDefaultLighting();
            LineEffect.DiffuseColor = new Vector3(1, 1, 1);
            LineEffect.VertexColorEnabled = true;
            LineEffect.LightingEnabled = false;
            LineEffect.TextureEnabled = false;

            sphereVertices = new VertexPositionColor[18];

            for (int i = 0; i <= 16; i++)
            {
                float angle = (float)Math.PI * 2.0f * (float)i / 16;
                sphereVertices[i].Color = Color.GreenYellow;
                sphereVertices[i].Position = new Vector3(Sin(angle), Cos(angle), 0);
            }

            sphereVertices[17].Color = Color.GreenYellow;
            sphereVertices[17].Position = Vector3.Zero;

            Matrix terrainWorld = Matrix.CreateScale(0.03f);

            base.LoadContent();
        }
Пример #8
0
 private static void SetupShittyStupidShit()
 {
     effect = new BasicEffect(Game1.Device);
     effect.EnableDefaultLighting();
     effect.TextureEnabled = true;
     effect.Texture = texture;
 }
Пример #9
0
        public ChunkModule(TrueCraftGame game)
        {
            Game = game;

            ChunkRenderer = new ChunkRenderer(Game.Client.World, Game, Game.BlockRepository);
            Game.Client.ChunkLoaded += (sender, e) => ChunkRenderer.Enqueue(e.Chunk);
            Game.Client.ChunkUnloaded += (sender, e) => UnloadChunk(e.Chunk);
            Game.Client.ChunkModified += (sender, e) => ChunkRenderer.Enqueue(e.Chunk, true);
            ChunkRenderer.MeshCompleted += MeshCompleted;
            ChunkRenderer.Start();

            OpaqueEffect = new BasicEffect(Game.GraphicsDevice);
            OpaqueEffect.EnableDefaultLighting();
            OpaqueEffect.DirectionalLight0.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight1.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight2.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.TextureEnabled = true;
            OpaqueEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled = true;
            OpaqueEffect.FogStart = 512f;
            OpaqueEffect.FogEnd = 1000f;
            OpaqueEffect.FogColor = Color.CornflowerBlue.ToVector3();
            OpaqueEffect.VertexColorEnabled = true;

            TransparentEffect = new AlphaTestEffect(Game.GraphicsDevice);
            TransparentEffect.AlphaFunction = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha = 127;
            TransparentEffect.Texture = Game.TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;

            ChunkMeshes = new List<ChunkMesh>();
            IncomingChunks = new ConcurrentBag<Mesh>();
            ActiveMeshes = new HashSet<Coordinates2D>();
        }
Пример #10
0
        private ShipModel(Model m, String name)
        {
            shipmodels.Add(name, this); //add to static dictionary of models
            ship = m;

            GraphicsDevice graphicsDevice = Game1.device;

            Point center = Point.Zero;

            m.Root.Transform = Matrix.CreateScale(10f);

            basicEffect = new BasicEffect(Game1.device);

            foreach (ModelMesh mesh in ship.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    part.Effect = basicEffect;
                }
            }

            // Create a BasicEffect, which will be used to render the primitive.
            //basicEffect = new BasicEffect(graphicsDevice);
            basicEffect.DiffuseColor = new Vector3(50, 50, 50);
            basicEffect.EnableDefaultLighting();
        }
Пример #11
0
		public override void onAddedToEntity()
		{
			base.onAddedToEntity();

			_basicEffect = entity.scene.content.loadMonoGameEffect<BasicEffect>();
			_basicEffect.VertexColorEnabled = true;
			_basicEffect.EnableDefaultLighting();
		}
Пример #12
0
        public Terrain(DagonGame game, int width, int length)
        {
            _basicEffect = new BasicEffect(game.GraphicsDevice) { TextureEnabled = true};

            if (game.Settings.EnableDefaultLighting)
            {
                _basicEffect.EnableDefaultLighting();
                _basicEffect.PreferPerPixelLighting = true;
            }

            _basicEffect.FogEnabled = true;
            _basicEffect.FogStart = game.Settings.RangeOfVisibility / 3f;
            _basicEffect.FogEnd = game.Settings.RangeOfVisibility;
            _basicEffect.FogColor = game.World.SkyColor.ToVector3();

            //_basicEffect.

            _game = game;

            _hightMap = new float[width + 1][];

            var random = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < width + 1; i++)
            {
                _hightMap[i] = new float[length + 1];

                for (int j = 0; j < length + 1; j++)
                {
                    _hightMap[i][j] = (float)(random.NextDouble() / 4);
                }
            }

            vertexData = new VertexPositionNormalTexture[_hightMap.Length * _hightMap[0].Length * 2 * 3];

            var index = 0;
            //TODO make map width*length size
            for (int i = 0; i < width-1; i++)
            {
                for (int j = 0; j < length-1; j++)
                {
                    vertexData[index] = CreateVertex(i, j, new Vector2(0, 0));
                    index++;
                    vertexData[index] = CreateVertex(i + 1, j, new Vector2(1, 0));
                    index++;
                    vertexData[index] = CreateVertex(i, j + 1, new Vector2(0, 1));
                    index++;

                    vertexData[index] = CreateVertex(i + 1, j, new Vector2(1, 0));
                    index++;
                    vertexData[index] = CreateVertex(i + 1, j + 1, new Vector2(1, 1));
                    index++;
                    vertexData[index] = CreateVertex(i, j + 1, new Vector2(0, 1));
                    index++;
                }
            }
        }
Пример #13
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            texturaPlano = Content.Load<Texture2D>("logo_ipca");

            efeito = new BasicEffect(GraphicsDevice);

            efeitoPlano = new BasicEffect(GraphicsDevice);
            efeitoPlano.TextureEnabled = true;
            efeitoPlano.EnableDefaultLighting();
            efeitoPlano.Texture = texturaPlano;
        }
Пример #14
0
        public static void ApplyToBasicEffect(BasicEffect effect)
        {
            effect.EnableDefaultLighting();

            effect.DirectionalLight0.Direction = new Vector3(-1.0f, 0.0f, 0.0f);
            effect.DirectionalLight0.DiffuseColor = new Vector3(0.95f);

            effect.DirectionalLight1.Enabled = false;
            effect.DirectionalLight2.Enabled = false;

            effect.AmbientLightColor = new Vector3(0.05f);
        }
Пример #15
0
        public Obstacle(Vector3 position, Color color)
        {
            unitCube = GameMultiVerse.Instance.Content.Load<Model>("Models/cube");
            basicEffect = new BasicEffect(GameMultiVerse.Instance.GraphicsDevice);

            Matrix W = Matrix.CreateTranslation(position);
            boundingBox = Collision.UpdateBoundingBox(unitCube, W);

            basicEffect.EnableDefaultLighting();
            basicEffect.World = W;
            basicEffect.DiffuseColor = color.ToVector3();
        }
Пример #16
0
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     cam = new FreeCamera(new Vector3(10, 10, 60), 0, 0, GraphicsDevice);
     setupworld();
     groundeffect = new BasicEffect(GraphicsDevice);
     groundeffect.TextureEnabled = true;
     groundeffect.EnableDefaultLighting();
     groundeffect.Texture = Content.Load<Texture2D>("Checker");
     ground = new VertexPositionNormalTexture[6];
     setupground();
     base.Initialize();
 }
Пример #17
0
        public override void Initialize()
        {
            base.Initialize();



            effect = new BasicEffect(Game.GraphicsDevice);
            effect.EnableDefaultLighting();
            effect.LightingEnabled = false;
            effect.AmbientLightColor = new Vector3(255, 255, 255);

            SetUpBuffers();
        }
Пример #18
0
        public ColorCube(GraphicsDevice graphicsDevice, float size)
        {
            // A cube has six faces, each one pointing in a different direction.
            Vector3[] normals =
            {
                new Vector3(0, 0, 1),
                new Vector3(0, 0, -1),
                new Vector3(1, 0, 0),
                new Vector3(-1, 0, 0),
                new Vector3(0, 1, 0),
                new Vector3(0, -1, 0),
            };

            List<VertexPositionColor> vertices = new List<VertexPositionColor>();
            List<ushort> indices = new List<ushort>();

            // Create the 6 faces
            foreach (Vector3 normal in normals)
            {
                // Get two vectors perpendicular to the face normal and to each other.
                Vector3 side1 = new Vector3(normal.Y, normal.Z, normal.X);
                Vector3 side2 = Vector3.Cross(normal, side1);

                ushort firstVertex = (ushort)vertices.Count;

                // Break the square face into two triangles
                AddSideIndices(indices, firstVertex);

                // Four vertices per face.
                vertices.Add(new VertexPositionColor((normal - side1 - side2) * size / 2, Color.Red));
                vertices.Add(new VertexPositionColor((normal - side1 + side2) * size / 2, Color.Blue));
                vertices.Add(new VertexPositionColor((normal + side1 + side2) * size / 2, Color.Yellow));
                vertices.Add(new VertexPositionColor((normal + side1 - side2) * size / 2, Color.White));
            }

            // Create a vertex buffer, and copy our vertex data into it.
            vertexBuffer = new VertexBuffer(graphicsDevice,
                                            typeof(VertexPositionColor),
                                            vertices.Count, BufferUsage.None);
            vertexBuffer.SetData(vertices.ToArray());

            // Create an index buffer, and copy our index data into it.
            indexBuffer = new IndexBuffer(graphicsDevice, typeof(ushort),
                                          indices.Count, BufferUsage.None);
            indexBuffer.SetData(indices.ToArray());

            // Create a BasicEffect, which will be used to render the primitive.
            basicEffect = new BasicEffect(graphicsDevice);
            basicEffect.EnableDefaultLighting();
            basicEffect.PreferPerPixelLighting = true;
        }
        /// <summary>
        /// Once all the geometry has been specified by calling AddVertex and AddIndex,
        /// this method copies the vertex and index data into GPU format buffers, ready
        /// for efficient rendering.
        protected void InitializePrimitive(GraphicsDevice graphicsDevice)
        {
            // Create a vertex buffer, and copy our vertex data into it.
            vertexBuffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionNormal), vertices.Count, BufferUsage.None);
            vertexBuffer.SetData(vertices.ToArray());

            // Create an index buffer, and copy our index data into it.
            indexBuffer = new IndexBuffer(graphicsDevice, typeof(ushort), indices.Count, BufferUsage.None);
            indexBuffer.SetData(indices.ToArray());

            // Create a BasicEffect, which will be used to render the primitive.
            basicEffect = new BasicEffect(graphicsDevice);
            basicEffect.EnableDefaultLighting();
        }
Пример #20
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;

            // TODO: Add your initialization logic here

            effect = new BasicEffect(GraphicsDevice);
            effect.EnableDefaultLighting();
            effect.PreferPerPixelLighting = true;

            Window.Title = "Pila 2 (Alt + Enter for full screen)";

            base.Initialize();
        }
Пример #21
0
        protected override void LoadContent()
        {
            texture = this.Game.Content.Load<Texture2D>("checker");
            effect = new BasicEffect(this.GraphicsDevice);
            effect.EnableDefaultLighting();
            effect.SpecularColor = new Vector3(0.1f, 0.1f, 0.1f);

            effect.World = Matrix.Identity;
            effect.TextureEnabled = true;

            effect.Texture = texture;

            base.LoadContent();
        }
Пример #22
0
 protected override void Initialize()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     cam = new FreeCamera(new Vector3(10, 10, 60), 0, 0, GraphicsDevice);
     groundeffect = new BasicEffect(GraphicsDevice);
     groundeffect.TextureEnabled = true;
     groundeffect.EnableDefaultLighting();
     groundeffect.Texture = Content.Load<Texture2D>("Checker");
     ground = new VertexPositionNormalTexture[6];
     setupground();
     setupworld();
     addboat();
     base.Initialize();
 }
Пример #23
0
        public override void LoadContent(ContentManager c, GraphicsDevice g)
        {
            base.LoadContent(c, g);

            currentMesh = createCube(c);
            effect = new BasicEffect(g);
            effect.PreferPerPixelLighting = true;
            effect.TextureEnabled = true;
            effect.Texture = currentMesh.Texture;
            effect.EnableDefaultLighting();

            cam = new FirstPersonCamera(0.5f, 5f);
            cam.Pos = new Vector3(0, 2, 4);
        }
Пример #24
0
        protected override void LoadContent()
        {
            basicEffect = new BasicEffect (Game.GraphicsDevice);
            var colorTexture = Game.Content.Load<Texture2D> ("seamlesscarpet");
            var game = Game as Startup;
            basicEffect.EnableDefaultLighting ();

            basicEffect.World = Matrix.CreateScale (20) *
                                Matrix.CreateTranslation (GameData.GlobalData.Ground);

            basicEffect.View = game.View;
            basicEffect.Projection = game.Projection;
            basicEffect.TextureEnabled = true;
            basicEffect.Texture = colorTexture;
        }
Пример #25
0
        public virtual void Draw(BasicEffect effect, Camera camera)
        {
            effect.EnableDefaultLighting();
            effect.LightingEnabled = true;
            effect.World = Matrix.CreateScale(scale) * Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position);
            effect.View = camera.View;
            effect.Projection = camera.Projection;
            effect.Texture = texture;
            effect.TextureEnabled = true;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                effect.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
            }
        }
Пример #26
0
        public Building(Game game)
            : base(game)
        {
            Model = CreateBuildingModelAuto(game, game.GraphicsDevice);

            effect = new BasicEffect(game.GraphicsDevice, new EffectPool());
            effect.DiffuseColor = Color.Gray.ToVector3();
            effect.EnableDefaultLighting();
            effect.PreferPerPixelLighting = true;

            vpntDec = new VertexDeclaration(game.GraphicsDevice, VertexPositionNormalTexture.VertexElements);

            this.CollisionType = EntityCollisionType.BuildingSpecial;

            //texture = new Texture2D(game.GraphicsDevice,
        }
Пример #27
0
        public Terreno(GraphicsDevice device, Texture2D imagemMapaAlturas, Texture2D texturaPlano, float tamanhoPlano, Texture2D textura)
        {
            larguraMapa = imagemMapaAlturas.Width;
            texturaTerreno = textura;
            tamanhoMapa = (imagemMapaAlturas.Height * imagemMapaAlturas.Width);
            this.texturaMapa = imagemMapaAlturas;
            effect = new BasicEffect(device);
            worldMatrix = Matrix.Identity;
            float aspectRatio = (float)device.Viewport.Width / device.Viewport.Height;

            effect.View = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 10.0f), Vector3.Zero, Vector3.Up);//para onde aponta a camara
            effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 0.01f, 1000.0f);
            effect.LightingEnabled = true;
            effect.EnableDefaultLighting();
            effect.DirectionalLight0.Enabled = true;
            effect.DirectionalLight0.Direction = new Vector3(1, -1, 1);
            effect.DirectionalLight0.SpecularColor = new Vector3(0.2f, 0.2f, 0.2f);
            effect.SpecularPower = 100f;
            effect.SpecularColor = new Vector3(1, 1, 1);
            effect.DirectionalLight1.Enabled = false;
            effect.DirectionalLight2.Enabled = false;
            //effect.AmbientLightColor = new Vector3(0, 0.1f, 0.1f);
            //effect.VertexColorEnabled = true;
            effect.Texture = texturaTerreno;
            effect.TextureEnabled = true;
            effect.EmissiveColor = new Vector3(0, 0, 1);

            //effect.LightingEnabled = true;
            //effect.EnableDefaultLighting();

            //effect.DirectionalLight0.Enabled = true;
            //effect.DirectionalLight0.Direction = new Vector3(0, 0, -1);
            ////effect.VertexColorEnabled = true;
            //effect.Texture = this.textura;
            //effect.TextureEnabled = true;

            lerMapaAlturas(imagemMapaAlturas);
            createGeometry(device);

            vertexBuffer = new VertexBuffer(device, typeof(VertexPositionNormalTexture), vertices.Length, BufferUsage.None);
            vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);

            indexBuffer = new IndexBuffer(device, typeof(short), indice.Length, BufferUsage.None);
            indexBuffer.SetData<short>(indice);

            //this.plano = new Plano(device, texturaPlano, tamanhoPlano);
        }
Пример #28
0
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     cam = new FreeCamera(new Vector3(10, 10, 60), 0, 0, GraphicsDevice);
     setupworld();
     addparticles();
     thr = new Thread(new ThreadStart(applyphysics));
     thr.Name = "Physics";
     thr.Start();
     //addparticle(new Vector3(0, 30, 0), Color.Red, 10);
     groundeffect = new BasicEffect(GraphicsDevice);
     groundeffect.TextureEnabled = true;
     groundeffect.EnableDefaultLighting();
     groundeffect.Texture = Content.Load<Texture2D>("Checker");
     ground = new VertexPositionNormalTexture[6];
     setupground();
     base.Initialize();
 }
Пример #29
0
        public MapDetailsRenderer3d(Game game, Point tileSize, int x, int y, int width, int height, Texture2D playerTile)
            : base(game, tileSize, x, y, width, height, playerTile)
        {
            _graphicsDevice = game.GraphicsDevice;
            _effect = new BasicEffect(_graphicsDevice);
            _effect.EnableDefaultLighting();
            _effect.World = Matrix.Identity;

            var tileCount = TilesToDisplay * TilesToDisplay;
            //TODO(deccer) replace with MonoGame/custom counterpart
            /*
            _cubes = new GeometricPrimitive[tileCount];
            for (var i = 0; i < tileCount; ++i)
            {
                _cubes[i] = GeometricPrimitive.Cube.New(_graphicsDevice, 0.5f, true);
            }
            */
        }
Пример #30
0
        protected override void LoadContent()
        {
            base.LoadContent();
            BoundingBox box = new BoundingBox(new Vector3(-1,-1,-1),new Vector3(1,1,1) );
            Vector3[] boxCornersVertices = box.GetCorners();

            _boxCorners = new VertexPositionColor[boxCornersVertices.Length];
            for (int i = 0; i < 8; i++)
                _boxCorners[i] = new VertexPositionColor(boxCornersVertices[i], Color.White);

            _boxIndices = new int[24];
            _boxIndices[0] = 0;
            _boxIndices[1] = 1;
            _boxIndices[2] = 1;
            _boxIndices[3] = 2;
            _boxIndices[4] = 2;
            _boxIndices[5] = 3;
            _boxIndices[6] = 3;
            _boxIndices[7] = 0;
            _boxIndices[8] = 0;
            _boxIndices[9] = 4;
            _boxIndices[10] = 3;
            _boxIndices[11] = 7;
            _boxIndices[12] = 2;
            _boxIndices[13] = 6;
            _boxIndices[14] = 1;
            _boxIndices[15] = 5;
            _boxIndices[16] = 4;
            _boxIndices[17] = 5;
            _boxIndices[18] = 5;
            _boxIndices[19] = 6;
            _boxIndices[20] = 6;
            _boxIndices[21] = 7;
            _boxIndices[22] = 7;
            _boxIndices[23] = 4;

            effect = new BasicEffect(GraphicsDevice);
            effect.EnableDefaultLighting();
            effect.AmbientLightColor = new Vector3(150, 0, 0);
            effect.PreferPerPixelLighting = true;
            effect.LightingEnabled = true;
            effect.TextureEnabled = false;
        }