pbrt_r3/core/texture/
mapping3d.rs1use crate::core::base::*;
2use crate::core::interaction::*;
3use crate::core::transform::*;
4
5pub trait TextureMapping3D {
6 fn map(&self, si: &SurfaceInteraction) -> (Point3f, Vector3f, Vector3f);
7}
8
9pub struct IdentityMapping3D {
10 world_to_tex: Transform,
11}
12
13impl IdentityMapping3D {
14 pub fn new(world_to_tex: &Transform) -> Self {
15 IdentityMapping3D {
16 world_to_tex: *world_to_tex,
17 }
18 }
19}
20
21impl TextureMapping3D for IdentityMapping3D {
22 fn map(&self, si: &SurfaceInteraction) -> (Point3f, Vector3f, Vector3f) {
23 let p = self.world_to_tex.transform_point(&si.p);
24 let dpdx = self.world_to_tex.transform_vector(&si.dpdx);
25 let dpdy = self.world_to_tex.transform_vector(&si.dpdx);
26 return (p, dpdx, dpdy);
27 }
28}