WaterSurface

Package: Libraries.Game.Graphics.Worlds · Inherits from: Libraries.Interface.Item3D, Libraries.Interface.Item, Libraries.Language.Object, Libraries.Game.Graphics.Model

WaterSurface is a flat sheet of water: a Model drawn with a WaterShaderProgram, after the lighting, over the ground. Its look comes from the program. Place it at the water's level with SetPosition, or SetLevel. Water has no collision.

Example Code

use Libraries.Game.Game
use Libraries.Game.Graphics.Worlds.WaterShaderProgram
use Libraries.Game.Graphics.Worlds.WaterSurface

class Main is Game
WaterShaderProgram water
WaterSurface lake

action Main
    StartGame()
end

action CreateGame
    water:Install()
    lake:Load(40, 40, water)
    lake:SetLevel(2)
    Add(lake)
end
end

Actions

GetLevel()

This action returns the water's height.

Returns

number: The surface's y position.

GetWaterProgram()

This action returns the water program the surface is drawn with.

Returns

Libraries.Game.Graphics.Worlds.WaterShaderProgram: The water program, or undefined before Load.

Load(number width, number depth, Libraries.Game.Graphics.Worlds.WaterShaderProgram program)

This action makes the water a flat sheet, width along x and depth along z, centered on its position, drawn with a water program.

Parameters

LoadCells(Libraries.Game.Graphics.Worlds.TerrainLake lake, Libraries.Game.Graphics.Worlds.WaterShaderProgram program, Libraries.Game.Graphics.Worlds.TerrainData data)

This action makes the water the shape of a lake's water cells: a flat sheet over each run of cells with water along a row, and nothing elsewhere, so water never shows past the lake's cells. The surface is placed at the lake's grid corner, at its level. A lake that follows the ground gets one square per cell instead, each corner its water depth above the ground there, and on the ground at the lake's edge, so the water never floats.

Parameters

LoadRiver(Libraries.Game.Graphics.Worlds.TerrainRiver river, Libraries.Game.Graphics.Worlds.WaterShaderProgram program)

This action makes the water a river's: a strip along the river's line, as wide as the river, at its water's height, sloping down where the river does. Its ripples flow downstream at the river's speed: each corner's texture coordinates are how far across and along the river it is, in world units, and its tangent and bitangent point across and downstream, which the water shader follows.

Parameters

SetLevel(number level)

This action moves the surface up or down to a height, keeping it where it is along x and z.

Parameters

  • level number: The water's height.

Inherited Actions

112 actions from Libraries.Game.Graphics.Model
62 actions from Libraries.Interface.Item
211 actions from Libraries.Interface.Item3D
3 actions from Libraries.Language.Object