70002245 Different colors for each vertex of a single face of vdPolyface

Article 70002245
Type Wish
Product Engine
Version 1001
Date Added 7/22/2022 12:00:00 AM
Fixed 10.1002.0.5 (11/18/2022 12:00:00 AM)
Submitted by Mario Messina

Summary

Is it possible to have different colors for each vertex of a single face of vdPolyface object?

Solution

In version 1002.0.1 A new property IsIndexed of vdPolyface.GradientColors was added
Get/Set if the colors are relative to polyface vertex index (=true) or depend on the elevation z coord (=false). Default value is false.
In case of true when the vdPolyface.GradientColors.SetAt is called the passed Elevation parameter represents the index of the vdPolyFace VertexList where the color will be assigned to.
Also if IsIndexed is true the vdPolyface.GradientColors.GetAt returnts the Color assigned to the passed index for Elevation parameter.

Example:

            vdPolyface pf = new vdPolyface(doc);
            //crete a box polyface
            pf.CreateBox(new gPoint(), 1.0, 1.0, 1.0, 0.0);
            //set gradient colors for each vertex index
            pf.GradientColors.IsIndexed = true;
            //set bottom vertexes to red and yellow
            for (int i = 0; i < pf.VertexList.Count / 2; i++)
            {
                if (i % 2 == 0) pf.GradientColors.SetAt(i, Color.Yellow);
                else
                    pf.GradientColors.SetAt(i, Color.Red);
            }
            //set top vertexes to blue and green
            for (int i = pf.VertexList.Count / 2; i < pf.VertexList.Count; i++)
            {
                if (i % 2 == 0) pf.GradientColors.SetAt(i, Color.Green);
                else
                    pf.GradientColors.SetAt(i, Color.Blue);
            }
            doc.Model.Entities.AddItem(pf);//add the polyface box to model entities.
            doc.Redraw(true);//redraw scene.

Send comments on this topic.