Example #1
0
        public void Draw(Camera camera, GameTime gametime)
        {
            RasterizerState rs = new RasterizerState();
            graphicsDevice.RasterizerState = rs;
            graphicsDevice.BlendState = BlendState.Additive;

            graphicsDevice.SetVertexBuffer(vbo);
            graphicsDevice.Indices = ibo;

            foreach (EffectTechnique et in fx.Techniques)
            {
                //rot += (float)gametime.ElapsedGameTime.TotalSeconds * 0.5f;
                //if (rot > (float)(2 * Math.PI))
                //    rot -= (float)(2 * Math.PI);
                //m_World = Matrix.CreateScale(4.0f);
                //m_World *= Matrix.CreateFromYawPitchRoll(rot, rot, rot);

                m_Projection = camera.Projection;
                m_View = camera.View;
                fx.Parameters["World"].SetValue(m_World);
                fx.Parameters["View"].SetValue(m_View);
                fx.Parameters["Projection"].SetValue(m_Projection);
                fx.CurrentTechnique = et;

                graphicsDevice.BlendState = BlendState.Opaque;
                fx.CurrentTechnique.Passes[0].Apply();
                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, verts, 0, verts.Length, wire_indices, 0, wire_indices.Length / 2);
                graphicsDevice.BlendState = BlendState.NonPremultiplied;
                fx.CurrentTechnique.Passes[1].Apply();
                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, verts, 0, verts.Length, indices, 0, indices.Length / 3);
            }
        }
        public virtual void Draw(Camera camera)
        {
            model.CopyAbsoluteBoneTransformsTo(modelTransforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.Projection = camera.Projection;
                    effect.View = camera.View;
                    effect.World = modelTransforms[mesh.ParentBone.Index] * GetWorld();
                    effect.EnableDefaultLighting();
                }
                mesh.Draw();
            }
        }
Example #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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            fx = Content.Load<Effect>("fx");

            m_camera = new Camera(new Vector3(0, 0, 10), new Vector3(0), 1f, 1000, this,view,projection);

            //voxels.Add(new Vox(Vector3.Zero, 1, Color.CornflowerBlue, GraphicsDevice, view, projection, fx));

            voxels.Add(new Vox(new Vector3(1, 0, -1), 1, Color.Aquamarine, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 0, -1), 1, Color.Red, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(1, 1, -1), 1, Color.Indigo, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 1, -1), 1, Color.LavenderBlush, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(1, 2, -1), 1, Color.LawnGreen, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 2, -1), 1, Color.Moccasin, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(0, 2, -1), 1, Color.Magenta, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(0, 0, -1), 1, Color.Maroon, GraphicsDevice, view, projection, fx));

            voxels.Add(new Vox(new Vector3(1, 0, 0), 1, Color.MediumSlateBlue, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 0, 0), 1, Color.MistyRose, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(1, 2, 0), 1, Color.Navy, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 2, 0), 1, Color.Olive, GraphicsDevice, view, projection, fx));

            voxels.Add(new Vox(new Vector3(1, 0, 1), 1, Color.PaleGreen, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 0, 1), 1, Color.Plum, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(1, 1, 1), 1, Color.PeachPuff, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 1, 1), 1, Color.RoyalBlue, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(1, 2, 1), 1, Color.Silver, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(-1, 2, 1), 1, Color.SteelBlue, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(0, 2, 1), 1, Color.Violet, GraphicsDevice, view, projection, fx));
            voxels.Add(new Vox(new Vector3(0, 0, 1), 1, Color.Turquoise, GraphicsDevice, view, projection, fx));
            // TODO: use this.Content to load your game content here
        }