use fere_common::*;
use fere_resources::{surface, Mesh, Texture};
use std::sync::Arc;
pub type ChamberIndex = u32;
pub struct InternalOp {
_creation_barrier: (),
}
impl InternalOp {
pub fn do_not_call_this() -> Self {
Self {
_creation_barrier: (),
}
}
}
#[derive(Debug)]
pub struct Object {
pub mesh: Arc<Mesh>,
pub shadow: bool,
pub irradiance_volume: bool,
pub trans: Mat4,
pub chamber_index: ChamberIndex,
}
#[derive(Debug)]
pub struct DrawGeneral {
pub object: Object,
pub surface: surface::GeneralI,
}
impl From<DrawGeneral> for RenderOp {
fn from(x: DrawGeneral) -> Self {
Self::DrawGeneral(x)
}
}
#[derive(Debug)]
pub struct DrawEmissiveStatic {
pub object: Object,
pub surface: surface::EmissiveStaticI,
pub point_light: Option<f32>,
}
impl From<DrawEmissiveStatic> for RenderOp {
fn from(x: DrawEmissiveStatic) -> Self {
Self::DrawEmissiveStatic(x)
}
}
#[derive(Debug)]
pub struct DrawEmissiveDynamic {
pub object: Object,
pub materials: surface::EmissiveMaterialI,
pub surface: surface::EmissiveDynamic,
}
impl From<DrawEmissiveDynamic> for RenderOp {
fn from(x: DrawEmissiveDynamic) -> Self {
Self::DrawEmissiveDynamic(x)
}
}
#[derive(Debug)]
pub struct DrawLine {
pub pos1: Vec3,
pub pos2: Vec3,
pub color: IVec4,
pub width: f32,
}
impl From<DrawLine> for RenderOp {
fn from(x: DrawLine) -> Self {
Self::DrawLine(x)
}
}
#[derive(Debug)]
pub struct DrawWireFrame {
pub mesh: Arc<Mesh>,
pub trans: Mat4,
pub color: IVec4,
pub width: f32,
}
impl From<DrawWireFrame> for RenderOp {
fn from(x: DrawWireFrame) -> Self {
Self::DrawWireFrame(x)
}
}
#[derive(Debug)]
pub struct AddMajorLight {
pub pos: Vec3,
pub color: Vec3,
pub xdir: Vec3,
pub ydir: Vec3,
pub perspective: f32,
pub chamber_index: ChamberIndex,
}
impl From<AddMajorLight> for RenderOp {
fn from(x: AddMajorLight) -> Self {
Self::AddMajorLight(x)
}
}
#[derive(Debug)]
pub struct MajorLightOmni {
pub pos: Vec3,
pub color: Vec3,
pub chamber_index: ChamberIndex,
}
impl From<MajorLightOmni> for RenderOp {
fn from(x: MajorLightOmni) -> Self {
RenderOp::Multiple(
(0..6)
.map(|i| {
let (xdir, ydir) = fere_common::geo::six_sides_dir(i);
AddMajorLight {
pos: x.pos,
color: x.color,
xdir,
ydir,
perspective: (90.0_f32).to_radians(),
chamber_index: x.chamber_index,
}
.into()
})
.collect(),
)
}
}
#[derive(Debug)]
pub struct AddPointLight {
pub pos: Vec3,
pub color: Vec3,
pub chamber_index: ChamberIndex,
}
impl From<AddPointLight> for RenderOp {
fn from(x: AddPointLight) -> Self {
Self::AddPointLight(x)
}
}
#[derive(Debug)]
pub struct AddAmbientLight {
pub color: Vec3,
pub omni: bool,
pub chamber_index: ChamberIndex,
}
impl From<AddAmbientLight> for RenderOp {
fn from(x: AddAmbientLight) -> Self {
Self::AddAmbientLight(x)
}
}
#[derive(Debug)]
pub struct ShadeWithIv {
pub chamber_index: ChamberIndex,
pub weight: f32,
}
impl From<ShadeWithIv> for RenderOp {
fn from(x: ShadeWithIv) -> Self {
Self::ShadeWithIv(x)
}
}
#[derive(Debug)]
pub struct DrawImage {
pub texture: Arc<Texture>,
pub pos: Vec2,
pub size: Vec2,
pub rotation: f32,
pub blend_mode: (),
pub color: Vec4,
}
impl From<DrawImage> for RenderOp {
fn from(x: DrawImage) -> Self {
Self::DrawImage(x)
}
}
#[derive(Debug)]
pub struct DrawBillboard {
pub texture: Arc<Texture>,
pub depth_test: bool,
pub depth_write: bool,
pub pos: Vec3,
pub size: Vec2,
pub rotation: f32,
pub blend_mode: (),
pub color: Vec4,
}
impl From<DrawBillboard> for RenderOp {
fn from(x: DrawBillboard) -> Self {
Self::DrawBillboard(x)
}
}
#[derive(Debug)]
pub struct VisualizeProbes {
pub chamber_index: ChamberIndex,
}
impl From<VisualizeProbes> for RenderOp {
fn from(x: VisualizeProbes) -> Self {
Self::VisualizeProbes(x)
}
}
#[derive(Debug)]
pub struct ShowInternalTexture {
pub name: String,
pub pos: Vec2,
pub size: Vec2,
}
impl From<ShowInternalTexture> for RenderOp {
fn from(x: ShowInternalTexture) -> Self {
Self::ShowInternalTexture(x)
}
}
pub enum RenderOp {
StartFrame(InternalOp),
Abort(InternalOp),
EndFrame(InternalOp),
SetCamera(SetCamera),
DrawLine(DrawLine),
DrawWireFrame(DrawWireFrame),
DrawGeneral(DrawGeneral),
DrawEmissiveStatic(DrawEmissiveStatic),
DrawEmissiveDynamic(DrawEmissiveDynamic),
AddMajorLight(AddMajorLight),
AddPointLight(AddPointLight),
AddAmbientLight(AddAmbientLight),
ShadeWithIv(ShadeWithIv),
DrawImage(DrawImage),
DrawBillboard(DrawBillboard),
VisualizeProbes(VisualizeProbes),
ShowInternalTexture(ShowInternalTexture),
Multiple(Vec<RenderOp>),
}
impl From<SetCamera> for RenderOp {
fn from(x: SetCamera) -> Self {
Self::SetCamera(x)
}
}