Beispiel #1
0
    void AddWallSegment(Vector3 closeLeftVertex, Vector3 farLeftVertex, Vector3 closeRightVertex,
                        Vector3 farRightVertex, bool addTower = false)
    {
        closeLeftVertex  = Metrics.Perturb(closeLeftVertex);
        closeRightVertex = Metrics.Perturb(closeRightVertex);
        farLeftVertex    = Metrics.Perturb(farLeftVertex);
        farRightVertex   = Metrics.Perturb(farRightVertex);

        var centralLeftWallPoint  = Metrics.WallLerp(closeLeftVertex, farLeftVertex);
        var centralRightWallPoint = Metrics.WallLerp(closeRightVertex, farRightVertex);

        var leftThicknessOffset  = Metrics.WallThicknessOffset(closeLeftVertex, farLeftVertex);
        var rightThicknessOffset = Metrics.WallThicknessOffset(closeRightVertex, farRightVertex);

        var bottomLeftWallEdge  = centralLeftWallPoint - leftThicknessOffset;
        var bottomRightWallEdge = centralRightWallPoint - rightThicknessOffset;

        var topLeftWallEdge  = bottomLeftWallEdge;
        var topRightWallEdge = bottomRightWallEdge;

        topLeftWallEdge.y  += Metrics.WallHeight;
        topRightWallEdge.y += Metrics.WallHeight;

        walls.AddQuadUnperturbed(bottomLeftWallEdge, bottomRightWallEdge, topLeftWallEdge, topRightWallEdge);

        var topLeftEdge  = topLeftWallEdge;
        var topRightEdge = topRightWallEdge;

        bottomLeftWallEdge  = topLeftWallEdge = centralLeftWallPoint + leftThicknessOffset;
        bottomRightWallEdge = topRightWallEdge = centralRightWallPoint + rightThicknessOffset;

        topLeftWallEdge.y  += Metrics.WallHeight;
        topRightWallEdge.y += Metrics.WallHeight;

        walls.AddQuadUnperturbed(bottomRightWallEdge, bottomLeftWallEdge, topRightWallEdge, topLeftWallEdge);

        walls.AddQuadUnperturbed(topLeftEdge, topRightEdge, topLeftWallEdge, topRightWallEdge);

        if (addTower)
        {
            AddTower(bottomLeftWallEdge, bottomRightWallEdge);
        }
    }