NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
lit.hpp
Go to the documentation of this file.
1
13#pragma once
14#include <array>
15
17#include "NNL/common/io.hpp"
19#include "NNL/utility/data.hpp"
20
21namespace nnl {
32namespace lit {
38
47struct Light {
48 bool active = false;
49 glm::vec3 direction = {0, 1.0f, 0};
50 u32 diffuse = 0xFF'FF'FF'FF;
52 u32 specular = 0xFF'00'00'00;
54};
55
59struct Lit {
60 std::array<Light, 3> lights;
62 glm::vec3 cel_shadow_light_direction = {0, 1.0f, 0};
66 u32 global_ambient = 0xFF'7F'7F'7F;
68};
69
77std::vector<nnl::SLight> Convert(const Lit& lit);
90Lit Convert(const std::vector<nnl::SLight>& slights, glm::vec3 ambient = glm::vec3(0), bool enable_specular = true,
91 float character_brightness = 1.0f);
92
104bool IsOfType(BufferView buffer);
105
106bool IsOfType(const std::filesystem::path& path);
107
108bool IsOfType(Reader& f);
109
124
125Lit Import(const std::filesystem::path& path);
126
127Lit Import(Reader& f);
137[[nodiscard]] Buffer Export(const Lit& lit);
138
139void Export(const Lit& lit, const std::filesystem::path& path);
140
141void Export(const Lit& lit, Writer& f);
143
144namespace raw {
150constexpr u32 kMagicBytes = utl::data::FourCC("LIT!");
151
152NNL_PACK(struct RLight {
153 Vec3<i8> direction{0};
154 Vec3<u8> diffuse{0}; // rgb
155 Vec3<u8> specular{0}; // rgb
156});
157
158static_assert(sizeof(RLight) == 0x9);
159
160NNL_PACK(struct RLit {
161 u32 magic_bytes = kMagicBytes; // 0x0
162 u8 active_flags = 0b0'0'0; // 0x4
163 RLight lights[4] = {}; // 0x5 4th light is a placeholder
164 Vec3<i8> shadow_light_direction{0}; // 0x29
165 u8 character_brightness = 0; // 0x2C
166 Vec3<u8> global_ambient{0}; // 0x2D rgb
167 u32 unknown30 = 0xFF'FF'FF'FF; // 0x30 unused
168 u8 unknown34 = 0xFF; // 0x34 unused
169});
170
171static_assert(sizeof(RLit) == 0x35);
172
173Lit Convert(const RLit& rlit);
174
175RLit Parse(Reader& f);
177} // namespace raw
178} // namespace lit
179
180} // namespace nnl
Provides functions and classes for handling binary data.
Contains macros and definitions for fixed-width types.
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::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
std::uint8_t u8
8-bit unsigned integer
Definition fixed_type.hpp:64
#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
glm::vec3 cel_shadow_light_direction
Definition lit.hpp:62
std::array< Light, 3 > lights
Definition lit.hpp:60
u32 specular
Definition lit.hpp:52
u32 diffuse
Definition lit.hpp:50
glm::vec3 direction
Direction to the light source.
Definition lit.hpp:49
u32 global_ambient
Definition lit.hpp:66
u8 character_brightness
Definition lit.hpp:64
bool active
Indicates if the light is used.
Definition lit.hpp:48
Represents a lighting configuration for a scene.
Definition lit.hpp:59
Represents a directional light in the scene. This structure represents a directional light source tha...
Definition lit.hpp:47
Lit Import(BufferView buffer)
Parses a binary file and converts it to a Lit struct.
Buffer Export(const Lit &lit)
Converts a light config to a binary file representation.
bool IsOfType(BufferView buffer)
Tests if the provided file is a light source config.
std::vector< nnl::SLight > Convert(const Lit &lit)
Converts a light config to a more generic representation that is more suitable for exporting into oth...
constexpr u32 kMagicBytes
Magic bytes.
Definition lit.hpp:150
Provides classes for reading and writing binary data to and from various sources.
Contains structures and functions for working with light source configs.
Definition lit.hpp:32
Definition exception.hpp:56
Provides data structures for representing essential components of a 3D asset.