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

Classes

struct  nnl::collision::Triangle
 Struct defining a single triangle used in collision detection. More...
struct  nnl::collision::Edge
 Struct defining a wall edge used in collision detection. More...
struct  nnl::collision::CollisionTest
 Struct representing a set of geometric shapes for collision testing. More...
struct  nnl::collision::Collision
 Struct that contains all necessary information for collision detection. More...
struct  nnl::collision::ConvertParam
 Parameters for converting a simplified mesh to the in-game collision format. More...

Enumerations

enum class  nnl::collision::SurfaceFeatures : u16 {
  nnl::collision::SurfaceFeatures::kNone = 0 , nnl::collision::SurfaceFeatures::kDirt = 0b0000'0001 , nnl::collision::SurfaceFeatures::kDirt2 = 0b0000'0010 , nnl::collision::SurfaceFeatures::kSand = 0b0000'0011 ,
  nnl::collision::SurfaceFeatures::kStone = 0b0000'0100 , nnl::collision::SurfaceFeatures::kGrass = 0b0000'0101 , nnl::collision::SurfaceFeatures::kWater = 0b0000'0110 , nnl::collision::SurfaceFeatures::kWood = 0b0000'0111 ,
  nnl::collision::SurfaceFeatures::kStone2 = 0b0000'1000 , nnl::collision::SurfaceFeatures::kMetal = 0b0000'1001 , nnl::collision::SurfaceFeatures::kShadow = 0b0001'0000 , nnl::collision::SurfaceFeatures::kPassThrowables = 0b010'0000'0000 ,
  nnl::collision::SurfaceFeatures::kPassCamera = 0b100'0000'0000
}
 Enum representing different settings for surfaces. More...
enum class  nnl::collision::PushFeatures : u16 { nnl::collision::PushFeatures::kNone = 0 , nnl::collision::PushFeatures::kPushBack = 0b01 , nnl::collision::PushFeatures::kPushIfStuck = 0b10 }
 Enum representing different push behaviors for entities. More...

Functions

SModel nnl::collision::Convert (const Collision &collision)
 Converts collision data from the in-game format to a simplified model representation.
Collision nnl::collision::Convert (SModel &&smodel, const std::vector< ConvertParam > &mesh_params, bool auto_wall=true, u32 shift=5)
 Converts a simplified representation of a model to the in-game collision format.
bool nnl::collision::IsOfType (BufferView buffer)
 Tests if the provided file is a collision config.
Collision nnl::collision::Import (BufferView buffer)
 Parses a binary file and converts it to a structured collision.
Buffer nnl::collision::Export (const Collision &collision)
 Converts a collision config to a binary file representation.

Detailed Description


Class Documentation

◆ nnl::collision::Triangle

struct nnl::collision::Triangle

Struct defining a single triangle used in collision detection.

See also
nnl::collision::CollisionTest
nnl::collision::Collision::normals
nnl::collision::Collision::vertices

Public Attributes

std::array< u16, 3 > indices_vertices {0}
 Indices of the triangle's vertices.
u16 index_normal = 0
 Index of the triangle's normal.
u16 index_vertex_min = 0
u16 index_vertex_max = 0
PushFeatures push_features {}
 Push behavior flags.
SurfaceFeatures surface_features {}
 Surface behavior flags.

Member Data Documentation

◆ index_normal

u16 nnl::collision::Triangle::index_normal = 0

Index of the triangle's normal.

◆ index_vertex_max

u16 nnl::collision::Triangle::index_vertex_max = 0

Index of the triangle's bounding maximum coordinate (max x, max y, max z)

◆ index_vertex_min

u16 nnl::collision::Triangle::index_vertex_min = 0

Index of the triangle's bounding minimum coordinate (min x, min y, min z)

◆ indices_vertices

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

Indices of the triangle's vertices.

◆ push_features

PushFeatures nnl::collision::Triangle::push_features {}

Push behavior flags.

◆ surface_features

SurfaceFeatures nnl::collision::Triangle::surface_features {}

Surface behavior flags.

◆ nnl::collision::Edge

struct nnl::collision::Edge

Struct defining a wall edge used in collision detection.

This structure seems to be optional and likely serves as an optimization for collision detection with "wall" triangles.

See also
nnl::collision::CollisionTest
nnl::collision::Collision::normals
nnl::collision::Collision::vertices

Public Attributes

std::array< u16, 2 > indices_vertices {0}
 Indices of the edge's vertices.
u16 index_vertex_min = 0
u16 index_vertex_max = 0
u16 index_normal = 0
 Index of the flipped triangle's normal.

Member Data Documentation

◆ index_normal

u16 nnl::collision::Edge::index_normal = 0

Index of the flipped triangle's normal.

◆ index_vertex_max

u16 nnl::collision::Edge::index_vertex_max = 0

Index of the edge's bounding maximum coordinate (max x, max y, max z)

