Cubemap
Description
The Cubemap class implements the concept of cubemaps as used by Tinman for MapType.Cube terrains.
The following figure shows the relation between cubemap coordinates and cubemap face coordinates:
Y- Z+ E-------F [0,0,n] [n,0,n] | / /. /| E ------------ F |/ / . / | | | X- --+-- X+ A-------B | | o--------> | /| | G....|..H | | +fx | / | | . | / | | Y- | Z- Y+ |. |/ | | | C-------D | V +fy | [0,0,0] [n,0,0] [n,0,n] [0,0,n] [0,0,0] A ------------ B ------------ F ------------ E ------------ A | | | | | | o--------> | o--------> | o--------> | o--------> | | | +fx | | +fx | | +fx | | +fx | | | Z- | | X+ | | Z+ | | X- | | | | | | | | | | | V +fy | V +fy | V +fy | V +fy | | | | | | C ------------ D ------------ H ------------ G ------------ C [0,n,0] [n,n,0] [n,n,n] [0,n,n] [0,n,0] | o--------> | | | +fx | | | Y+ | n := Maximum cubemap coordinate | | | [x,y,z] := Cubemap coordinates | V +fy | fx := Positive cubemap face X-axis | | fy := Positive cubemap face Y-axis G ------------ H [0,n,n] [n,n,n]
The cross-product between the cubemap face X-axis and Y-axis point towards the interior of the cubemap cube. This figure shows the possible cubemap wrapping cases (along edges and corners):
+--------------------+--------------------+--------------------+--------------------+ | [E] -fy Y- | [F] +fx X+ | [A] -fy X- | [B] -fy X+ | | \ \ | \ \ | \ \ | \ \ | | -fx \ o-- +fx | -fy \ o-- +fy | -fy \ o-- -fx | -fy \ o-- +fx | | \ \ | \ \ | \ \ | \ \ | | X- o [A]----[B] | Y- o [B]----[D] | Z- o [C]----[G] | Z- o [D]----[H] | | / / | / / | / / | / / | | +fy / o-- +fx | -fx / o-- +fy | +fx / o-- +fy | -fx / o-- +fy | | / / | / / | / / | / / | | [C] +fy Z- | [A] -fx Z- | [D] +fx Y+ | [C] -fx Y+ | +--------------------+--------------------+--------------------+--------------------+ | [G] +fy Z+ | [E] +fx Z+ | [E] -fy Z+ | [F] -fy X+ | | \ \ | \ \ | \ \ | \ \ | | +fy \ o-- -fx | -fx \ o-- +fy | -fy \ o-- -fx | -fy \ o-- -fx | | \ \ | \ \ | \ \ | \ \ | | X- o [E]----[F] | Y- o [F]----[H] | X- o [G]----[H] | Z+ o [H]----[D] | | / / | / / | / / | / / | | +fx / o-- +fx | +fy / o-- +fy | +fx / o-- +fx | +fx / o-- -fy | | / / | / / | / / | / / | | [A] +fy Y- | [B] -fx X+ | [C] -fy Y+ | [G] -fx Y+ | +--------------------+--------------------+--------------------+--------------------+
- See also
Public / Constants
FirstFace
The CubemapFace with minimal ordinal value.
Use this constant for iterating through cubemap faces.
- See also
LastFace
The CubemapFace with maximum ordinal value.
Use this constant for iterating through cubemap faces.
- See also
Public / Methods
CreateTestPattern
Builds a test pattern for cubemaps.
The test pattern for each cubemap face (512 pixel units) contains a grid a tiles (64 pixel units), where the cubemap coordinates are encoded in the background color. The cubemap face name and the cubemap coordinates are also output as text into the tile.
CubeToFace
9 overloads
Intersects the given box with a cubemap face and returns the resulting rectangle in cubemap face coordinates.
Converts the given set of unit cubemap coordinates to unit cubemap face coordinates.
Converts the given set of unit cubemap coordinates to unit cubemap face coordinates.
Converts the given set of unit cubemap coordinates to unit cubemap face coordinates.
Converts the given set of unit cubemap coordinates to unit cubemap face coordinates.
Translates the given cubemap coordinates into cubemap face coordinates (if possible).
Translates the given cubemap coordinates into cubemap face coordinates (if possible).
Translates the given cubemap coordinates into cubemap face coordinates (if possible).
Translates the given cubemap coordinates into cubemap face coordinates (if possible).
CubeToGeographic
2 overloads
Computes geographic coordinates (i.e. latitude and longitude) from the given cubemap coordinates.
Computes geographic coordinates (i.e. latitude and longitude) from the given cubemap coordinates.
CubeToLinear
2 overloads
Translates the given cubemap coordinates into a linear storage index.
- See also
Translates the given cubemap coordinates into a linear storage index.
- See also
CubeToVector
2 overloads
Computes a direction vector from the given cubemap coordinates.
Computes a direction vector from the given cubemap coordinates.
FaceToCube
5 overloads
Computes the bounding box in cubemap coordinates for the given bounding box in cubemap face coordinates.
The given cubemap face coordinates are allowed to lie outside the face bounds along one dimension; proper wrapping will be performed automatically.
Converts the given set of unit cubemap face coordinates to unit cubemap coordinates.
The given cubemap face coordinates are allowed to lie outside the face bounds along one dimension; proper wrapping will be performed automatically.
Converts the given set of unit cubemap face coordinates to unit cubemap coordinates.
The given cubemap face coordinates are allowed to lie outside the face bounds along one dimension; proper wrapping will be performed automatically.
Converts the given set of unit cubemap face coordinates to unit cubemap coordinates.
The given cubemap face coordinates are allowed to lie outside the face bounds along one dimension; proper wrapping will be performed automatically.
If faceX in and/or faceY in are less than -n
or greater than 2*n
, the method will return Vec2I.Zero.
Converts the given set of unit cubemap face coordinates to unit cubemap coordinates.
The given cubemap face coordinates are allowed to lie outside the face bounds along one dimension; proper wrapping will be performed automatically.
If faceX in and/or faceY in are less than -n
or greater than 2*n
, the method will return Vec2D.Undefined.
GeographicToCube
2 overloads
Computes cubemap coordinates from the given geographic coordinates (i.e. latitude and longitude).
Computes cubemap coordinates from the given geographic coordinates (i.e. latitude and longitude).
PackCube
2 overloads
Packs the given cubemap face coordinates into a single 63-bit value.
Packs the given cubemap face coordinates into a single 63-bit value.
PackFace
2 overloads
Packs the given cubemap face coordinates into a single 63-bit value.
Packs the given cubemap face coordinates into a single 63-bit value.
SameFace
4 overloads
Checks if a in and b in lie on the same cubemap face.
Checks if a in and b in lie on the same cubemap face.
Checks if a in, b in and c in lie on the same cubemap face.
Checks if a in, b in and c in lie on the same cubemap face.
ToFaceDecompose
Returns the decomposition of the transformation from cubemap coordinate to cubemap face coordinates.
Cubemap face coordinates can be computed from cubemap coordinates as follows:
cube : cubemap coordinates (X, Y, Z) face : cubemap face coordinates (X, Z) face.X := offset.X + dot(x, cube) face.Y := offset.Y + dot(y, cube)
where offset
, x
and y
are computed by this method.