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 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

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