pub struct Geom {}
Expand description
Geom contains functionality related to mesh-like entities, like reading from files, or fixing and processing mesh data. Contains mostly static functions so that in the future this class can be broken into it’s own crate for geometry processing.
Implementations§
Source§impl Geom
impl Geom
Sourcepub fn build_cube(center: Point3<f32>) -> EntityBuilder
pub fn build_cube(center: Point3<f32>) -> EntityBuilder
Creates a cube
Sourcepub fn build_plane(
center: Point3<f32>,
normal: Vector3<f32>,
size_x: f32,
size_y: f32,
transform_cpu_data: bool,
) -> EntityBuilder
pub fn build_plane( center: Point3<f32>, normal: Vector3<f32>, size_x: f32, size_y: f32, transform_cpu_data: bool, ) -> EntityBuilder
Creates a plane based on a center and normal. If transform_cpu_data
is
true, then the vertices of the plane are actually translated and rotated
on the CPU. Otherwise the transformation is done on the GPU using the
model matrix. This is useful when creating light planes for example when
we want the model matrix to be consistent with the orientation of the
light and therefore we set transform_cpu_data=false
pub fn build_floor() -> EntityBuilder
pub fn build_grid( center: Point3<f32>, normal: Vector3<f32>, nr_lines_x: u32, nr_lines_y: u32, size_x: f32, size_y: f32, transform_cpu_data: bool, ) -> EntityBuilder
pub fn build_from_file(path: &str) -> EntityBuilder
Sourcepub fn build_from_obj_buf(buf: &[u8]) -> EntityBuilder
pub fn build_from_obj_buf(buf: &[u8]) -> EntityBuilder
§Panics
Will panic if the path cannot be opened
pub fn save_obj( verts: &DMatrix<f32>, faces: Option<&DMatrix<u32>>, uv: Option<&DMatrix<f32>>, normals: Option<&DMatrix<f32>>, path: &str, )
pub fn save_ply( verts: &DMatrix<f32>, faces: Option<&DMatrix<u32>>, uvs: Option<&DMatrix<f32>>, normals: Option<&DMatrix<f32>>, colors: Option<&DMatrix<f32>>, path: &str, )
Sourcepub fn compute_per_vertex_normals(
verts: &DMatrix<f32>,
faces: &DMatrix<u32>,
weighting_type: &PerVertexNormalsWeightingType,
) -> DMatrix<f32>
pub fn compute_per_vertex_normals( verts: &DMatrix<f32>, faces: &DMatrix<u32>, weighting_type: &PerVertexNormalsWeightingType, ) -> DMatrix<f32>
Computes per vertex normals
Sourcepub fn compute_per_vertex_normals_burn<B: Backend>(
verts: &Tensor<B, 2, Float>,
faces: &Tensor<B, 2, Int>,
weighting_type: &PerVertexNormalsWeightingType,
) -> Tensor<B, 2, Float>
pub fn compute_per_vertex_normals_burn<B: Backend>( verts: &Tensor<B, 2, Float>, faces: &Tensor<B, 2, Int>, weighting_type: &PerVertexNormalsWeightingType, ) -> Tensor<B, 2, Float>
Computes per vertex normals for Burn Tensors
Sourcepub fn compute_per_face_normals(
verts: &DMatrix<f32>,
faces: &DMatrix<u32>,
) -> DMatrix<f32>
pub fn compute_per_face_normals( verts: &DMatrix<f32>, faces: &DMatrix<u32>, ) -> DMatrix<f32>
Computes per face normals
Sourcepub fn compute_double_face_areas(
verts: &DMatrix<f32>,
faces: &DMatrix<u32>,
) -> DMatrix<f32>
pub fn compute_double_face_areas( verts: &DMatrix<f32>, faces: &DMatrix<u32>, ) -> DMatrix<f32>
computes twice the area for each input triangle[quad]
Sourcepub fn compute_tangents(
verts: &DMatrix<f32>,
faces: &DMatrix<u32>,
normals: &DMatrix<f32>,
uvs: &DMatrix<f32>,
) -> DMatrix<f32>
pub fn compute_tangents( verts: &DMatrix<f32>, faces: &DMatrix<u32>, normals: &DMatrix<f32>, uvs: &DMatrix<f32>, ) -> DMatrix<f32>
Compute tangents given verts, faces, normals and uvs
Sourcepub fn compute_tangents_burn<B: Backend>(
verts: &Tensor<B, 2, Float>,
faces: &Tensor<B, 2, Int>,
normals: &Tensor<B, 2, Float>,
uvs: &Tensor<B, 2, Float>,
) -> Tensor<B, 2, Float>
pub fn compute_tangents_burn<B: Backend>( verts: &Tensor<B, 2, Float>, faces: &Tensor<B, 2, Int>, normals: &Tensor<B, 2, Float>, uvs: &Tensor<B, 2, Float>, ) -> Tensor<B, 2, Float>
Compute tangents given verts, faces, normals and uvs for Burn Tensors
pub fn transform_verts( verts: &DMatrix<f32>, model_matrix: &SimilarityMatrix3<f32>, ) -> DMatrix<f32>
pub fn transform_vectors( verts: &DMatrix<f32>, model_matrix: &SimilarityMatrix3<f32>, ) -> DMatrix<f32>
pub fn get_bounding_points( verts: &DMatrix<f32>, model_matrix: Option<SimilarityMatrix3<f32>>, ) -> (Point3<f32>, Point3<f32>)
pub fn get_centroid( verts: &DMatrix<f32>, model_matrix: Option<SimilarityMatrix3<f32>>, ) -> Point3<f32>
pub fn sample_img_with_uvs( img: &DynImage, uvs: &DMatrix<f32>, is_srgb: bool, ) -> DMatrix<f32>
Sourcepub fn filter_rows<T: Scalar>(
mat: &DMatrix<T>,
mask: &[bool],
keep: bool,
) -> (DMatrix<T>, Vec<i32>, Vec<i32>)
pub fn filter_rows<T: Scalar>( mat: &DMatrix<T>, mask: &[bool], keep: bool, ) -> (DMatrix<T>, Vec<i32>, Vec<i32>)
returns the rows of mat where mask==keep returns the filtered rows and also a matrix of orig2filtered and filtered2orig which maps from original row indices to filtered ones and viceversa (-1 denotes a invalid index)
Sourcepub fn filter_cols<T: Scalar>(
mat: &DMatrix<T>,
mask: &[bool],
keep: bool,
) -> (DMatrix<T>, Vec<i32>, Vec<i32>)
pub fn filter_cols<T: Scalar>( mat: &DMatrix<T>, mask: &[bool], keep: bool, ) -> (DMatrix<T>, Vec<i32>, Vec<i32>)
returns the cols of mat where mask==keep returns the filtered cols and also a matrix of orig2filtered and filtered2orig which maps from original row indices to filtered ones and viceversa (-1 denotes a invalid index)
Sourcepub fn splat_rows(
mat: &DMatrix<f32>,
indices_orig2splatted: &[u32],
splat_type: &SplatType,
) -> DMatrix<f32>
pub fn splat_rows( mat: &DMatrix<f32>, indices_orig2splatted: &[u32], splat_type: &SplatType, ) -> DMatrix<f32>
Gets rows of mat and splats them according to indices_orig2splatted
such that:
vec = mat[i];
idx_destination = indices_orig2splatted[i];
splatted.row(idx_destination) += vec
pub fn apply_indirection( mat: &DMatrix<u32>, indices_orig2destin: &[i32], removal_policy: &IndirRemovalPolicy, ) -> (DMatrix<u32>, Vec<bool>)
pub fn compute_dummy_uvs<B: Backend>( nr_verts: usize, device: &B::Device, ) -> Tensor<B, 2, Float>
pub fn compute_dummy_colors<B: Backend>( nr_verts: usize, device: &B::Device, ) -> Tensor<B, 2, Float>
pub fn compute_dummy_tangents<B: Backend>( nr_verts: usize, device: &B::Device, ) -> Tensor<B, 2, Float>
pub fn create_frustum_verts_and_edges( extrinsics: &Matrix4<f32>, fovy: f32, aspect_ratio: f32, near: f32, far: f32, ) -> (DMatrix<f32>, DMatrix<u32>)
Auto Trait Implementations§
impl Freeze for Geom
impl RefUnwindSafe for Geom
impl Send for Geom
impl Sync for Geom
impl Unpin for Geom
impl UnwindSafe for Geom
Blanket Implementations§
Source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.