Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Foliage

  1. Object
  2. Foliage
Plants that move in the wind. The sway is a vertex offset that grows with height above the model’s origin, so put each plant’s origin at its root. Gusts roll across the scene in world space, so neighbours move together.

Fields

public static final String WIND = "windDir"VEC2 the direction the wind blows, in world x/z.
public static final String STRENGTH = "windStrength"FLOAT how far a point one unit above the root bends, world units.
public static final String SPEED = "windSpeed"FLOAT sways per second.
public static final String CUTOFF = "leafCutoff"FLOAT alpha below which a pixel of the texture is cut away.
public static final String ROOT = "grassRoot"VEC3 colour at the root of a blade of grass.
public static final String TIP = "grassTip"VEC3 colour at its tip.

Methods

public static ShaderMaterial wind()Wind sway alone; the surface keeps its own colour and texture.
public static ShaderMaterial leaves()Leaf cards: wind sway, the texture’s alpha cut out, and sunlight glowing through leaves seen against the sun.
public static ShaderMaterial canopy()A tree crown modelled as one solid shape (a ball or a block of leaves): leaf clusters from cellular noise, each cluster lit as a bump of its own, crevices between clusters darkened, the underside in shade, sunlight glowing through the rim seen against the sun, and a gentle sway.
public static ShaderMaterial grass()Grass blades: a root to tip gradient along the texture’s v (0 at the root), wind, and a sheen toward the sun.

Inherited methods

Field details

WIND

public static final String WIND = "windDir"
VEC2 the direction the wind blows, in world x/z.

STRENGTH

public static final String STRENGTH = "windStrength"
FLOAT how far a point one unit above the root bends, world units.

SPEED

public static final String SPEED = "windSpeed"
FLOAT sways per second.

CUTOFF

public static final String CUTOFF = "leafCutoff"
FLOAT alpha below which a pixel of the texture is cut away.

ROOT

public static final String ROOT = "grassRoot"
VEC3 colour at the root of a blade of grass.

TIP

public static final String TIP = "grassTip"
VEC3 colour at its tip.

Method details

wind

public static ShaderMaterial wind()
Wind sway alone; the surface keeps its own colour and texture.

Returns

a new shader material

leaves

public static ShaderMaterial leaves()
Leaf cards: wind sway, the texture’s alpha cut out, and sunlight glowing through leaves seen against the sun.

Returns

a new shader material

canopy

public static ShaderMaterial canopy()
A tree crown modelled as one solid shape (a ball or a block of leaves): leaf clusters from cellular noise, each cluster lit as a bump of its own, crevices between clusters darkened, the underside in shade, sunlight glowing through the rim seen against the sun, and a gentle sway. The instance colour is the foliage tint, so a creator’s green, autumn orange or blossom pink is kept.

Returns

a new shader material

grass

public static ShaderMaterial grass()
Grass blades: a root to tip gradient along the texture’s v (0 at the root), wind, and a sheen toward the sun. Pair with instancing or a field of crossed quads.

Returns

a new shader material