Ejemplo n.º 1
0
    void AddTriangle(Vector3 v1, Vector3 v2, Vector3 v3)
    {
        int cnt = vertices.Count;

        vertices.Add(HexMetrics.DisturbXZ(v1));
        vertices.Add(HexMetrics.DisturbXZ(v2));
        vertices.Add(HexMetrics.DisturbXZ(v3));
        indices.Add(cnt);
        indices.Add(cnt + 1);
        indices.Add(cnt + 2);
    }
Ejemplo n.º 2
0
    //从上往下看,顺时针方向时法线朝上
    void AddQuad(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4)
    {
        int cnt = vertices.Count;

        vertices.Add(HexMetrics.DisturbXZ(v1));
        vertices.Add(HexMetrics.DisturbXZ(v2));
        vertices.Add(HexMetrics.DisturbXZ(v3));
        vertices.Add(HexMetrics.DisturbXZ(v4));
        indices.Add(cnt);
        indices.Add(cnt + 1);
        indices.Add(cnt + 3);
        indices.Add(cnt + 1);
        indices.Add(cnt + 2);
        indices.Add(cnt + 3);
    }
Ejemplo n.º 3
0
    void GenCornerTriangle_SSC(Vector3 low, HexCell lowCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell)
    {
        Vector3 mid, mid_L, mid_R;

        if (right.y < left.y)
        {
            mid   = right;
            mid_L = low;
            mid_R = left;
        }
        else
        {
            mid   = left;
            mid_L = right;
            mid_R = low;
        }

        Vector3 disturb_L   = HexMetrics.DisturbXZ(mid_L);
        Vector3 disturb_R   = HexMetrics.DisturbXZ(mid_R);
        Vector3 disturb_mid = HexMetrics.DisturbXZ(mid);
        Vector3 junction    = Vector3.Lerp(disturb_L, disturb_R, (disturb_L.y - disturb_mid.y) / (disturb_L.y - disturb_R.y));

        Vector3 v1 = mid;

        for (int i = 1; i <= HexMetrics.StepAmount; i++)
        {
            Vector3 v2 = HexMetrics.StepLerp(mid, mid_L, i);
            AddTriangleUndisturbed(HexMetrics.DisturbXZ(v1), HexMetrics.DisturbXZ(v2), junction);

            v1 = v2;
        }

        Vector3 v3 = mid;

        for (int i = 1; i <= HexMetrics.StepAmount; i++)
        {
            Vector3 v4 = HexMetrics.StepLerp(mid, mid_R, i);
            AddTriangleUndisturbed(HexMetrics.DisturbXZ(v4), HexMetrics.DisturbXZ(v3), junction);
            v3 = v4;
        }
    }
Ejemplo n.º 4
0
    //rightCell最高 Low left Right呈现顺时针方向
    void GenCornerTriangle_SCCR(Vector3 low, HexCell lowCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell)
    {
        BridgeType oppsite = HexMetrics.GetBridgeType(rightCell.Elevation, leftCell.Elevation);

        Vector3 disturb_low   = HexMetrics.DisturbXZ(low);
        Vector3 disturb_left  = HexMetrics.DisturbXZ(left);
        Vector3 disturb_right = HexMetrics.DisturbXZ(right);

        float   t        = (disturb_left - disturb_low).y / (disturb_right - disturb_low).y;
        Vector3 junction = Vector3.Lerp(disturb_low, disturb_right, t);

        if (oppsite == BridgeType.Slope)
        {
            AddTriangleUndisturbed(disturb_low, disturb_left, junction);

            Vector3 v1 = left;
            for (int i = 1; i <= HexMetrics.StepAmount; i++)
            {
                Vector3 v2 = HexMetrics.StepLerp(left, right, i);
                AddTriangleUndisturbed(v1.DisturbXZ(), v2.DisturbXZ(), junction);
                v1 = v2;
            }
        }
        else
        {
            AddTriangleUndisturbed(disturb_left, disturb_right, junction);

            Vector3 v1 = low;
            for (int i = 1; i <= HexMetrics.StepAmount; i++)
            {
                Vector3 v2 = HexMetrics.StepLerp(low, left, i);
                AddTriangleUndisturbed(v1.DisturbXZ(), v2.DisturbXZ(), junction);
                v1 = v2;
            }
        }
    }
Ejemplo n.º 5
0
 public static Vector3 DisturbXZ(this Vector3 vec)
 {
     return(HexMetrics.DisturbXZ(vec));
 }