Exemplo n.º 1
0
    private ConwayPoly MakeAntenna(ConwayPoly spaceship)
    {
        var allNew   = spaceship.FaceselToFaceFilterFunc(FaceSelections.AllNew);
        var facingUp = spaceship.FaceselToFaceFilterFunc(FaceSelections.FacingUp);
        Func <FilterParams, bool> newAndFacingUp = x => allNew(x) && facingUp(x);
        var topSurfaces = spaceship.FaceKeep(new OpParams {
            filterFunc = newAndFacingUp
        });

        var antennaGroup = new ConwayPoly();
        var antenna      = JohnsonPoly.Pyramid(4);

        foreach (var face in topSurfaces.Faces)
        {
            float radius = Random.Range(0.01f, 0.05f);
            float height = Random.Range(0.25f, 2f);
            float offset = Random.value < .5 ? 0 : Random.value < 0.5 ? .5f : -.5f;
            antennaGroup.Append(antenna.Transform(
                                    face.GetPolarPoint(90, offset),
                                    Vector3.zero,
                                    new Vector3(radius, height, radius)
                                    ));
        }
        return(antennaGroup);
    }
Exemplo n.º 2
0
    public void Generate()
    {
        var        colorMethod = ColorBySides ? PolyHydraEnums.ColorMethods.BySides : PolyHydraEnums.ColorMethods.ByRole;
        ConwayPoly poly        = null;

        // TODO move this into a method on JohnsonPoly
        switch (JohnsonPolyType)
        {
        case PolyHydraEnums.JohnsonPolyTypes.Prism:
            poly = JohnsonPoly.Prism(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.Antiprism:
            poly = JohnsonPoly.Antiprism(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.Pyramid:
            poly = JohnsonPoly.Pyramid(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.ElongatedPyramid:
            poly = JohnsonPoly.ElongatedPyramid(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroelongatedPyramid:
            poly = JohnsonPoly.GyroelongatedPyramid(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.Dipyramid:
            poly = JohnsonPoly.Dipyramid(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.ElongatedDipyramid:
            poly = JohnsonPoly.ElongatedDipyramid(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroelongatedDipyramid:
            poly = JohnsonPoly.GyroelongatedDipyramid(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.Cupola:
            poly = JohnsonPoly.Cupola(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.ElongatedCupola:
            poly = JohnsonPoly.ElongatedCupola(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroelongatedCupola:
            poly = JohnsonPoly.GyroelongatedCupola(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.OrthoBicupola:
            poly = JohnsonPoly.OrthoBicupola(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroBicupola:
            poly = JohnsonPoly.GyroBicupola(sides);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.ElongatedOrthoBicupola:
            poly = JohnsonPoly.ElongatedBicupola(sides, false);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.ElongatedGyroBicupola:
            poly = JohnsonPoly.ElongatedBicupola(sides, true);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroelongatedBicupola:
            poly = JohnsonPoly.GyroelongatedBicupola(sides, false);
            break;

        case PolyHydraEnums.JohnsonPolyTypes.Rotunda:
            poly = JohnsonPoly.Rotunda();
            break;

        case PolyHydraEnums.JohnsonPolyTypes.ElongatedRotunda:
            poly = JohnsonPoly.ElongatedRotunda();
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroelongatedRotunda:
            poly = JohnsonPoly.GyroelongatedRotunda();
            break;

        case PolyHydraEnums.JohnsonPolyTypes.GyroelongatedBirotunda:
            poly = JohnsonPoly.GyroelongatedBirotunda();
            break;
        }
        poly = poly.FaceRemove(new OpParams {
            facesel = removeSelection
        });
        poly = poly.ExtendBoundaries(new OpParams {
            valueA = amount1, valueB = angle1
        });
        poly = poly.ExtendBoundaries(new OpParams {
            valueA = amount2, valueB = angle2
        });

        if (ApplyOp)
        {
            var o = new OpParams {
                valueA = opAmount, valueB = op2Amount, facesel = facesel
            };
            poly = poly.ApplyOp(op, o);
        }

        var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(poly, false, null, colorMethod);

        GetComponent <MeshFilter>().mesh = mesh;
    }