Cauldron3D.Bsp.Face (Cauldron3D v0.2.2)

Copy Markdown View Source

One face of a BSP world: a convex polygon on a plane, painted with a texture and lit by a lightmap.

  • plane — the plane index; back? true when the face looks along the plane's back
  • points — the corners, in order
  • texture — the texture index
  • s, t — {axis, offset}: a point's place on the texture is Vec.dot(point, axis) + offset across and down
  • mins, extents — {s, t}: where the lightmap starts on the texture and how far it reaches, multiples of luxel
  • lightmap — the byte offset of the face's samples in the world's lightmaps, or nil for an unlit face
  • styles — up to four light style numbers, one lightmap of (div(s_extent, luxel) + 1) * (div(t_extent, luxel) + 1) samples each, in order
  • luxel — how many texture pixels one lightmap sample covers, 16 by default

Summary

Functions

The middle of the face's corners.

The lightmap's size in samples, {across, down}.

The face with mins and extents worked out from its points: the smallest and largest texture place, out to whole luxels.

Where a point lies on the face's texture, {s, t}.

Types

t()

@type t() :: %Cauldron3D.Bsp.Face{
  back?: boolean(),
  extents: {non_neg_integer(), non_neg_integer()},
  lightmap: non_neg_integer() | nil,
  luxel: pos_integer(),
  mins: {integer(), integer()},
  plane: non_neg_integer(),
  points: [Cauldron3D.Vec.t()],
  s: {Cauldron3D.Vec.t(), float()},
  styles: [non_neg_integer()],
  t: {Cauldron3D.Vec.t(), float()},
  texture: non_neg_integer()
}

Functions

centre(face)

@spec centre(t()) :: Cauldron3D.Vec.t()

The middle of the face's corners.

lightmap_size(face)

@spec lightmap_size(t()) :: {pos_integer(), pos_integer()}

The lightmap's size in samples, {across, down}.

measured(face)

@spec measured(t()) :: t()

The face with mins and extents worked out from its points: the smallest and largest texture place, out to whole luxels.

st(face, point)

@spec st(t(), Cauldron3D.Vec.t()) :: {float(), float()}

Where a point lies on the face's texture, {s, t}.