Exemple #1
0
    public void Generate()
    {
        var poly        = JohnsonPoly.Antiprism(4);
        var cube        = JohnsonPoly.Prism(4);
        var decorations = new ConwayPoly();

        cube = cube.Transform(Vector3.zero, Vector3.zero, Vector3.one * cubeScale);
        foreach (var face in poly.Faces)
        {
            for (float angle = 0; angle < 360; angle += theta)
            {
                var pos  = face.GetPolarPoint(angle, distance);
                var look = Quaternion.LookRotation(face.Normal, Vector3.up).eulerAngles + new Vector3(90, 0, 0);
                decorations.Append(cube.Transform(pos, look, Vector3.one));
            }
        }
        //poly.Append(decorations);
        var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(decorations, false);

        GetComponent <MeshFilter>().mesh = mesh;
    }
Exemple #2
0
    public void Generate()
    {
        Random.seed = seed;

        spaceship = JohnsonPoly.Prism(numSides);
        wings     = new ConwayPoly();
        antennae  = new ConwayPoly();

        float angleCorrection = 180f / numSides;

        if (numSides % 2 != 0)
        {
            angleCorrection /= 2f;
        }
        spaceship = spaceship.Rotate(Vector3.up, angleCorrection);
        spaceship = spaceship.Rotate(Vector3.left, -90);

        alreadyStake = false;

        for (int i = 0; i < 2; i++)  // Loop twice - once for the back and once for the front.
        {
            for (int j = 0; j <= numSections; j++)
            {
                spaceship = MakeSection(spaceship);
            }

            // Second time through loop:
            // Flip everything around ready to generate the back sections

            spaceship = spaceship.Rotate(Vector3.up, 180);
            wings     = wings.Rotate(Vector3.up, 180);
            antennae  = antennae.Rotate(Vector3.up, 180);

            // Change random range for front sections
            loftLow  = -0.35f;
            loftHigh = 0.15f;
        }



        // Make the engines
        var engines = spaceship.FaceKeep(new OpParams {
            facesel = FaceSelections.FacingStraightBackward
        });

        spaceship = spaceship.FaceRemove(new OpParams {
            facesel = FaceSelections.FacingStraightBackward
        });
        engines = engines.Loft(new OpParams {
            valueA = Random.Range(.3f, .4f), valueB = Random.Range(-.2f, .2f)
        });
        // spaceship = engines;
        if (EngineVariant)
        {
            var engineRim = engines.FaceRemove(new OpParams {
                facesel = FaceSelections.Existing
            });
            engines = engines.FaceKeep(new OpParams {
                facesel = FaceSelections.Existing
            });
            engines = engines.Ortho(new OpParams {
                valueA = 0
            });
            engines = engines.Loft(new OpParams {
                valueA = Random.Range(0, .25f), valueB = -.5f
            });
            engines.Append(engineRim);
        }
        else
        {
            engines = engines.Loft(new OpParams {
                valueA = Random.Range(.25f, .75f), valueB = Random.Range(0, .2f), facesel = FaceSelections.Existing
            });
            engines = engines.Loft(new OpParams {
                valueA = Random.Range(.1f, .3f), valueB = Random.Range(-.3f, -.7f), facesel = FaceSelections.AllNew
            });
        }

        // Make the nose section
        if (NoseLength > 0)
        {
            spaceship = spaceship.Loft(new OpParams {
                valueA = .2f, valueB = 0, facesel = FaceSelections.FacingStraightForward
            });
            spaceship = spaceship.FaceSlide(new OpParams {
                valueA = .12f, facesel = FaceSelections.Existing
            });
            if (NoseVariant)
            {
                spaceship = spaceship.Lace(new OpParams {
                    valueA = NoseSharpness, valueB = NoseLength, facesel = FaceSelections.Existing
                });
            }
            else
            {
                spaceship = spaceship.Loft(new OpParams {
                    valueA = NoseSharpness, valueB = NoseLength, facesel = FaceSelections.Existing
                });
            }
        }


        // Add panel insets to the hull
        spaceship = spaceship.Loft(new OpParams {
            valueA = 0.1f, valueB = 0.025f
        });

        // Add panel insets to the wings
        wings = wings.Loft(new OpParams {
            valueA = 0.1f, valueB = 0.025f
        });

        spaceship.Append(engines);
        spaceship.Append(wings);
        spaceship.Append(antennae);

        // Build the final mesh
        var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(spaceship, false);

        GetComponent <MeshFilter>().mesh       = mesh;
        GetComponent <MeshRenderer>().material = material;
    }
Exemple #3
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;
    }