Ejemplo n.º 1
0
        /// <summary>
        /// Crear nube de puntos aleatorios y luego computar el mejor OBB que los ajusta
        /// </summary>
        private void generateObb()
        {
            obb.dispose();
            obb = null;

            //Crear nube ed puntos
            int   COUNT    = 10;
            float MIN_RAND = -20f;
            float MAX_RAND = 20f;

            points = new Vector3[COUNT];
            for (int i = 0; i < points.Length; i++)
            {
                float x = MIN_RAND + (float)rand.NextDouble() * (MAX_RAND - MIN_RAND);
                float y = MIN_RAND + (float)rand.NextDouble() * (MAX_RAND - MIN_RAND);
                float z = MIN_RAND + (float)rand.NextDouble() * (MAX_RAND - MIN_RAND);
                points[i] = new Vector3(x, y, z);
            }

            //Computar mejor OBB
            obb = TgcObb.computeFromPoints(points);



            if (vertices != null)
            {
                for (int i = 0; i < vertices.Length; i++)
                {
                    vertices[i].dispose();
                }
            }

            vertices = new TgcBox[points.Length];
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = TgcBox.fromSize(points[i], new Vector3(1, 1, 1), Color.White);
            }
        }