Exemplo n.º 1
0
        public void AppendPathSolid(IEnumerable <Vector3d> vertices, double radius, Colorf color)
        {
            TubeGenerator tubegen = new TubeGenerator()
            {
                Vertices         = new List <Vector3d>(vertices),
                Polygon          = Polygon2d.MakeCircle(radius, 6),
                NoSharedVertices = false
            };
            DMesh3 mesh = tubegen.Generate().MakeDMesh();

            if (Mesh.HasVertexColors)
            {
                mesh.EnableVertexColors(color);
            }
            AppendMesh(mesh, Mesh.AllocateTriangleGroup());
        }
Exemplo n.º 2
0
        public void AppendBox(Frame3f frame, Vector3f size, Colorf color)
        {
            TrivialBox3Generator boxgen = new TrivialBox3Generator()
            {
                Box = new Box3d(frame, size),
                NoSharedVertices = false
            };

            boxgen.Generate();
            DMesh3 mesh = new DMesh3();

            boxgen.MakeMesh(mesh);
            if (Mesh.HasVertexColors)
            {
                mesh.EnableVertexColors(color);
            }
            AppendMesh(mesh, Mesh.AllocateTriangleGroup());
        }
Exemplo n.º 3
0
        public void AddPoint(float t, Colorf c)
        {
            var cp = new ColorPoint()
            {
                t = t, c = c
            };

            if (points.Count == 0)
            {
                points.Add(cp);
                validRange.Contain(t);
            }
            else if (t < points[0].t)
            {
                points.Insert(0, cp);
                validRange.Contain(t);
            }
            else
            {
                for (int k = 0; k < points.Count; ++k)
                {
                    if (points[k].t == t)
                    {
                        points[k] = cp;
                        return;
                    }
                    else if (points[k].t > t)
                    {
                        points.Insert(k, cp);
                        return;
                    }
                }
                points.Add(cp);
                validRange.Contain(t);
            }
        }
Exemplo n.º 4
0
 public ColorHSV(Colorf rgb)
 {
     ConvertFromRGB(rgb);
 }
Exemplo n.º 5
0
        public void ConvertFromRGB(Colorf rgb)
        {
            this.a = rgb.a;
            float rp = rgb.r, gp = rgb.g, bp = rgb.b;

            float cmax      = rp;
            int   cmaxwhich = 0; /* faster comparison afterwards */

            if (gp > cmax)
            {
                cmax = gp; cmaxwhich = 1;
            }
            if (bp > cmax)
            {
                cmax = bp; cmaxwhich = 2;
            }
            float cmin = rp;

            //int cminwhich = 0;
            if (gp < cmin)
            {
                cmin = gp;              /*cminwhich = 1;*/
            }
            if (bp < cmin)
            {
                cmin = bp;              /*cminwhich = 2;*/
            }

            float delta = cmax - cmin;

            /* HUE */
            if (delta == 0)
            {
                this.h = 0;
            }
            else
            {
                switch (cmaxwhich)
                {
                case 0:     /* cmax == rp */
                    h = 60.0f * (((gp - bp) / delta) % 6.0f);
                    break;

                case 1:     /* cmax == gp */
                    h = 60.0f * (((bp - rp) / delta) + 2);
                    break;

                case 2:     /* cmax == bp */
                    h = 60.0f * (((rp - gp) / delta) + 4);
                    break;
                }
                if (h < 0)
                {
                    h += 360.0f;
                }
            }

            /* LIGHTNESS/VALUE */
            //l = (cmax + cmin) / 2;
            v = cmax;

            /* SATURATION */

            /*if (delta == 0) {
             * r_s = 0;
             * } else {
             * r_s = delta / (1 - fabs (1 - (2 * (l - 1))));
             * }*/
            if (cmax == 0)
            {
                s = 0;
            }
            else
            {
                s = delta / cmax;
            }
        }
Exemplo n.º 6
0
        public static void AppendBox(DMesh3 mesh, Frame3f frame, Vector3f size, Colorf color)
        {
            var editor = new MeshEditor(mesh);

            editor.AppendBox(frame, size, color);
        }
Exemplo n.º 7
0
        public static void AppendBox(DMesh3 mesh, Vector3d pos, Vector3d normal, float size, Colorf color)
        {
            var editor = new MeshEditor(mesh);

            editor.AppendBox(new Frame3f(pos, normal), size * Vector3f.One, color);
        }