NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches

Classes

struct  nnl::shadow_collision::Triangle
 Struct defining a single triangle for projecting shadows onto it. More...
struct  nnl::shadow_collision::CollisionTest
 Struct representing a set of triangles to be tested for shadow projection. More...
struct  nnl::shadow_collision::Collision
 Struct that contains all necessary information for performing shadow projection. More...

Functions

SModel nnl::shadow_collision::Convert (const Collision &collision)
 Converts collision data from the in-game format to a simplified model representation.
Collision nnl::shadow_collision::Convert (SModel &&smodel, bool auto_cull=true, u32 shift=1)
 Converts a simplified representation of a model to the in-game shadow collision format that is used for shadow projection.
bool nnl::shadow_collision::IsOfType (BufferView buffer)
 Tests if the provided file is a shadow collision.
Collision nnl::shadow_collision::Import (BufferView buffer)
 Parses a binary file and converts it to a structured collision.
Buffer nnl::shadow_collision::Export (const Collision &collision)
 Converts a shadow collision config to a binary file representation.

Detailed Description


Class Documentation

◆ nnl::shadow_collision::Triangle

struct nnl::shadow_collision::Triangle

Struct defining a single triangle for projecting shadows onto it.

Public Attributes

std::array< u16, 3 > indices_vertices {0}
u16 shadow_features = 0

Member Data Documentation

◆ indices_vertices

std::array<u16, 3> nnl::shadow_collision::Triangle::indices_vertices {0}

Indices of the triangle's vertices.

See also
nnl::shadow_collision::Collision::vertices

◆ shadow_features

u16 nnl::shadow_collision::Triangle::shadow_features = 0

Not used in NSLAR, in NUC2 this can disable shadows (1) and possibly more...

◆ nnl::shadow_collision::CollisionTest

struct nnl::shadow_collision::CollisionTest

Struct representing a set of triangles to be tested for shadow projection.

The CollisionTest struct holds the indices of the triangles that are relevant for shadow projection at the player's current position.

See also
nnl::shadow_collision::Collision

◆ nnl::shadow_collision::Collision

struct nnl::shadow_collision::Collision

Struct that contains all necessary information for performing shadow projection.

The Collision struct contains parameters and data structures necessary for projection of fake shadows.

Note
This type of "collision" works only in NSLAR (it's also used in NUC2)

This struct stores only a portion of the data that may be required by a 3D asset to function properly. Its binary representation must be used as part of a larger container that should also include models and possibly other data.
See also
nnl::asset::Asset
nnl::asset::Asset3D
nnl::collision::Collision
nnl::model::Model

Public Attributes

u16 shift_value = 1
glm::vec3 origin_point {0.0f}
std::vector< glm::vec3 > vertices
std::vector< Triangletriangles
 List of triangles in the collision environment.
utl::Array3D< CollisionTestcoordinate_map

Member Data Documentation

◆ coordinate_map

utl::Array3D<CollisionTest> nnl::shadow_collision::Collision::coordinate_map

A 3D array that maps coordinates that the player can end up in to the corresponding collision tests. ((current_pos - origin_point)>>(shift_value+5))

◆ origin_point

glm::vec3 nnl::shadow_collision::Collision::origin_point {0.0f}

Represents the origin point in 3D space. All coordinates in the coordinate_map are assumed to be positive offsets relative to it.

◆ shift_value

u16 nnl::shadow_collision::Collision::shift_value = 1

The exponent of 2 that determines how the entire collision space is divided into smaller parts. E.g, the player's coordinates are shifted by this value to get a relevant entry in the coordinate_map.

◆ triangles

std::vector<Triangle> nnl::shadow_collision::Collision::triangles

List of triangles in the collision environment.

◆ vertices

std::vector<glm::vec3> nnl::shadow_collision::Collision::vertices

The vertices that are used to define the triangles involved in shadow projection.

Function Documentation

◆ Convert() [1/2]

SModel nnl::shadow_collision::Convert ( const Collision & collision)

Converts collision data from the in-game format to a simplified model representation.

Parameters
collisionThe in-game shadow collision format to be converted.
Returns
The converted model.

◆ Convert() [2/2]

Collision nnl::shadow_collision::Convert ( SModel && smodel,
bool auto_cull = true,
u32 shift = 1 )

Converts a simplified representation of a model to the in-game shadow collision format that is used for shadow projection.

Parameters
smodelThe source model to be converted.
auto_cullAutomatically remove triangles that do not belong to the ground.
shiftThe exponent of 2 that determines how the whole collision space is divided. Larger values can reduce the size of data but make collision testing slower.
Returns
The converted collision.
Note
Use std::move when passing an existing object.

◆ Export()

Buffer nnl::shadow_collision::Export ( const Collision & collision)
nodiscard

Converts a shadow collision config to a binary file representation.

This function takes a Collision object and converts it into a Buffer, which represents the binary format of the collision.

Parameters
collisionThe Collision object to be converted into a binary format.
Returns
A Buffer containing the binary representation of the collision.

◆ Import()

Collision nnl::shadow_collision::Import ( BufferView buffer)

Parses a binary file and converts it to a structured collision.

This function takes a binary representation of a shadow collision config, parses its contents, and converts them into a Collision struct for easier access and manipulation.

Parameters
bufferThe binary data to be processed.
Returns
A Collision object representing the converted data.
See also
nnl::shadow_collision::IsOfType
nnl::shadow_collision::Export

◆ IsOfType()

bool nnl::shadow_collision::IsOfType ( BufferView buffer)

Tests if the provided file is a shadow collision.

This function takes a file buffer and checks whether it corresponds to the in-game shadow collision format.

Parameters
bufferThe data to be tested.
Returns
Returns true if the file is identified as a shadow collision;
See also
nnl::shadow_collision::Import