Beispiel #1
0
    Mesh GetMesh()
    {
        Mesh mesh = new Mesh();

        vertices  = new List <Vector3>();
        triangles = new List <int>();
        normals   = new List <Vector3>();
        uvs       = new List <Vector2>();
        Rect  texRect = new Rect(0, 0, 1f, 1f);
        float width   = 0.04f * Own.Params.ThornsParam.ThornsLevel;
        float height  = 0.1f * Own.Params.ThornsParam.ThornsLevel;

        for (float x = -0.4f; x <= 0.4f; x += 0.2f)
        {
            for (float z = -0.1f; z >= -0.9f; z -= 0.2f)
            {
                AddToMesh(new Vector3(x, 1f, z), Shapes.Cone(height, width, 0, 6, texRect));
            }
        }
        mesh.vertices  = vertices.ToArray();
        mesh.triangles = triangles.ToArray();
        mesh.normals   = normals.ToArray();
        mesh.uv        = uvs.ToArray();
        mesh.name      = GetType().Name;
        return(mesh);
    }
Beispiel #2
0
    void SetPine(float px, float pz, float tileHeight)
    {
        float height = Random.Range(0.5f, 1f);
        float rad    = Random.Range(0.15f, 0.3f);

        AddMesh(new Vector3(px, tileHeight, pz), Shapes.Box(rad, rad, height, GetTexture(TreeType.Pine, TreeMat.Wood)));
        int   level = Random.Range(3, 5);
        float hPos  = tileHeight + height;

        for (int i = 0; i < level; i++)
        {
            float r = (rad * (2 + level - i));
            float h = r;
            AddMesh(new Vector3(px, hPos, pz), Shapes.Cone(h, r, 0.1f, 6, GetTexture(TreeType.Pine, TreeMat.Leafs)));
            hPos += h * 0.75f;
        }
    }