◆ index_vertex_min

u16 nnl::collision::Edge::index_vertex_min = 0

Index of the edge's bounding minimum coordinate (min x, min y, min z)

◆ indices_vertices

std::array<u16, 2> nnl::collision::Edge::indices_vertices {0}

Indices of the edge's vertices.

◆ nnl::collision::CollisionTest

struct nnl::collision::CollisionTest

Struct representing a set of geometric shapes for collision testing.

The CollisionTest struct holds the indices of geometric shapes that are relevant for collision testing at the player's current position.

See also
nnl::collision::Collision

Public Attributes

std::vector< u16triangle_indices
std::vector< u16triangle_wall_indices
std::vector< u16edge_wall_indices

Member Data Documentation

◆ edge_wall_indices

std::vector<u16> nnl::collision::CollisionTest::edge_wall_indices

Holds the indices of "wall" edges to be tested. These seem to be an optional optimization.

◆ triangle_indices

std::vector<u16> nnl::collision::CollisionTest::triangle_indices

Holds the indices of triangles to be tested.

◆ triangle_wall_indices

std::vector<u16> nnl::collision::CollisionTest::triangle_wall_indices

Holds the indices of "wall" triangles to be tested.

◆ nnl::collision::Collision

struct nnl::collision::Collision

Struct that contains all necessary information for collision detection.

The Collision struct contains parameters and data structures necessary for performing collision detection.

Note
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 meshes and possibly other data.
See also
nnl::asset::Asset
nnl::asset::Asset3D
nnl::model::Model
nnl::shadow_collision::Collision

Public Attributes

u16 shift_value = 5
glm::vec3 origin_point {0.0f}
std::vector< glm::vec3 > vertices
std::vector< glm::vec3 > normals
 Normal vectors associated with the geometric shapes.
std::vector< Triangletriangles
 List of triangles.
std::vector< Edgeedges
 List of wall edges.
utl::Array3D< CollisionTestcoordinate_map

Member Data Documentation

◆ coordinate_map

utl::Array3D<CollisionTest> nnl::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)

◆ edges

std::vector<Edge> nnl::collision::Collision::edges

List of wall edges.

◆ normals

std::vector<glm::vec3> nnl::collision::Collision::normals

Normal vectors associated with the geometric shapes.

◆ origin_point

glm::vec3 nnl::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::collision::Collision::shift_value = 5

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

◆ triangles

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

List of triangles.

◆ vertices

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

The vertices that are used to define the geometric shapes involved in collision detection.

◆ nnl::collision::ConvertParam

struct nnl::collision::ConvertParam

Parameters for converting a simplified mesh to the in-game collision format.

This struct contains settings that configure collision meshes.

See also
nnl::SMesh

Enumeration Type Documentation

◆ PushFeatures

enum class nnl::collision::PushFeatures : u16
strong

Enum representing different push behaviors for entities.

This enum defines various settings that determine how entities interact with collision surfaces when they get too close to them.

See also
nnl::colbox::ColBoxConfig
Enumerator
kNone 

Default.

kPushBack 

This flag should be used for meshes that act as walls. When an entity is too close to the object, it will be pushed back to prevent overlap.

kPushIfStuck 

This flag should be used for meshes that act as ceilings.

◆ SurfaceFeatures

enum class nnl::collision::SurfaceFeatures : u16
strong

Enum representing different settings for surfaces.

The surface features determine how an entity collides with a surface and what sounds and effects are used when it does.

Note
This enum reflects the original game's binary format. The first 4 bits represent mutually exclusive surface types, while higher bits are additive behavior flags.
Enumerator
kNone 

Default, same as kDirt.

kDirt 

Dirt.

kDirt2 

Another type of dirt.

kSand 

Sand.

kStone 

Stone or gravel.

kGrass 

Grass.

kWater 

Water.

kWood 

Wood.

kStone2 

Another type of stone.

kMetal 

Metal.

kShadow 

Darkens characters that step on the surface.

Note
This flag works properly only in NSLAR.
kPassThrowables 

Allows the camera and throwable objects to pass through the surface.

kPassCamera 

Allows the camera to pass through the surface.

Function Documentation

◆ Convert() [1/2]

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

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

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

◆ Convert() [2/2]

Collision nnl::collision::Convert ( SModel && smodel,
const std::vector< ConvertParam > & mesh_params,
bool auto_wall = true,
u32 shift = 5 )

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

Parameters
smodelThe source model to be converted.
mesh_paramsThe parameters that dictate how the conversion should be performed for each mesh.
auto_wallAutomatically set appropriate PushFlags.
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::collision::Export ( const Collision & collision)
nodiscard

Converts a 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::collision::Import ( BufferView buffer)

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

This function takes a binary representation of a 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::collision::IsOfType
nnl::collision::Export

◆ IsOfType()

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

Tests if the provided file is a collision config.

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

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