Exemple #1
0
        public SceneView() : base()
        {
            var flags = ControlStyles.AllPaintingInWmPaint
                        | ControlStyles.DoubleBuffer
                        | ControlStyles.UserPaint;

            SetStyle(flags, true);
            ResizeRedraw = true;
            Graphics3D   = new Graphics3D(this);
        }
 public virtual void Draw(Graphics3D graphics)
 {
     foreach (var facet in Indices)
     {
         for (int i = 0; i < facet.Length; ++i)
         {
             var a = new Vertex(Coordinates[facet[i]]);
             var b = new Vertex(Coordinates[facet[(i + 1) % facet.Length]]);
             graphics.DrawLine(a, b);
         }
     }
 }
        public override void Draw(Graphics3D graphics)
        {
            var curTexture = graphics.ActiveTexture;

            graphics.ActiveTexture = texture;

            foreach (var facet in Indices)
            {
                for (int i = 1; i < facet.Length - 1; ++i)
                {
                    var a = new Vertex(Coordinates[facet[0]], uvCoordinates[facet[0]]);
                    var b = new Vertex(Coordinates[facet[i]], uvCoordinates[facet[i]]);
                    var c = new Vertex(Coordinates[facet[i + 1]], uvCoordinates[facet[i + 1]]);
                    graphics.DrawTriangle(a, b, c);
                }
            }
        }
Exemple #4
0
        private void PictureBox1_Paint(object sender, PaintEventArgs e)
        {
            //e.Graphics.FillRectangle(Brushes.Black, 0, 0, pictureBox1.Width, pictureBox1.Height);
            var graphics3D = new Graphics3D(e.Graphics, camera.ViewProjection, pictureBox1.Width, pictureBox1.Height, cur_obj.Center, camera.Position);
            var zero       = new Vector(0, 0, 0);
            var x          = new Vector(0.8, 0, 0);
            var y          = new Vector(0, 0.8, 0);
            var z          = new Vector(0, 0, 0.8);

            graphics3D.DrawLine(
                new Vertex(zero, Color.Red),
                new Vertex(x, Color.Red));
            graphics3D.DrawPoint(new Vertex(x, Color.Red));
            graphics3D.DrawLine(
                new Vertex(zero, Color.Green),
                new Vertex(y, Color.Green));
            graphics3D.DrawPoint(new Vertex(y, Color.Green));
            graphics3D.DrawLine(
                new Vertex(zero, Color.Blue),
                new Vertex(z, Color.Blue));
            graphics3D.DrawPoint(new Vertex(z, Color.Blue));
            cur_obj.Draw(graphics3D);
            e.Graphics.DrawImage(graphics3D.colorBuffer, 0, 0);
        }