Exemplo n.º 1
0
    public void Build(int p, int q)
    {
        P = p;
        Q = q;

        switch (ShapeType)
        {
        case PolyHydraEnums.ShapeTypes.Uniform:
            var wythoff = new WythoffPoly(PolyType, P, Q);
            wythoff.BuildFaces();
            poly = new ConwayPoly(wythoff);
            break;

        case PolyHydraEnums.ShapeTypes.Johnson:
            poly = JohnsonPoly.Build(JohnsonPolyType, P);
            break;

        case PolyHydraEnums.ShapeTypes.Grid:
            poly = Grids.Grids.MakeGrid(GridType, GridShape, P, Q);
            break;

        case PolyHydraEnums.ShapeTypes.Other:
            poly = JohnsonPoly.BuildOther(OtherPolyType, P, Q);
            break;

        case PolyHydraEnums.ShapeTypes.Waterman:
            poly = WatermanPoly.Build(1f, P, Q, true);
            break;
        }
    }
Exemplo n.º 2
0
    public void Generate()
    {
        var poly = JohnsonPoly.BuildOther(otherPolyType, sides, segments);

        if (ApplyOp)
        {
            var o1 = new OpParams {
                valueA = op1Amount1, valueB = op1Amount2, facesel = op1Facesel
            };
            poly = poly.ApplyOp(op1, o1);
            var o2 = new OpParams {
                valueA = op2Amount1, valueB = op2Amount2, facesel = op2Facesel
            };
            poly = poly.ApplyOp(op2, o2);
        }
        if (Canonicalize)
        {
            poly = poly.Canonicalize(0.1, 0.1);
        }
        poly = poly.Transform(Position, Rotation, Scale);

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

        GetComponent <MeshFilter>().mesh = mesh;
    }
Exemplo n.º 3
0
    public void MakePolyhedron()
    {
        switch (ShapeType)
        {
        case PolyHydraEnums.ShapeTypes.Uniform:
            var wythoff = new WythoffPoly(UniformPolyType, PrismP, PrismQ);
            wythoff.BuildFaces();
            _conwayPoly = new ConwayPoly(wythoff);
            break;

        case PolyHydraEnums.ShapeTypes.Johnson:
            _conwayPoly = JohnsonPoly.Build(JohnsonPolyType, PrismP);
            break;

        case PolyHydraEnums.ShapeTypes.Grid:
            _conwayPoly = Grids.Grids.MakeGrid(GridType, GridShape, PrismP, PrismQ);
            break;

        case PolyHydraEnums.ShapeTypes.Waterman:
            _conwayPoly = WatermanPoly.Build(PrismP, PrismQ);
            break;

        case PolyHydraEnums.ShapeTypes.Other:
            _conwayPoly = JohnsonPoly.BuildOther(OtherPolyType, PrismP, PrismQ);
            break;
        }
        _conwayPoly.basePolyhedraInfo = new ConwayPoly.BasePolyhedraInfo {
            P = PrismP, Q = PrismQ
        };

        foreach (var op in ConwayOperators.ToList())
        {
            if (op.disabled || op.opType == Ops.Identity)
            {
                continue;
            }
            _conwayPoly = ApplyOp(_conwayPoly, ref stashed, op);
            _conwayPoly.basePolyhedraInfo = new ConwayPoly.BasePolyhedraInfo {
                P = PrismP, Q = PrismQ
            };
        }
        var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(_conwayPoly, GenerateSubmeshes, null, ColorMethod);

        AssignFinishedMesh(mesh);
    }
Exemplo n.º 4
0
    public void Generate()
    {
        switch (ShapeType)
        {
        case ShapeTypes.Wythoff:
            var wythoff = new WythoffPoly(PolyType, PrismP, PrismQ);
            wythoff.BuildFaces();
            poly = new ConwayPoly(wythoff);
            break;

        case ShapeTypes.Johnson:
            poly = JohnsonPoly.Build(JohnsonPolyType, PrismP);
            break;

        case ShapeTypes.Grid:
            poly = Grids.Grids.MakeGrid(GridType, GridShape, PrismP, PrismQ);
            break;

        case ShapeTypes.Other:
            poly = JohnsonPoly.BuildOther(OtherPolyType, PrismP, PrismQ);
            break;
        }

        if (applyPreOp)
        {
            var preOpParams = new OpParams {
                valueA = preOpAmount1, valueB = preOpAmount2, facesel = preOpFacesel
            };
            for (int i = 0; i < preOpIterations; i++)
            {
                poly = poly.ApplyOp(preOp, preOpParams);
            }
        }

        OpParams amount1Func = null;

        switch (Equation)
        {
        case Equations.LinearX:
            amount1Func = new OpParams
            {
                funcA = x => offset1 + Mathf.Sin((x.poly.Faces[x.index].Centroid.x * frequency1 + phase1 - (Time.time * animationSpeed1))) * amplitude1,
                funcB = x => offset2 + Mathf.Sin((x.poly.Faces[x.index].Centroid.x * frequency2 + phase2 - (Time.time * animationSpeed2))) * amplitude2
            };
            break;

        case Equations.LinearY:
            amount1Func = new OpParams
            {
                funcA = x => offset1 + Mathf.Sin((x.poly.Faces[x.index].Centroid.y * frequency1 + phase1 - (Time.time * animationSpeed1))) * amplitude1,
                funcB = x => offset2 + Mathf.Sin((x.poly.Faces[x.index].Centroid.y * frequency2 + phase2 - (Time.time * animationSpeed2))) * amplitude2
            };
            break;

        case Equations.LinearZ:
            amount1Func = new OpParams
            {
                funcA = x => offset1 + Mathf.Sin((x.poly.Faces[x.index].Centroid.z * frequency1 + phase1 - (Time.time * animationSpeed1))) * amplitude1,
                funcB = x => offset2 + Mathf.Sin((x.poly.Faces[x.index].Centroid.z * frequency2 + phase2 - (Time.time * animationSpeed2))) * amplitude2
            };
            break;

        case Equations.Radial:
            amount1Func = new OpParams
            {
                funcA = x => offset1 + Mathf.Sin((x.poly.Faces[x.index].Centroid.magnitude * frequency1 + phase1 - (Time.time * animationSpeed1))) * amplitude1,
                funcB = x => offset2 + Mathf.Sin((x.poly.Faces[x.index].Centroid.magnitude * frequency2 + phase2 - (Time.time * animationSpeed2))) * amplitude2
            };
            break;

        case Equations.Perlin:
            amount1Func = new OpParams
            {
                funcA = x => offset1 + Mathf.PerlinNoise(x.poly.Faces[x.index].Centroid.x * frequency1 + phase1 - (Time.time * animationSpeed1), x.poly.Faces[x.index].Centroid.z * frequency1 + phase1 - (Time.time * animationSpeed1)) * amplitude1,
                funcB = x => offset2 + Mathf.PerlinNoise(x.poly.Faces[x.index].Centroid.x * frequency2 + phase2 - (Time.time * animationSpeed2), x.poly.Faces[x.index].Centroid.z * frequency2 + phase2 - Time.time) * amplitude2,
            };
            break;
        }

        poly = poly.ApplyOp(op, amount1Func);
        var mesh = PolyMeshBuilder.BuildMeshFromConwayPoly(poly, false, null, ColorMethod);

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