plasma_prp/rendering/
fog.rs1use std::io::Read;
6
7use anyhow::Result;
8
9use crate::core::synched_object::SynchedObjectData;
10use crate::core::uoid::{Uoid, read_key_uoid};
11use crate::material::layer::Color;
12use crate::resource::prp::PlasmaRead;
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub enum FogType {
17 Linear = 0,
18 ExpX = 1,
19 Exp2X = 2,
20}
21
22impl FogType {
23 pub fn from_u8(v: u8) -> Self {
24 match v {
25 1 => Self::ExpX,
26 2 => Self::Exp2X,
27 _ => Self::Linear,
28 }
29 }
30}
31
32#[derive(Debug, Clone)]
34pub struct FogEnvironmentData {
35 pub self_key: Option<Uoid>,
36 pub synched: SynchedObjectData,
37 pub fog_type: FogType,
38 pub start: f32,
39 pub end: f32,
40 pub density: f32,
41 pub color: Color,
42}
43
44impl FogEnvironmentData {
45 pub fn read(reader: &mut impl Read) -> Result<Self> {
46 let self_key = read_key_uoid(reader)?;
47 let synched = SynchedObjectData::read(reader)?;
48
49 let fog_type = FogType::from_u8(reader.read_u8()?);
50 let start = reader.read_f32()?;
51 let end = reader.read_f32()?;
52 let density = reader.read_f32()?;
53 let color = Color::read(reader)?;
54
55 Ok(Self {
56 self_key,
57 synched,
58 fog_type,
59 start,
60 end,
61 density,
62 color,
63 })
64 }
65}