예제 #1
0
    private void XSideHighSmoothing(Vector3 pointA, Vector3 pointZ)
    {
        pointA.x--; pointZ.x++;
        if (pointA.x < 0)
        {
            pointA.x = 0;                    //donot allow minus values
        }
        var point = pointA;

        for (int i = (int)pointA.x; i <= (int)/*pointA.z*/ pointZ.x; i++)
        {
            point.x = i;
            //Instantiate(testCube,point, Quaternion.identity);
            HighGroundSmoother.SmoothLineBackwardXHigh(point, ref betaHeights, elevation);           //FIXME: for higher ground this function in not good
            HighGroundSmoother.SmoothLineXHigh(point, ref betaHeights, elevation, testSubCube);      //vertical to this point
        }
    }
예제 #2
0
    /* ************************************************************* */
    private void ZSideHighSmoothing(Vector3 pointA, Vector3 pointZ)
    {
        pointA.z -= 1; pointZ.z += 1;    //for higher ground this expansion is expanding one side only
        Vector3 point = pointA;

        if (pointA.z < 0)
        {
            pointA.z = 0;                    //donot allow minus values
        }
        for (int i = (int)pointA.z; i <= (int)/*pointA.z*/ pointZ.z; i++)
        {
            point.z = i;
            //Instantiate(testCube,point,Quaternion.identity);
            HighGroundSmoother.SmoothLineZHigh(point, ref betaHeights, elevation);           //vertical to this point
            HighGroundSmoother.SmoothLineBackwardZHigh(point, ref betaHeights, elevation);   //FIXME: for higher ground this function in not good
        }
    }
예제 #3
0
    public void SmoothAroundIngredients()
    {
        float t = Time.realtimeSinceStartup;

        //print("SmoothAroundIngredients");
        for (int i = 0; i < (int)ingredientsCorners.Count - 3; i += 4)
        {
            //print((0+i)+","+(1+i)+","+(2+i)+","+(3+i));
            if (ingredientsCorners[0 + i].y > betaHeightsForTest[(int)ingredientsCorners[0 + i].x, (int)ingredientsCorners[0 + i].z])
            {
                //ZSideHighSmoothing(ingredientsCorners[0+i],ingredientsCorners[1+i]);
                //XSideHighSmoothing(ingredientsCorners[2+i],ingredientsCorners[3+i]);
                //print("HIGH");

                var pair = HighGroundSmoother.SquareSmootherForHighGround(new Vector3[] { ingredientsCorners[0 + i], ingredientsCorners[3 + i],
                                                                                          ingredientsCorners[1 + i], ingredientsCorners[2 + i] }, ref betaHeights, elevation, width, height);


                //terrain.terrainData.SetHeights(0,0,betaHeights);
                //return;
            }
            else
            {
                OtherSideSmoothing(ingredientsCorners[0 + i], ingredientsCorners[1 + i]);      //x direction
                SideSmoothing(ingredientsCorners[2 + i], ingredientsCorners[3 + i]);           //z direction
                //print("LOW");
            }
        }

        int Tw = terrain.terrainData.heightmapWidth;
        int Th = terrain.terrainData.heightmapHeight;

        //smooth function from old famus terraintoolkit : https://github.com/unitycoder/unityterraintoolkit/blob/f29819161e1cb00dc77c302908cf378f5fe9fcf7/Assets/TerrainToolkit/Scripts/TerrainToolkit.cs
        betaHeights = smooth(betaHeights, new Vector2(Tw, Th), Neighbourhood.Moore);

        terrain.terrainData.SetHeights(0, 0, betaHeights);

        float finalTime = Time.realtimeSinceStartup - t;

        print("Time : " + finalTime.ToString());
    }
    public void SmoothAroundIngredients()
    {
        float t = Time.time;

        //print("SmoothAroundIngredients");
        for (int i = 0; i < (int)ingredientsCorners.Count - 3; i += 4)
        {
            //print((0+i)+","+(1+i)+","+(2+i)+","+(3+i));
            if (ingredientsCorners[0 + i].y > betaHeightsForTest[(int)ingredientsCorners[0 + i].x, (int)ingredientsCorners[0 + i].z])
            {
                //ZSideHighSmoothing(ingredientsCorners[0+i],ingredientsCorners[1+i]);
                //XSideHighSmoothing(ingredientsCorners[2+i],ingredientsCorners[3+i]);
                print("HIGH");

                var pair = HighGroundSmoother.SquareSmootherForHighGround(new Vector3[] { ingredientsCorners[0 + i], ingredientsCorners[3 + i],
                                                                                          ingredientsCorners[1 + i], ingredientsCorners[2 + i] }, ref betaHeights, elevation, width, height);


                //terrain.terrainData.SetHeights(0,0,betaHeights);
                //return;
            }
            else
            {
                OtherSideSmoothing(ingredientsCorners[0 + i], ingredientsCorners[1 + i]);      //x direction
                SideSmoothing(ingredientsCorners[2 + i], ingredientsCorners[3 + i]);           //z direction
                print("LOW");
            }
        }



        terrain.terrainData.SetHeights(0, 0, betaHeights);

        float finalTime = Time.time - t;

        print("Time : " + finalTime.ToString());
    }