Add Pbrt scale texture and initial material stuff
This commit is contained in:
parent
2476d2d49a
commit
0dfa2128dd
6 changed files with 176 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use crate::tokenizer::Tokenizer;
|
||||
use error::SourceFile;
|
||||
use material::PbrtMaterial;
|
||||
use miette::{Diagnostic, IntoDiagnostic, Result, SourceSpan, bail, miette};
|
||||
use ray_tracing_core::{
|
||||
affine_transform::AffineTransform,
|
||||
|
|
@ -16,10 +17,10 @@ use thiserror::Error;
|
|||
|
||||
#[macro_use]
|
||||
mod tokenizer;
|
||||
|
||||
mod error;
|
||||
|
||||
mod material;
|
||||
mod texture;
|
||||
|
||||
struct Lexer {
|
||||
input: Tokenizer,
|
||||
}
|
||||
|
|
@ -70,6 +71,9 @@ enum Statement {
|
|||
Unknown(String, Vec<String>),
|
||||
Transform(AffineTransform),
|
||||
Texture(String, Arc<dyn PbrtTexture>),
|
||||
Material(Arc<dyn PbrtMaterial>),
|
||||
MakeNamedMaterial(String, Arc<dyn PbrtMaterial>),
|
||||
NamedMaterial(String),
|
||||
}
|
||||
|
||||
fn parse_look_at(iter: &mut Tokenizer) -> Result<Statement> {
|
||||
|
|
@ -399,6 +403,14 @@ impl Lexer {
|
|||
texture::parse_texture(&mut self.input, textures)
|
||||
.map(|(name, texture)| Statement::Texture(name, texture)),
|
||||
),
|
||||
"Material" => Some(
|
||||
material::parse_material(&mut self.input, textures).map(Statement::Material),
|
||||
),
|
||||
"MakeNamedMaterial" => Some(
|
||||
material::parse_make_named_material(&mut self.input, textures)
|
||||
.map(|(name, material)| Statement::MakeNamedMaterial(name, material)),
|
||||
),
|
||||
"NamedMaterial" => Some(self.input.parse_parameter().map(Statement::NamedMaterial)),
|
||||
"ConcatTransform" => {
|
||||
Some(parse_transform(&mut self.input).map(Statement::ConcatTransform))
|
||||
}
|
||||
|
|
@ -410,7 +422,6 @@ impl Lexer {
|
|||
Ok(s) => Ok(Statement::CoordSysTransform(s)),
|
||||
Err(e) => Err(e),
|
||||
}),
|
||||
|
||||
"WorldBegin" => Some(Ok(Statement::WorldBegin)),
|
||||
_ => {
|
||||
if s.chars().any(|c| !c.is_ascii_alphabetic()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue