First materials succesfully parsed
This commit is contained in:
parent
9a95ca8fd7
commit
c8ff77a0a9
5 changed files with 197 additions and 172 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::tokenizer::Tokenizer;
|
||||
use crate::{texture::Pbrt_2d_float_texture, tokenizer::Tokenizer};
|
||||
use error::SourceFile;
|
||||
use material::PbrtMaterial;
|
||||
use miette::{IntoDiagnostic, Result, bail, miette};
|
||||
use miette::{Diagnostic, IntoDiagnostic, Result, SourceSpan, bail, miette};
|
||||
use ray_tracing_core::{
|
||||
affine_transform::AffineTransform,
|
||||
math::{Dir3, Pos3},
|
||||
|
|
@ -12,6 +13,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
use texture::PbrtTexture;
|
||||
use thiserror::Error;
|
||||
|
||||
#[macro_use]
|
||||
mod tokenizer;
|
||||
|
|
@ -642,7 +644,7 @@ enum ShapeAlpha {
|
|||
#[derive(Debug)]
|
||||
struct Shape {
|
||||
ctm: AffineTransform,
|
||||
material: usize,
|
||||
material: Arc<dyn PbrtMaterial>,
|
||||
obj: ShapeType,
|
||||
alpha: ShapeAlpha,
|
||||
}
|
||||
|
|
@ -809,7 +811,12 @@ fn inner_parse_pbrt(path: impl AsRef<Path> + std::fmt::Debug) -> Result<Pbrt> {
|
|||
Statement::Shape(shape_type, shape_alpha) => {
|
||||
pbrt.scene.shapes.push(Shape {
|
||||
ctm: context.get_ctm(),
|
||||
material: 0,
|
||||
material: Arc::clone(
|
||||
context
|
||||
.material
|
||||
.last()
|
||||
.ok_or_else(|| miette!("No material specified"))?,
|
||||
),
|
||||
obj: shape_type,
|
||||
alpha: shape_alpha,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue