Esempio n. 1
0
        void fittingTerrain(Plot3 plot)
        {
            var district = plot.GetComponentInParent <District3>();

            if (district == null)
            {
                return;
            }


            var tr = district.GetComponentInChildren <Terrain>();

            var field = new TerrainOperator(tr);


            var parts = plot.GetComponentsInChildren <PathSegment3>();           //RoadPart3>();

            foreach (var part in parts)
            {
                var mcs = part.GetComponentsInChildren <MeshCollider>();

                foreach (var mc in mcs)
                {
                    field.adjustMesh(mc);
                }
            }

            tr.Flush();
        }
Esempio n. 2
0
    public void adjustAlphamaps(TerrainOperator op)
    {
        var mratio = new Vector2(op.fieldUnit.x / op.mapUnit.x, op.fieldUnit.y / op.mapUnit.y);

        var m = new FieldManipulator(min, max, op.mapUnitR, op.mapLength);

        var ms = m.getAlphamaps(op.td);

        for (var iy = 0; iy < m.len.y; iy++)
        {
            for (var ix = 0; ix < m.len.x; ix++)
            {
                var spos = m.getIterationPosition(ix, iy, op.mapUnit);

                var height = hs[(int)(iy * mratio.y), (int)(ix * mratio.x)] * op.fieldUnitHeight;

                var pos = new Vector3(spos.x, height, spos.y);

                if ((pos - center).sqrMagnitude <= sqrradius)
                {
                    ms[iy, ix, 0] = 0.3f;
                    ms[iy, ix, 1] = 0.0f;
                    ms[iy, ix, 2] = 0.0f;
                    ms[iy, ix, 3] = 0.0f;
                }
            }
        }

        m.setAlphamaps(op.td, ms);
    }
Esempio n. 3
0
    public void adjustAlphamaps(TerrainOperator op)
    {
        var m = new FieldManipulator(min, max, op.mapUnitR, op.mapLength);

        var ms = m.getAlphamaps(op.td);

        for (var iy = 0; iy < m.len.y; iy++)
        {
            for (var ix = 0; ix < m.len.x; ix++)
            {
                var pos = m.getIterationPosition3d(ix, iy, op.mapUnit) + tofs;

                var start = pos + Vector3.up * 512.0f;
                var end   = pos + Vector3.down * 512.0f;

                var ray = new Ray(start, end - start);
                var res = new RaycastHit();
                if (mc.Raycast(ray, out res, 1024.0f))
                {
                    ms[iy, ix, 0] = 0.0f;
                    ms[iy, ix, 1] = 1.0f;
                    ms[iy, ix, 2] = 0.0f;
                    ms[iy, ix, 3] = 0.0f;
                }
            }
        }

        m.setAlphamaps(op.td, ms);
    }
Esempio n. 4
0
 public void adjustAlphamaps(TerrainOperator op)
 {
 }