コード例 #1
0
ファイル: TerrainField3.cs プロジェクト: abarabone/a
    public void adjustHeights(SimpleTerrainOperator op)
    {
        var m = new FieldManipulator(min, max, op.fieldUnitR, op.fieldLength);

        var hs = m.getHeights(op.td);

        var tofs = new Vector3(op.terrainPosition.x, op.terrainPositionHeight, op.terrainPosition.y);

        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.fieldUnit) + 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))
                {
                    hs[iy, ix] = (res.point.y - op.terrainPositionHeight) * op.fieldUnitHeightR;
                }
            }
        }

        m.setHeights(op.td, hs);
    }
コード例 #2
0
ファイル: TerrainField3.cs プロジェクト: abarabone/a
    public FieldAdjusterForExplosionShpere(Vector3 center, float radius, float impact, SimpleTerrainOperator op)
    {
        sqrradius = radius * radius;
        sradius   = new Vector2(radius, radius);

        scenter      = new Vector2(center.x, center.z) - op.terrainPosition;
        centerHeight = center.y - op.terrainPositionHeight;

        this.center = new Vector3(scenter.x, centerHeight, scenter.y);

        min = scenter - sradius;
        max = scenter + sradius;

        this.impact = impact;


        hm = new FieldManipulator(min, max, op.fieldUnitR, op.fieldLength);

        hs = hm.getHeights(op.td);
    }