CSharpGL.ChainModel.ChainModel C# (CSharp) Метод

ChainModel() публичный Метод

链条。若干个点用直线连接起来。
public ChainModel ( int pointCount = 10, int length = 5, int width = 5, int height = 5 ) : System
pointCount int 有多少个点
length int 点的范围(长度)
width int 点的范围(宽度)
height int 点的范围(高度)
Результат System
        public ChainModel(int pointCount = 10, int length = 5, int width = 5, int height = 5)
        {
            var random = new Random();
            var positions = new vec3[pointCount];
            for (int i = 0; i < pointCount; i++)
            {
                var point = new vec3();
                point.x = (float)random.NextDouble() * length;
                point.y = (float)random.NextDouble() * width;
                point.z = (float)random.NextDouble() * height;
                positions[i] = point;
            }
            BoundingBox box = positions.Move2Center();
            this.Lengths = box.MaxPosition - box.MinPosition;
            this.Positions = positions;

            this.Colors = new vec3[pointCount];
            {
                for (int i = 0; i < pointCount; i++)
                {
                    uint p = (uint)((256 * 256 * 256) / pointCount * (i + 1));
                    var color = new vec3();
                    color.x = ((p >> 0) & 0xFF) / 255.0f;
                    color.y = ((p >> 8) & 0xFF) / 255.0f;
                    color.z = ((p >> 16) & 0xFF) / 255.0f;
                    this.Colors[i] = color;
                }
            }
        }