Example #1
0
        public override Mesh Build()
        {
            BAnyMeshSettings settings = this;
            Mesh             mesh     = null;

            switch (settings.meshType)
            {
            case PrimitiveMeshOptions.UserDefinedMesh:
                //Need to copy mesh from sharedMesh or we cant modify the mesh!
                if (settings.userMesh == null)     //fill in something
                {
                    settings.userMesh = ProceduralPrimitives.CreateMeshBox(settings.extents.x, settings.extents.x, settings.extents.x);
                    Debug.Log("Must provide a mesh for UserDefinedMesh setting.");
                }

                mesh = (Mesh)GameObject.Instantiate(settings.userMesh);
                break;

            case PrimitiveMeshOptions.Box:
                mesh = ProceduralPrimitives.CreateMeshBox(settings.extents.x, settings.extents.y, settings.extents.z);
                break;

            case PrimitiveMeshOptions.Sphere:
                mesh = ProceduralPrimitives.CreateMeshSphere(settings.radius, settings.numLongitudeLines, settings.numLatitudeLines);
                break;

            case PrimitiveMeshOptions.Cylinder:
                mesh = ProceduralPrimitives.CreateMeshCylinder(settings.height, settings.radius, settings.nbSides);
                break;

            case PrimitiveMeshOptions.Cone:
                mesh = ProceduralPrimitives.CreateMeshCone(settings.height, settings.radius, 0f, settings.nbSides);
                break;

            case PrimitiveMeshOptions.Pyramid:
                mesh = ProceduralPrimitives.CreateMeshPyramid(settings.height, settings.radius);
                break;

            case PrimitiveMeshOptions.Bunny:
                //TODO put this back
                mesh = null;     //ProceduralPrimitives.BuildMeshFromData(SoftDemo.BunnyMesh.Vertices, SoftDemo.BunnyMesh.Indices);
                break;

            case PrimitiveMeshOptions.Plane:
                mesh = ProceduralPrimitives.CreateMeshPlane(settings.length, settings.width, settings.resX, settings.resZ);
                break;

            default:
                break;
            }

            return(mesh);
        }
Example #2
0
        public override Mesh Build()
        {
            Mesh mesh = null;

            switch (meshType)
            {
            case PrimitiveMeshOptions.UserDefinedMesh:
                //Need to copy mesh from sharedMesh or we cant modify the mesh!
                if (userMesh == null)     //fill in something
                {
                    mesh = ProceduralPrimitives.CreateMeshBox(extents.x, extents.x, extents.x);
                    Debug.Log("Must provide a mesh for UserDefinedMesh setting.");
                }

                mesh = (Mesh)GameObject.Instantiate(userMesh);
                break;

            case PrimitiveMeshOptions.Box:
                mesh = ProceduralPrimitives.CreateMeshBox(extents.x, extents.y, extents.z);
                break;

            case PrimitiveMeshOptions.Sphere:
                mesh = ProceduralPrimitives.CreateMeshSphere(radius, numLongitudeLines, numLatitudeLines);
                break;

            case PrimitiveMeshOptions.Cylinder:
                mesh = ProceduralPrimitives.CreateMeshCylinder(height, radius, nbSides);
                break;

            case PrimitiveMeshOptions.Cone:
                mesh = ProceduralPrimitives.CreateMeshCone(height, radius, 0f, nbSides);
                break;

            case PrimitiveMeshOptions.Pyramid:
                mesh = ProceduralPrimitives.CreateMeshPyramid(height, radius);
                break;

            //case PrimitiveMeshOptions.Bunny:
            //mesh = ProceduralPrimitives.BuildMeshFromData(SoftDemo.BunnyMesh.Vertices, SoftDemo.BunnyMesh.Indices);
            //break;
            case PrimitiveMeshOptions.Plane:
                mesh = ProceduralPrimitives.CreateMeshPlane(length, width, resX, resZ);
                break;

            default:
                break;
            }

            return(mesh);
        }
        public override Mesh Build()
        {
            Mesh mesh = ProceduralPrimitives.CreateMeshPlane(length, width, resX, resZ);

            return(mesh);
        }