Ejemplo n.º 1
0
    public CaveRoom GenerateRoom(Vec3i position, Vector3 size)
    {
        CaveRoom     cr        = new CaveRoom(position, size, new Vec3i(0, 0, 0), new Vec3i(0, 0, 0));
        List <Vec3i> points    = cr.AllPointsInside();
        float        perlinLim = Mathf.Clamp(GenRan.GaussianFloat(0.4f, 0.2f), 0.1f, 0.5f);

        foreach (Vec3i v in points)
        {
            float perlin = GenRan.PerlinNoise3D(v, 0.1f);
            if (perlin < 0.6f)
            {
                ClearVoxelNode(v.x, v.y, v.z);
            }
        }

        return(cr);
    }
Ejemplo n.º 2
0
    public override void OnObjectLoad(WorldObject obj)
    {
        Mesh  mesh        = obj.GetComponent <MeshFilter>().mesh;
        float distort_amp = 2;
        float sin_freq    = Mathf.PI * 2;
        float total_scale = 1;

        Vector3[] verticies = mesh.vertices;

        Vector3 seed_delta = new Vector3(WorldPosition.x + ObjectDeltaPosition.x * 17f, ObjectDeltaPosition.y * 2f, WorldPosition.z + ObjectDeltaPosition.z * 27f);
        Vector3 scale      = genRan.RandomVector3(0.2f, 0.5f) * RockSize;

        scale.y *= 0.8f; //Bias to flatter canopies
        for (int i = 0; i < mesh.vertices.Length; i++)
        {
            float perlin = genRan.PerlinNoise3D(verticies[i] + seed_delta, 512f);
            float dist_f = 1 + distort_amp * perlin;
            verticies[i].Scale(scale * dist_f);
        }
        mesh.vertices = verticies;
        mesh.RecalculateNormals();
    }