Expand description
General Information
NOT BEIGN USED AT THE MOMENT
A cone first serves as an object with ‘ray casting’-like functionality to be able to click elements from screen. It transforms viewport coordinates to object coordinates and projects a cone inside this viewport. Then, an intersectrion can ben done to obtain closest object and return it to the user to do something.
Fields
anchorage_point
- Point from where the cone starts. Normally coincides with near plane of cameradirection
- Direction the cone will take. Given mouse position, a line is determined inside viewport. Near and far coordinates are determined and the direction vector of the line generated (by near and far points) is usedangle
- How much should the cone be open
Fields§
§anchorage_point: Point3<f32>
§direction: Vector3<f32>
§angle: f32
Implementations§
source§impl Cone
impl Cone
sourcepub(crate) fn new(
anchorage_point: Point3<f32>,
direction: Vector3<f32>,
angle: f32
) -> Cone
pub(crate) fn new(
anchorage_point: Point3<f32>,
direction: Vector3<f32>,
angle: f32
) -> Cone
Function to create new instance. Normalizes direction vector.
sourcepub(crate) fn change_from_mouse_position(
&mut self,
mouse_coordinates: &Point2<f32>,
projection_matrix: &Matrix4<f32>,
window_width: u32,
window_height: u32
) -> Result<(), Error>
pub(crate) fn change_from_mouse_position(
&mut self,
mouse_coordinates: &Point2<f32>,
projection_matrix: &Matrix4<f32>,
window_width: u32,
window_height: u32
) -> Result<(), Error>
General Information
Change cone given mouse input. This function is normally used along cone and window. Steps reffered to in struct definition, are performed here.
Parameters
mouse_coordinates
- viewport coordinates to change anchorage point.projection_matrix
- camera projection matrix to find reverse transformation.window_width
- original window width needed to normalize viewport coordinateswindow_height
- original window height needed to normalize viewport coordinates
sourcefn get_translation_matrix(arr: &Array1<f32>) -> Matrix4<f32>
fn get_translation_matrix(arr: &Array1<f32>) -> Matrix4<f32>
Matrix to translate vertex to a given location (normally determined by a mesh instance).
sourcefn get_view_center(
arr: &ArrayView1<'_, f64>,
view_matrix: &Matrix4<f32>
) -> Vector3<f32>
fn get_view_center(
arr: &ArrayView1<'_, f64>,
view_matrix: &Matrix4<f32>
) -> Vector3<f32>
Obtain center coordinates as viewed from camera
sourcepub(crate) fn obtain_nearest_intersection(
&self,
vertices: &Array1<f64>,
view_matrix: &Matrix4<f32>
) -> Option<(f32, usize)>
pub(crate) fn obtain_nearest_intersection(
&self,
vertices: &Array1<f64>,
view_matrix: &Matrix4<f32>
) -> Option<(f32, usize)>
General Information
Determine closest intersection given some vertices (sextuples of points) and current cone status. Only one vertex is returned with id.
Parameters
&self
- To determine cone location.vertices
- Vertices check wether they’re inside or outside the coneview_matrix
- Camera view matrix needed to see where a vertex is (in view space).