rpfm_lib/files/rigidmodel/materials/static_point_light.rs
1//---------------------------------------------------------------------------//
2// Copyright (c) 2017-2026 Ismael Gutiérrez González. All rights reserved.
3//
4// This file is part of the Rusted PackFile Manager (RPFM) project,
5// which can be found here: https://github.com/Frodo45127/rpfm.
6//
7// This file is licensed under the MIT license, which can be found here:
8// https://github.com/Frodo45127/rpfm/blob/master/LICENSE.
9//---------------------------------------------------------------------------//
10
11use super::*;
12
13/// Size in bytes of the name of a static point light.
14const STATIC_POINT_LIGHT_NAME_SIZE: usize = 512;
15
16//---------------------------------------------------------------------------//
17// Implementation
18//---------------------------------------------------------------------------//
19
20/// Static point light materials: the name of the light, and its position in `v_pivot`.
21impl Material {
22 pub fn read_static_point_light<R: ReadBytes>(data: &mut R, version: u32) -> Result<Self> {
23 Ok(Self {
24 name: read_padded_string(data, version, STATIC_POINT_LIGHT_NAME_SIZE)?,
25 v_pivot: Vector3::new(data.read_f32()?, data.read_f32()?, data.read_f32()?),
26 ..Default::default()
27 })
28 }
29
30 pub fn write_static_point_light<W: WriteBytes>(&self, data: &mut W, version: u32) -> Result<()> {
31 write_padded_string(data, version, &self.name, STATIC_POINT_LIGHT_NAME_SIZE)?;
32 data.write_f32(self.v_pivot.x)?;
33 data.write_f32(self.v_pivot.y)?;
34 data.write_f32(self.v_pivot.z)
35 }
36}