Function openexr::core::envmap::cube_map::face_and_position_in_face_from_direction [−][src]
pub fn face_and_position_in_face_from_direction<V3: Vec3<f32>, B: Bound2<i32>, V2: Vec2<f32>>(
direction: &V3,
data_window: &B
) -> (CubeMapFace, V2)
Expand description
Convert a 3D direction into a cube face, and a pixel position within that face.
If you have a 3D direction, dir
, the following code fragment
finds the position, pos
, of the corresponding pixel in an
environment map with data window dw
:
use openexr::prelude::*;
let dir = [0.0f32, 1.0, 0.0];
let dw = [0, 0, 255, 127];
let (face, position_in_face): (CubeMapFace, [f32; 2]) =
cube_map::face_and_position_in_face_from_direction(
&dir,
&dw
);
let pos = cube_map::pixel_position_from_position_in_face(
face,
&dw,
position_in_face
);