コード例 #1
0
ファイル: ExampleModels.cs プロジェクト: whigg/PointClouds
        /// <summary>Generates a 3D PointCloud for a cylinder.</summary>
        /// <param name="Name">PointCloud name.</param>
        /// <param name="Radius">Cylinder radius.</param>
        /// <param name="Height">Cylinder height.</param>
        /// <param name="numPoints">Number of points for circular section.</param>
        /// <param name="Color">Color vector.</param>
        public static PointCloud Cuboid(float xMax, float yMax, float zMax, int pointsMaxX, int pointsMaxY, int pointsMaxZ)
        {
            float stepX = xMax / pointsMaxX;
            float stepY = yMax / pointsMaxY;
            float stepZ = zMax / pointsMaxZ;

            PointCloud     pCloud            = new PointCloud();
            int            indexInPointCloud = -1;
            List <Vector3> pointsList        = new List <Vector3>();

            for (int i = 0; i <= pointsMaxX; i++)
            {
                for (int j = 0; j <= pointsMaxY; j++)
                {
                    for (int k = 0; k <= pointsMaxZ; k++)
                    {
                        indexInPointCloud++;
                        Vector3 v = new Vector3(i * stepX, j * stepY, k * stepZ);
                        pointsList.Add(v);
                    }
                }
            }
            pCloud.Vectors = pointsList.ToArray();
            pCloud.CreateIndicesDefault();
            return(pCloud);
        }
コード例 #2
0
ファイル: ExampleModels.cs プロジェクト: whigg/PointClouds
        /// <summary>
        /// Generates a 3D PointCloud for a cuboid, by setting all lines with points
        /// </summary>
        /// <param name="Name">PointCloud name</param>
        /// <param name="u">Length of the lower part</param>
        /// <param name="v">Length of the high part</param>
        /// <param name="numberOfPoints">Number of points to use in circumference</param>
        /// <param name="Color">Color vector</param>
        /// <returns></returns>
        public static PointCloud Cuboid_AllLines(string Name, float u, float v, int numberOfPoints, System.Drawing.Color color)
        {
            PointCloud points = new PointCloud();

            float          u0         = 0f;
            float          v0         = 0f;
            List <Vector3> pointsList = new List <Vector3>();

            for (int i = 0; i < numberOfPoints; i++)
            {
                pointsList.Add(new Vector3(u0, 0, 0));
                pointsList.Add(new Vector3(0, 0, u0));
                pointsList.Add(new Vector3(u0, 0, u));
                pointsList.Add(new Vector3(u, 0, u0));
                pointsList.Add(new Vector3(0, v0, 0));
                pointsList.Add(new Vector3(0, v0, u));
                pointsList.Add(new Vector3(u, v0, u));
                pointsList.Add(new Vector3(u, v0, 0));
                pointsList.Add(new Vector3(u0, v, 0));
                pointsList.Add(new Vector3(0, v, u0));
                pointsList.Add(new Vector3(u0, v, u));
                pointsList.Add(new Vector3(u, v, u0));

                u0 += u / 100;
                v0 += v / 100;
            }


            PointCloud myPointCloud = new PointCloud();

            myPointCloud.Vectors = pointsList.ToArray();
            myPointCloud.CreateIndicesDefault();
            return(myPointCloud);
        }
コード例 #3
0
ファイル: ExampleModels.cs プロジェクト: whigg/PointClouds
        /// <summary>Generates a 3D PointCloud for a cylinder.</summary>
        /// <param name="Name">PointCloud name.</param>
        /// <param name="Radius">Cylinder radius.</param>
        /// <param name="Height">Cylinder height.</param>
        /// <param name="numPoints">Number of points for circular section.</param>
        /// <param name="Color">Color vector.</param>
        public static PointCloud Rectangle(float xMax, float yMax, int pointsMaxX, int pointsMaxY)
        {
            float stepX = xMax / pointsMaxX;
            float stepY = yMax / pointsMaxY;

            PointCloud     pCloud            = new PointCloud();
            List <Vector3> pointsList        = new List <Vector3>();
            int            indexInPointCloud = -1;

            for (int i = 0; i < pointsMaxX; i++)
            {
                for (int j = 0; j < pointsMaxY; j++)
                {
                    indexInPointCloud++;
                    Vector3 v = new Vector3(i * stepX, j * stepY, 0);
                    pointsList.Add(v);
                }
            }

            pCloud.Vectors = pointsList.ToArray();
            pCloud.CreateIndicesDefault();
            return(pCloud);
        }