#include <PhxTerrainDatabase.h>
Inheritance diagram for Phx::GraphicsEngine::TerrainGeometry::TerrainDatabase:

Public Types | |
| typedef uint64_t | QuadIdentifier |
| A code type that is used to identify quads within the database. | |
| typedef uint32_t | ChildIndex |
| typedef float | HeightValue |
Public Member Functions | |
| virtual Vector3 | rootCorner (QuadIdentifier identifier, ChildIndex which)=0 |
Returns a corner of the root quad containing identifier. | |
| virtual double | ellipsoidRadius (const Vector3 &v)=0 |
Returns the radius of the "ellipsoid" beneath the vector v. | |
|
virtual Ptr< const Buffer< HeightValue > > | newHeightBuffer (QuadIdentifier identifier, uint32_t resolution)=0 |
|
virtual Ptr< const Buffer< uint8_t > > | newColorBuffer (QuadIdentifier identifier, uint32_t resolution)=0 |
|
virtual Ptr< const Buffer< uint8_t > > | newBandBuffer (QuadIdentifier identifier, const String &band, uint32_t resolution)=0 |
Static Public Member Functions | |
| static bool | isRootIdentifier (QuadIdentifier identifier) |
| Returns whether a valid identifier is a root identifier. | |
| static QuadIdentifier | rootIdentifier (QuadIdentifier quad) |
| Returns the root identifier contained in a quad identifier. | |
| static QuadIdentifier | childIdentifier (QuadIdentifier parent, ChildIndex c) |
Returns the identifier for a child of parent. | |
| static QuadIdentifier | parentIdentifier (QuadIdentifier quad) |
Returns the parent identifier of quad. | |
| static Rectangle< float > | uvCoords (QuadIdentifier identifier) |
| Computes the UV coordinates of a quad within its root quad. | |
Static Public Attributes | |
| static const ChildIndex | LL = 0 |
| static const ChildIndex | UL = 1 |
| static const ChildIndex | LR = 2 |
| static const ChildIndex | UR = 3 |
| static const ChildIndex | CHILD_COUNT = 4 |
| static const QuadIdentifier | INVALID_IDENTIFIER = ((uint64_t)-1) |
| An identifier returned when an operation fails. | |
| static const uint32_t | ROOT_IDENTIFIER_BITS = 24 |
| Every identifier is composed of a "root" identifier which is an even number of leading bits. | |
| static const uint32_t | QUAD_IDENTIFIER_BITS = 64 - ROOT_IDENTIFIER_BITS |
| The number of bits used to identify a quad within a tree. | |
| static const QuadIdentifier | MIN_ROOT_IDENTIFIER = ((uint64_t)1)<<(ROOT_IDENTIFIER_BITS-2) |
| Every root identifier must have a 1 in one of the two leading bits; this implies a minimum value of such an identifier. | |
| static const QuadIdentifier | MAX_ROOT_IDENTIFIER = (((uint64_t)1)<<ROOT_IDENTIFIER_BITS)-1 |
| This is the largest possible root identifier, given the choice of ROOT_IDENTIFIER_BITS. | |
The TerrainDatabase maintains all of the information for a terrain dataset. Each dataset is composed of a set of "root" level quadrangles stretched between four corner points. Each of these root quads is assigned an identifier. The root quads are then subdivided into four child quads, each of which has its own identifier derived from its parent's identifier. A local surface coordinate system is attached to each root quad. (0,0) corresponds to the "lower left" corner of the root quad, and (1,1) corresponds to the "upper right" corner. These designations are arbitrary, but consistent. Within the root quad, its 4 children share the interior point (0.5, 0.5) as their corner. We call these "UV coordinates", as they are like texture coordinates. One can use the uvCoords() method to find the UV coordinates of a quad, relative to the root quad, from its identifier.
This hierarchy of quads is a "forest" -- a collection of quad trees. Each identifier corresponds to a node in one of these trees, with a root identifier designating the root of a particular tree. The database implementation should respond quickly to requests for terrain information covering any of these quads.
The public interface provides a number of inline static methods, that are concurrently accessible, to allow the manipulation of the quad identifiers. The primary client of the database (typically the object that constructed the TerrainGeometry) also has the ability to perform queries using these codes, getting buffers of data in return.
|
||||||||||||
|
Returns the identifier for a child of
|
|
|
Returns the radius of the "ellipsoid" beneath the vector
More accurately, this is the distance from the "mean sea level" surface at a point below
|
|
|
Returns whether a valid identifier is a root identifier.
|
|
|
Returns the parent identifier of
|
|
||||||||||||
|
Returns a corner of the root quad containing
Specifically, each root quad has four corners (corresponding to the four children: LL, UL, LR, UR). This method determines the root identifier of
|
|
|
Returns the root identifier contained in a quad identifier.
Contained in the most significant nonzero bits, on 2-bit boundaries, of the identifier
|
|
|
Computes the UV coordinates of a quad within its root quad.
|
|
|
This is the largest possible root identifier, given the choice of ROOT_IDENTIFIER_BITS.
This is essentially ROOT_IDENTIFIER_BITS 1's in the QuadIdentifier's LSBs. Hence, it can be used as a mask to determine if an identifier is a root identifier: if !(identifier & ~MAX_ROOT_IDENTIFIER) then |
|
|
Every root identifier must have a 1 in one of the two leading bits; this implies a minimum value of such an identifier. The "leading 1 requirement" guarantees that, after shifts by two bits, there is no ambiguitity with identifiers starting at another root identifier. Thus, the smallest root identifier is one that has a '1' in the second bit of its most-significant two bits. |
|
|
Every identifier is composed of a "root" identifier which is an even number of leading bits. The choice of root identifier length is based on the underlying system. IEEE floats allow precision of 2^-23, and hence 23 levels per tree (if implemented perfectly). For elbow room, we allow 20 levels per tree, requiring 40 bits for the identifier of each tree. Thus, we use the remaining 24 bits for the root identifier, which designates the tree to which an identifier pertains. |
1.4.2