Example #1
0
 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);
         }
     }
 }
Example #2
0
 public override void Draw(Graphics3D graphics)
 {
     foreach (var facet in Indices)
     {
         for (int i = 1; i < facet.Length - 1; ++i)
         {
             var a = new Vertex(Coordinates[facet[0]], Color.White, Normals[facet[0]]);
             var b = new Vertex(Coordinates[facet[i]], Color.White, Normals[facet[i]]);
             var c = new Vertex(Coordinates[facet[i + 1]], Color.White, Normals[facet[i + 1]]);
             graphics.DrawTriangle(a, b, c);
         }
         if (VirisbleNormals)
         {
             for (int i = 0; i < Coordinates.Length; ++i)
             {
                 var a = new Vertex(Coordinates[i], Color.White, Normals[i]);
                 var b = new Vertex(Coordinates[i] + Normals[i], Color.White, Normals[i]);
                 graphics.DrawLine(a, b);
             }
         }
     }
 }
Example #3
0
        public override void Draw(Graphics3D graphics)
        {
            bool textureActiveInfo = graphics.IsActiveTexture;

            graphics.IsActiveTexture = true;
            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);
                }
            }

            graphics.IsActiveTexture = textureActiveInfo;
            graphics.ActiveTexture   = curTexture;
        }
Example #4
0
        public override void Draw(Graphics3D graphics)
        {
            graphics.DrawPoint(new Vertex(new Vector(0.5, 0.5, 0.5), Color.Yellow));
            graphics.DrawLine(new Vertex(new Vector(0.5, 0.5, 0.5), Color.Yellow), new Vertex(new Vector(0, 0, 0), Color.Yellow));
            foreach (var facet in Indices)
            {
                var    verts = facet.Distinct().ToArray();
                Vector norm  = Normals[verts[0]];
                norm = Vector.CrossProduct((Coordinates[facet[0]] - Coordinates[facet[1]]), (Coordinates[facet[1]] - Coordinates[facet[2]]));



                if (Vector.AngleBet((new Vector(0.5, 0.5, 0.5)), norm) > Math.PI / 2)
                {
                    for (int i = 0; i < facet.Length; ++i)
                    {
                        var a = new Vertex(Coordinates[facet[i]], Color.White, Normals[facet[i]]);
                        var b = new Vertex(Coordinates[facet[(i + 1) % facet.Length]], Color.White, Normals[facet[(i + 1) % facet.Length]]);
                        graphics.DrawLine(a, b);
                    }
                }
            }
        }