NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
posd.hpp
Go to the documentation of this file.
1
13#pragma once
14
15#include <vector>
16
17#include "NNL/common/io.hpp"
19#include "NNL/utility/data.hpp"
20namespace nnl {
31namespace posd {
46struct Position {
47 u32 id = 0;
49 glm::vec3 position{0.0f};
50 f32 radius = 80.0f;
51 f32 rotation = 0.0f;
52};
53
61using PositionData = std::vector<Position>;
69std::vector<SPosition> Convert(const PositionData& posd);
76PositionData Convert(const std::vector<SPosition>& positions);
77
89bool IsOfType(BufferView buffer);
90
91bool IsOfType(const std::filesystem::path& path);
92
93bool IsOfType(Reader& f);
94
109
110PositionData Import(const std::filesystem::path& path);
111
122[[nodiscard]] Buffer Export(const PositionData& posd);
123
124void Export(const PositionData& posd, const std::filesystem::path& path);
125
126void Export(const PositionData& posd, Writer& f);
128
129namespace raw {
130
136constexpr u32 kMagicBytes = utl::data::FourCC("POSD");
137
138NNL_PACK(struct RHeader {
139 u32 magic_bytes = kMagicBytes;
140 u32 num_positions = 0;
141});
142
143static_assert(sizeof(RHeader) == 0x8);
144
145NNL_PACK(struct RPosition {
146 u32 id = 0;
147 Vec3<f32> position{0.0f};
148 f32 radius = 0.0f;
149 i16 rotation = 0; // fixed point (4 bits - int, 11 - fraction)
150 u16 padding = 0;
151});
152
153static_assert(sizeof(RPosition) == 0x18);
154
155struct RPositionData {
156 RHeader header;
157 std::vector<RPosition> positions;
158};
159
160PositionData Convert(const RPositionData& posd);
161
162RPositionData Parse(Reader& f);
164} // namespace raw
165
166} // namespace posd
167
168} // namespace nnl
Provides functions and classes for handling binary data.
constexpr u32 FourCC(const char(&str)[5]) noexcept
Generates a numeric four character code from a given string.
Definition data.hpp:36
3D vector template with packed storage
Definition fixed_type.hpp:163
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
std::int16_t i16
16-bit signed integer
Definition fixed_type.hpp:63
float f32
32-bit floating point
Definition fixed_type.hpp:59
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
#define NNL_PACK(...)
A structure packing directive.
Definition fixed_type.hpp:41
Reader implementation for read-only memory buffers.
Definition io.hpp:598
Abstract class for writing data.
Definition io.hpp:136
Abstract class for reading data.
Definition io.hpp:78
std::vector< u8 > Buffer
A type alias for std::vector<u8> that denotes a raw, contiguous memory region that may be interpreted...
Definition io.hpp:40
f32 rotation
Rotation angle around the Y axis in degrees [-180.0, 180.0f].
Definition posd.hpp:51
glm::vec3 position
The 3D coordinates (x, y, z) of the position.
Definition posd.hpp:49
f32 radius
May affect the size of a mission circle.
Definition posd.hpp:50
Represents a spawn position in the world.
Definition posd.hpp:46
std::vector< Position > PositionData
A vector of Position structs.
Definition posd.hpp:61
PositionData Import(BufferView buffer)
Parses a binary file and converts it to PositionData.
Buffer Export(const PositionData &posd)
Converts a spawn position config to a binary file representation.
bool IsOfType(BufferView buffer)
Tests if the provided file is a spawn position config.
std::vector< SPosition > Convert(const PositionData &posd)
Converts a spawn position config into a format that is more suitable for further exporting into other...
constexpr u32 kMagicBytes
Magic bytes.
Definition posd.hpp:136
Provides classes for reading and writing binary data to and from various sources.
Contains functions and structures for working with spawn position configs.
Definition posd.hpp:31
Definition exception.hpp:56
Provides data structures for representing essential components of a 3D asset.