public void calc_points_circle(int quality, ref cylinder_pr cur)
        {
            float x = cur.x;
            float z = cur.z;
            float y = cur.y - cur.H / 2;
            float r = cur.R;

            cur.base_cylinder_x.Clear();
            cur.base_cylinder_y.Clear();
            cur.base_cylinder_z.Clear();
            cur.base_cylinder_x_d.Clear();
            cur.base_cylinder_y_d.Clear();
            cur.base_cylinder_z_d.Clear();
            for (int i = 0; i < quality; i++)
            {
                float angle = 2f * 3.14f * (float)i / (float)quality;
                float dx    = r * (float)Math.Cos(angle);
                float dz    = r * (float)Math.Sin(angle);
                cur.base_cylinder_x.Add(x + dx);
                cur.base_cylinder_x_d.Add(x + dx);
                cur.base_cylinder_z.Add(z + dz);
                cur.base_cylinder_z_d.Add(z + dz);
                cur.base_cylinder_y.Add(y);
                cur.base_cylinder_y_d.Add(y + cur.H);
            }
        }
        public void cylinder_build(int num, float x, float y, float z, float r, float h, int quality, ref float[,] colors)
        {
            if (num == -1)
            {
                cylinder_pr cur = new cylinder_pr();
                cur.base_cylinder_x   = new ArrayList();
                cur.base_cylinder_y   = new ArrayList();
                cur.base_cylinder_z   = new ArrayList();
                cur.base_cylinder_x_d = new ArrayList();
                cur.base_cylinder_y_d = new ArrayList();
                cur.base_cylinder_z_d = new ArrayList();
                cur.cylinder_colors   = new float[3, 3];
                cur.x_alpha           = 0.0f;
                cur.y_alpha           = 0.0f;
                cur.z_alpha           = 0.0f;
                cylinders.Add(cur);
                num = cylinders.Count - 1;
            }
            cylinder_pr t = (cylinder_pr)cylinders[num];

            t.R = r;
            t.H = h;
            t.x = x;
            t.y = y + h / 2;
            t.z = z;
            calc_points_circle(quality, ref t);
            t.cylinder_colors[0, 0] = colors[0, 0];
            t.cylinder_colors[0, 1] = colors[0, 1];
            t.cylinder_colors[0, 2] = colors[0, 2];

            t.cylinder_colors[1, 0] = colors[1, 0];
            t.cylinder_colors[1, 1] = colors[1, 1];
            t.cylinder_colors[1, 2] = colors[1, 2];

            t.cylinder_colors[2, 0] = colors[2, 0];
            t.cylinder_colors[2, 1] = colors[2, 1];
            t.cylinder_colors[2, 2] = colors[2, 2];

            float ax = t.x_alpha;
            float ay = t.y_alpha;
            float az = t.z_alpha;

            t.x_alpha      = 0.0f;
            t.y_alpha      = 0.0f;
            t.z_alpha      = 0.0f;
            cylinders[num] = t;
            if (ax != 0.0)
            {
                turn_by_x(num, ax);
            }
            if (ay != 0.0)
            {
                turn_by_y(num, ay);
            }
            if (az != 0.0)
            {
                turn_by_z(num, az);
            }
        }
        public void change_color(int num, int n, float r, float g, float b)
        {
            cylinder_pr cur = (cylinder_pr)cylinders[num];

            cur.cylinder_colors[n, 0] = r;
            cur.cylinder_colors[n, 1] = g;
            cur.cylinder_colors[n, 2] = b;
            cylinders[num]            = cur;
        }
        public void turn_by_z(int num, float alpha)
        {
            cylinder_pr cur = (cylinder_pr)cylinders[num];

            for (int i = 0; i < cur.base_cylinder_x.Count; i++)
            {
                float x   = (float)cur.base_cylinder_x[i];
                float x_d = (float)cur.base_cylinder_x_d[i];
                float y   = (float)cur.base_cylinder_y[i];
                float y_d = (float)cur.base_cylinder_y_d[i];
                cur.base_cylinder_x[i]   = (float)((x - cur.x) * (Math.Cos(alpha)) - (y - cur.y) * (Math.Sin(alpha))) + cur.x;
                cur.base_cylinder_x_d[i] = (float)((x_d - cur.x) * (Math.Cos(alpha)) - (y_d - cur.y) * (Math.Sin(alpha))) + cur.x;
                cur.base_cylinder_y[i]   = (float)((x - cur.x) * (Math.Sin(alpha)) + (y - cur.y) * (Math.Cos(alpha))) + cur.y;
                cur.base_cylinder_y_d[i] = (float)((x_d - cur.x) * (Math.Sin(alpha)) + (y_d - cur.y) * (Math.Cos(alpha))) + cur.y;
            }
            cur.z_alpha   += alpha;
            cylinders[num] = cur;
        }
        public void turn_by_y(int num, float alpha)
        {
            cylinder_pr cur = (cylinder_pr)cylinders[num];

            for (int i = 0; i < cur.base_cylinder_x.Count; i++)
            {
                float x   = (float)cur.base_cylinder_x[i];
                float x_d = (float)cur.base_cylinder_x_d[i];
                float z   = (float)cur.base_cylinder_z[i];
                float z_d = (float)cur.base_cylinder_z_d[i];
                cur.base_cylinder_x[i]   = (float)((x - cur.x) * (Math.Cos(alpha)) + (z - cur.z) * (Math.Sin(alpha))) + cur.x;
                cur.base_cylinder_x_d[i] = (float)((x_d - cur.x) * (Math.Cos(alpha)) + (z_d - cur.z) * (Math.Sin(alpha))) + cur.x;
                cur.base_cylinder_z[i]   = (float)(-(x - cur.x) * (Math.Sin(alpha)) + (z - cur.z) * (Math.Cos(alpha))) + cur.z;
                cur.base_cylinder_z_d[i] = (float)(-(x_d - cur.x) * (Math.Sin(alpha)) + (z_d - cur.z) * (Math.Cos(alpha))) + cur.z;
            }
            cur.y_alpha   += alpha;
            cylinders[num] = cur;
        }
        public void turn_by_x(int num, float alpha)
        {
            cylinder_pr cur = (cylinder_pr)cylinders[num];

            for (int i = 0; i < cur.base_cylinder_x.Count; i++)
            {
                float y   = (float)cur.base_cylinder_y[i];
                float y_d = (float)cur.base_cylinder_y_d[i];
                cur.base_cylinder_y[i]   = (y - cur.y) * (float)(Math.Cos(alpha)) + ((float)cur.base_cylinder_z[i] - cur.z) * (float)(Math.Sin(alpha)) + cur.y;
                cur.base_cylinder_y_d[i] = (y_d - cur.y) * (float)(Math.Cos(alpha)) + ((float)cur.base_cylinder_z_d[i] - cur.z) * (float)(Math.Sin(alpha)) + cur.y;
                float z   = (float)cur.base_cylinder_z[i];
                float z_d = (float)cur.base_cylinder_z_d[i];
                cur.base_cylinder_z[i]   = -(y - cur.y) * (float)(Math.Sin(alpha)) + (z - cur.z) * (float)(Math.Cos(alpha)) + cur.z;
                cur.base_cylinder_z_d[i] = -(y_d - cur.y) * (float)(Math.Sin(alpha)) + (z_d - cur.z) * (float)(Math.Cos(alpha)) + cur.z;
            }
            cur.x_alpha   += alpha;
            cylinders[num] = cur;
        }