void updateMesh(int index, int idz, GameObject terrainObject, Transform gO, int lod, MeshFilter mf, float xDisp, float yDisp, float interval2, bool update)
    {
        //if (mf.sharedMesh!=null)mf.sharedMesh.Clear();

        MeshData meshData = PlaneGenerator.Generate(interval2 * 2, interval2 * 2, textQual / lod - 2, textQual / lod - 2);

        if (sphere)
        {
            meshData.vertices = spheritize(meshData.vertices, new Vector3(xDisp, radius, yDisp));
        }
        if (useNoise)
        {
            meshData.vertices = addNormalNoise(meshData.vertices, planetInfo.nmArray [index], meshHeightMultiplier);
        }
        Vector3 movement = meshAverage(meshData.vertices);

        gO.localPosition += translateByPivot(idz, new Vector2(movement.x, movement.z), movement.y);
        meshData.vertices = translateMesh(meshData.vertices, -movement);
        //Debug.Log (mesh.vertices.Length.ToString());
        Mesh mesh = meshData.CreateMesh();

        if (!update)
        {
            mf.sharedMesh = mesh;
        }
        else
        {
            mf.mesh = mesh;
        }

        planetInfo.mcArray [index].sharedMesh = mesh;
    }
Example #2
0
    private void Awake()
    {
        _mesh = PlaneGenerator.Generate(_gridSize, _cellSize, "OceanMesh");
        _mesh.MarkDynamic();

        _vertices = _mesh.vertices;
    }
    void updateMesh(int lod, MeshFilter mf, float[,] noiseMap, float interval2)
    {
        if (mf.sharedMesh != null)
        {
            mf.sharedMesh.Clear();
        }

        MeshData mesh = PlaneGenerator.Generate(interval2 * 2, interval2 * 2, textQual / lod - 2, textQual / lod - 2);

        mesh.vertices = addNormalNoise(mesh.vertices, noiseMap, meshHeightMultiplier, false);

        mf.sharedMesh = mesh.CreateMesh();
    }
Example #4
0
    void Start()
    {
        // Generate Plane
        p = GetComponent <PlaneGenerator>();
        p.Generate();

        // Attach Wave Material & Remove Shadow Casting
        MeshRenderer mR = GetComponent <MeshRenderer>();

        mR.material          = wave;
        mR.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

        m = GetComponent <MeshFilter>().mesh;
    }
Example #5
0
 void OnValidate()
 {
     m_planeGenerator.Generate(this.transform, VectorToColor(new Vector2(0, 1)));
 }