use super::tokens::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum TextureFormat {
#[default]
Automatic,
Latlong,
MirroredBall,
Angular,
CubeMapVerticalCross,
}
impl TextureFormat {
pub fn as_token(self) -> &'static str {
match self {
TextureFormat::Automatic => TEXTURE_FORMAT_AUTOMATIC,
TextureFormat::Latlong => TEXTURE_FORMAT_LATLONG,
TextureFormat::MirroredBall => TEXTURE_FORMAT_MIRRORED_BALL,
TextureFormat::Angular => TEXTURE_FORMAT_ANGULAR,
TextureFormat::CubeMapVerticalCross => TEXTURE_FORMAT_CUBE_MAP_VERTICAL_CROSS,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
TEXTURE_FORMAT_AUTOMATIC => TextureFormat::Automatic,
TEXTURE_FORMAT_LATLONG => TextureFormat::Latlong,
TEXTURE_FORMAT_MIRRORED_BALL => TextureFormat::MirroredBall,
TEXTURE_FORMAT_ANGULAR => TextureFormat::Angular,
TEXTURE_FORMAT_CUBE_MAP_VERTICAL_CROSS => TextureFormat::CubeMapVerticalCross,
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum PoleAxis {
#[default]
SceneUp,
Y,
Z,
}
impl PoleAxis {
pub fn as_token(self) -> &'static str {
match self {
PoleAxis::SceneUp => POLE_AXIS_SCENE_UP,
PoleAxis::Y => POLE_AXIS_Y,
PoleAxis::Z => POLE_AXIS_Z,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
POLE_AXIS_SCENE_UP => PoleAxis::SceneUp,
POLE_AXIS_Y => PoleAxis::Y,
POLE_AXIS_Z => PoleAxis::Z,
_ => return None,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum LightListCacheBehavior {
#[default]
ConsumeAndContinue,
ConsumeAndHalt,
Ignore,
}
impl LightListCacheBehavior {
pub fn as_token(self) -> &'static str {
match self {
LightListCacheBehavior::ConsumeAndContinue => CACHE_BEHAVIOR_CONSUME_AND_CONTINUE,
LightListCacheBehavior::ConsumeAndHalt => CACHE_BEHAVIOR_CONSUME_AND_HALT,
LightListCacheBehavior::Ignore => CACHE_BEHAVIOR_IGNORE,
}
}
pub fn from_token(s: &str) -> Option<Self> {
Some(match s {
CACHE_BEHAVIOR_CONSUME_AND_CONTINUE => LightListCacheBehavior::ConsumeAndContinue,
CACHE_BEHAVIOR_CONSUME_AND_HALT => LightListCacheBehavior::ConsumeAndHalt,
CACHE_BEHAVIOR_IGNORE => LightListCacheBehavior::Ignore,
_ => return None,
})
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadLight {
pub path: String,
pub intensity: f32,
pub exposure: f32,
pub diffuse: f32,
pub specular: f32,
pub normalize: bool,
pub color: [f32; 3],
pub enable_color_temperature: bool,
pub color_temperature: f32,
pub filters: Vec<String>,
}
impl Default for ReadLight {
fn default() -> Self {
Self {
path: String::new(),
intensity: 1.0,
exposure: 0.0,
diffuse: 1.0,
specular: 1.0,
normalize: false,
color: [1.0, 1.0, 1.0],
enable_color_temperature: false,
color_temperature: 6500.0,
filters: Vec::new(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadDistantLight {
pub common: ReadLight,
pub angle_deg: f32,
}
impl Default for ReadDistantLight {
fn default() -> Self {
Self {
common: ReadLight {
intensity: 50000.0, ..ReadLight::default()
},
angle_deg: 0.53,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadSphereLight {
pub common: ReadLight,
pub radius: f32,
pub treat_as_point: bool,
}
impl Default for ReadSphereLight {
fn default() -> Self {
Self {
common: ReadLight::default(),
radius: 0.5,
treat_as_point: false,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadRectLight {
pub common: ReadLight,
pub width: f32,
pub height: f32,
pub texture_file: Option<String>,
}
impl Default for ReadRectLight {
fn default() -> Self {
Self {
common: ReadLight::default(),
width: 1.0,
height: 1.0,
texture_file: None,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadDiskLight {
pub common: ReadLight,
pub radius: f32,
}
impl Default for ReadDiskLight {
fn default() -> Self {
Self {
common: ReadLight::default(),
radius: 0.5,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadCylinderLight {
pub common: ReadLight,
pub length: f32,
pub radius: f32,
pub treat_as_line: bool,
}
impl Default for ReadCylinderLight {
fn default() -> Self {
Self {
common: ReadLight::default(),
length: 1.0,
radius: 0.5,
treat_as_line: false,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadDomeLight {
pub common: ReadLight,
pub texture_file: Option<String>,
pub texture_format: TextureFormat,
pub portals: Vec<String>,
pub guide_radius: f32,
pub pole_axis: Option<PoleAxis>,
}
impl Default for ReadDomeLight {
fn default() -> Self {
Self {
common: ReadLight::default(),
texture_file: None,
texture_format: TextureFormat::Automatic,
portals: Vec::new(),
guide_radius: 1.0e5,
pole_axis: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ReadGeometryLight {
pub common: ReadLight,
pub geometry: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadPortalLight {
pub common: ReadLight,
pub width: f32,
pub height: f32,
}
impl Default for ReadPortalLight {
fn default() -> Self {
Self {
common: ReadLight::default(),
width: 1.0,
height: 1.0,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ReadAnyLight {
Distant(ReadDistantLight),
Sphere(ReadSphereLight),
Rect(ReadRectLight),
Disk(ReadDiskLight),
Cylinder(ReadCylinderLight),
Dome(ReadDomeLight),
Geometry(ReadGeometryLight),
Portal(ReadPortalLight),
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadShaping {
pub focus: f32,
pub focus_tint: [f32; 3],
pub cone_angle_deg: f32,
pub cone_softness: f32,
pub ies_file: Option<String>,
pub ies_angle_scale: f32,
pub ies_normalize: bool,
}
impl Default for ReadShaping {
fn default() -> Self {
Self {
focus: 0.0,
focus_tint: [0.0, 0.0, 0.0],
cone_angle_deg: 90.0,
cone_softness: 0.0,
ies_file: None,
ies_angle_scale: 0.0,
ies_normalize: false,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct ReadShadow {
pub enable: bool,
pub color: [f32; 3],
pub distance: f32,
pub falloff: f32,
pub falloff_gamma: f32,
}
impl Default for ReadShadow {
fn default() -> Self {
Self {
enable: true,
color: [0.0, 0.0, 0.0],
distance: -1.0,
falloff: -1.0,
falloff_gamma: 1.0,
}
}
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ReadLightList {
pub lights: Vec<String>,
pub cache_behavior: LightListCacheBehavior,
}
#[derive(Debug, Clone, Default)]
pub struct LuxPrims {
pub distant: Vec<String>,
pub sphere: Vec<String>,
pub rect: Vec<String>,
pub disk: Vec<String>,
pub cylinder: Vec<String>,
pub dome: Vec<String>,
pub geometry: Vec<String>,
pub portal: Vec<String>,
pub light_filters: Vec<String>,
pub light_api: Vec<String>,
pub shaping: Vec<String>,
pub shadow: Vec<String>,
pub light_list: Vec<String>,
}