Beispiel #1
0
        void Generate(Mesh mesh, List <Vector3> dataPoints, bool pointSphere, float pointSize)
        {
            //mesh.Clear();
            var verts     = new List <Vector3>();
            var normals   = new List <Vector3>();
            var tris      = new List <int>();
            var baseIndex = 0;

            var dimx = pointSize * scale;
            var dimy = pointSize * scale;
            var dimz = pointSize * scale;

            for (int i = 0; i < dataPoints.Count; i++)
            {
                var pos = dataPoints[i];
                if (pointSphere)
                {
                    baseIndex = GeomUtil.CreateSpheroid(
                        baseIndex,
                        xySegments,
                        zSegments,
                        dimx, dimz, dimy,
                        pos,
                        Quaternion.identity,
                        verts,
                        normals,
                        tris);
                }
                else
                {
                    baseIndex = GeomUtil.CreateCubic(
                        baseIndex,
                        dimx,
                        dimy,
                        dimz,
                        pos,
                        Quaternion.identity,
                        verts,
                        normals,
                        tris
                        );
                }
            }
            mesh.SetVertices(verts);
            mesh.SetNormals(normals);
            mesh.SetTriangles(tris, 0);
        }
Beispiel #2
0
        void Generate()
        {
            mMesh.Clear();
            var verts   = new List <Vector3>();
            var normals = new List <Vector3>();
            var tris    = new List <int>();

            int baseIndex = 0;

            float hGridW = gridWidth / 2f;
            float hGridH = gridHeight / 2f;
            float hGridD = gridDepth / 2f;

            var verticals = new List <Vector3> {
                new Vector3(-hGridW + dimx / 2, 0, -hGridD + dimz / 2f),
                new Vector3(-hGridW + dimx / 2f, 0, hGridD - dimz / 2f),
                new Vector3(hGridW - dimy / 2f, 0, hGridD - dimz / 2f),
                new Vector3(hGridW - dimy / 2f, 0, -hGridD + dimz / 2f)
            };

            foreach (var pt in verticals)
            {
                baseIndex = GeomUtil.CreateCubic(baseIndex,
                                                 dimx, gridHeight - 2 * dimy, dimz,
                                                 new Vector3(posx, posy, posz) + pt,
                                                 Quaternion.identity,
                                                 verts,
                                                 normals,
                                                 tris);
            }

            var horizontals = new List <Vector3> {
                new Vector3(0, -hGridH + dimy / 2f, -hGridD + dimz / 2f),
                new Vector3(0, -hGridH + dimy / 2f, hGridD - dimz / 2f),
                new Vector3(0, hGridH - dimy / 2f, hGridD - dimz / 2f),
                new Vector3(0, hGridH - dimy / 2f, -hGridD + dimz / 2f)
            };

            foreach (var pt in horizontals)
            {
                baseIndex = GeomUtil.CreateCubic(baseIndex,
                                                 gridWidth, dimy, dimz,
                                                 new Vector3(posx, posy, posz) + pt,
                                                 Quaternion.identity,
                                                 verts,
                                                 normals,
                                                 tris);
            }

            var depthinals = new List <Vector3> {
                new Vector3(-hGridW + dimx / 2f, -hGridH + dimy / 2f, 0),
                new Vector3(-hGridW + dimx / 2f, hGridH - dimy / 2f, 0),
                new Vector3(hGridW - dimx / 2f, hGridH - dimy / 2f, 0),
                new Vector3(hGridW - dimx / 2f, -hGridH + dimy / 2f, 0)
            };

            foreach (var pt in depthinals)
            {
                baseIndex = GeomUtil.CreateCubic(baseIndex,
                                                 dimx, dimy, gridDepth - 2 * dimz,
                                                 new Vector3(posx, posy, posz) + pt,
                                                 Quaternion.identity,
                                                 verts,
                                                 normals,
                                                 tris);
            }

            mMesh.SetVertices(verts);
            mMesh.SetNormals(normals);
            mMesh.SetTriangles(tris, 0);
        }