Skip to main content

SurfaceMesh

Struct SurfaceMesh 

Source
pub struct SurfaceMesh { /* private fields */ }
Expand description

A surface mesh structure (triangular or polygonal).

Implementations§

Source§

impl SurfaceMesh

Source

pub fn compute_face_tangent_basis(&self) -> (Vec<Vec3>, Vec<Vec3>)

Compute default per-face tangent basis from first edge direction.

Source

pub fn compute_vertex_tangent_basis(&self) -> (Vec<Vec3>, Vec<Vec3>)

Compute default per-vertex tangent basis from area-weighted face bases.

Source§

impl SurfaceMesh

Source

pub fn add_vertex_scalar_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, ) -> &mut Self

Adds a vertex scalar quantity to this mesh.

Source

pub fn add_face_scalar_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, ) -> &mut Self

Adds a face scalar quantity to this mesh.

Source

pub fn add_vertex_color_quantity( &mut self, name: impl Into<String>, colors: Vec<Vec3>, ) -> &mut Self

Adds a vertex color quantity to this mesh (RGB, alpha defaults to 1.0).

Source

pub fn add_vertex_color_quantity_with_alpha( &mut self, name: impl Into<String>, colors: Vec<Vec4>, ) -> &mut Self

Adds a vertex color quantity with explicit per-vertex RGBA alpha values.

Source

pub fn add_face_color_quantity( &mut self, name: impl Into<String>, colors: Vec<Vec3>, ) -> &mut Self

Adds a face color quantity to this mesh (RGB, alpha defaults to 1.0).

Source

pub fn add_face_color_quantity_with_alpha( &mut self, name: impl Into<String>, colors: Vec<Vec4>, ) -> &mut Self

Adds a face color quantity with explicit per-face RGBA alpha values.

Source

pub fn add_vertex_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec3>, ) -> &mut Self

Adds a vertex vector quantity to this mesh.

Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.

Source

pub fn add_face_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec3>, ) -> &mut Self

Adds a face vector quantity to this mesh.

Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.

Source

pub fn add_vertex_parameterization_quantity( &mut self, name: impl Into<String>, coords: Vec<Vec2>, ) -> &mut Self

Adds a vertex parameterization (UV) quantity to this mesh.

Source

pub fn add_corner_parameterization_quantity( &mut self, name: impl Into<String>, coords: Vec<Vec2>, ) -> &mut Self

Adds a corner parameterization (UV) quantity to this mesh.

Source

pub fn add_vertex_intrinsic_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, basis_x: Vec<Vec3>, basis_y: Vec<Vec3>, ) -> &mut Self

Adds a vertex intrinsic vector quantity with explicit tangent basis.

Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.

Source

pub fn add_vertex_intrinsic_vector_quantity_auto( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, ) -> &mut Self

Adds a vertex intrinsic vector quantity with auto-computed tangent basis.

Source

pub fn add_face_intrinsic_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, basis_x: Vec<Vec3>, basis_y: Vec<Vec3>, ) -> &mut Self

Adds a face intrinsic vector quantity with explicit tangent basis.

Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.

Source

pub fn add_face_intrinsic_vector_quantity_auto( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, ) -> &mut Self

Adds a face intrinsic vector quantity with auto-computed tangent basis.

Source

pub fn add_one_form_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, orientations: Vec<bool>, ) -> &mut Self

Adds a one-form quantity to this mesh.

A one-form assigns a scalar value to each edge, rendered as arrows at edge midpoints. The orientations array specifies the sign convention for each edge (true = canonical low→high vertex direction). Arrow length and radius are auto-scaled based on mesh extent and edge flow magnitudes.

Source

pub fn active_vertex_scalar_quantity(&self) -> Option<&MeshVertexScalarQuantity>

Returns the currently active vertex scalar quantity, if any.

Source

pub fn active_face_scalar_quantity(&self) -> Option<&MeshFaceScalarQuantity>

Returns the currently active face scalar quantity, if any.

Source

pub fn active_vertex_color_quantity(&self) -> Option<&MeshVertexColorQuantity>

Returns the currently active vertex color quantity, if any.

Source

pub fn active_face_color_quantity(&self) -> Option<&MeshFaceColorQuantity>

Returns the currently active face color quantity, if any.

Source

pub fn active_vertex_vector_quantity(&self) -> Option<&MeshVertexVectorQuantity>

Returns the currently active vertex vector quantity (immutable), if any.

Source

pub fn active_vertex_vector_quantity_mut( &mut self, ) -> Option<&mut MeshVertexVectorQuantity>

Returns the currently active vertex vector quantity (mutable), if any.

Source

pub fn active_face_vector_quantity(&self) -> Option<&MeshFaceVectorQuantity>

Returns the currently active face vector quantity (immutable), if any.

Source

pub fn active_face_vector_quantity_mut( &mut self, ) -> Option<&mut MeshFaceVectorQuantity>

Returns the currently active face vector quantity (mutable), if any.

Source

pub fn face_centroids(&self) -> Vec<Vec3>

Computes face centroids (average of face vertices).

Source

pub fn active_vertex_parameterization_quantity( &self, ) -> Option<&MeshVertexParameterizationQuantity>

Returns the currently active vertex parameterization quantity, if any.

Source

pub fn active_corner_parameterization_quantity( &self, ) -> Option<&MeshCornerParameterizationQuantity>

Returns the currently active corner parameterization quantity, if any.

Source

pub fn active_vertex_intrinsic_vector_quantity( &self, ) -> Option<&MeshVertexIntrinsicVectorQuantity>

Returns the currently active vertex intrinsic vector quantity (immutable), if any.

Source

pub fn active_vertex_intrinsic_vector_quantity_mut( &mut self, ) -> Option<&mut MeshVertexIntrinsicVectorQuantity>

Returns the currently active vertex intrinsic vector quantity (mutable), if any.

Source

pub fn active_face_intrinsic_vector_quantity( &self, ) -> Option<&MeshFaceIntrinsicVectorQuantity>

Returns the currently active face intrinsic vector quantity (immutable), if any.

Source

pub fn active_face_intrinsic_vector_quantity_mut( &mut self, ) -> Option<&mut MeshFaceIntrinsicVectorQuantity>

Returns the currently active face intrinsic vector quantity (mutable), if any.

Source

pub fn active_one_form_quantity(&self) -> Option<&MeshOneFormQuantity>

Returns the currently active one-form quantity (immutable), if any.

Source

pub fn active_one_form_quantity_mut( &mut self, ) -> Option<&mut MeshOneFormQuantity>

Returns the currently active one-form quantity (mutable), if any.

Source§

impl SurfaceMesh

Source

pub fn new( name: impl Into<String>, vertices: Vec<Vec3>, faces: Vec<Vec<u32>>, ) -> Self

Creates a new surface mesh from vertices and polygon faces.

Each face is a variable-length list of vertex indices forming a polygon. Triangles have 3 indices, quads have 4, etc.

Source

pub fn from_triangles( name: impl Into<String>, vertices: Vec<Vec3>, triangles: Vec<[u32; 3]>, ) -> Self

Creates a new surface mesh from triangles (convenience method).

This is a convenience method for creating a mesh from triangle data.

Source

pub fn num_vertices(&self) -> usize

Returns the number of vertices.

Source

pub fn num_faces(&self) -> usize

Returns the number of faces.

Source

pub fn num_triangles(&self) -> usize

Returns the number of triangles in the triangulation.

Source

pub fn num_edges(&self) -> usize

Returns the number of edges.

Source

pub fn vertices(&self) -> &[Vec3]

Returns the vertices.

Source

pub fn faces(&self) -> &[Vec<u32>]

Returns the faces (polygon indices).

Source

pub fn triangulation(&self) -> &[[u32; 3]]

Returns the triangulation.

Source

pub fn face_to_tri_range(&self) -> &[Range<usize>]

Returns the mapping from face index to triangle range.

Source

pub fn vertex_normals(&self) -> &[Vec3]

Returns the vertex normals.

Source

pub fn face_normals(&self) -> &[Vec3]

Returns the face normals.

Source

pub fn corner_normals(&self) -> &[Vec3]

Returns the corner normals (per triangle vertex).

Source

pub fn edge_is_real(&self) -> &[Vec3]

Returns the edge_is_real flags for each triangle corner. For each triangle vertex, this is a Vec3 where:

  • x = 1.0 if edge from this vertex to next is real, 0.0 if internal
  • y = 1.0 if edge from next to prev is real (always real for middle edge)
  • z = 1.0 if edge from prev to this is real, 0.0 if internal
Source

pub fn edges(&self) -> &[(u32, u32)]

Returns the unique edges as sorted pairs.

Source

pub fn update_vertices(&mut self, vertices: Vec<Vec3>)

Updates the vertex positions.

Source

pub fn update_faces(&mut self, faces: Vec<Vec<u32>>)

Updates the faces.

Source

pub fn shade_style(&self) -> ShadeStyle

Gets the shade style.

Source

pub fn set_shade_style(&mut self, style: ShadeStyle)

Sets the shade style.

Source

pub fn edge_width(&self) -> f32

Gets the edge width.

Source

pub fn set_edge_width(&mut self, width: f32)

Sets the edge width.

Source

pub fn edge_color(&self) -> Vec4

Gets the edge color.

Source

pub fn set_edge_color(&mut self, color: Vec3)

Sets the edge color.

Source

pub fn show_edges(&self) -> bool

Gets whether edges are shown.

Source

pub fn set_show_edges(&mut self, show: bool)

Sets whether edges are shown.

Source

pub fn backface_policy(&self) -> BackfacePolicy

Gets the backface policy.

Source

pub fn set_backface_policy(&mut self, policy: BackfacePolicy)

Sets the backface policy.

Source

pub fn backface_color(&self) -> Vec4

Gets the backface color.

Source

pub fn set_backface_color(&mut self, color: Vec3)

Sets the backface color.

Source

pub fn surface_color(&self) -> Vec4

Gets the surface color.

Source

pub fn set_surface_color(&mut self, color: Vec3)

Sets the surface color.

Source

pub fn transparency(&self) -> f32

Gets the transparency (0.0 = opaque, 1.0 = fully transparent).

Source

pub fn set_transparency(&mut self, transparency: f32)

Sets the transparency.

Source

pub fn build_egui_ui(&mut self, ui: &mut Ui, available_materials: &[&str])

Builds the egui UI for this surface mesh.

Source

pub fn init_gpu_resources( &mut self, device: &Device, bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, )

Initializes GPU resources for rendering.

Source

pub fn render_data(&self) -> Option<&SurfaceMeshRenderData>

Returns the render data if initialized.

Source

pub fn init_shadow_resources( &mut self, device: &Device, shadow_bind_group_layout: &BindGroupLayout, light_buffer: &Buffer, )

Initializes shadow rendering resources.

Creates the bind group needed to render this mesh in the shadow pass.

Source

pub fn shadow_bind_group(&self) -> Option<&BindGroup>

Returns the shadow bind group if initialized.

Source

pub fn has_shadow_resources(&self) -> bool

Returns whether shadow resources are initialized.

Source

pub fn init_pick_resources( &mut self, device: &Device, mesh_pick_bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, global_start: u32, )

Initializes GPU resources for pick rendering.

Creates the pick uniform buffer, face index mapping buffer, and bind group. The face index buffer maps each GPU triangle to its original polygon face index.

Source

pub fn pick_bind_group(&self) -> Option<&BindGroup>

Returns the pick bind group if initialized.

Source

pub fn update_pick_uniforms(&self, queue: &Queue)

Updates pick uniforms (model transform) when the structure is moved.

Source

pub fn num_triangulation_vertices(&self) -> u32

Returns the total number of vertices in the triangulation (for draw calls).

Source

pub fn update_gpu_buffers(&self, queue: &Queue, color_maps: &ColorMapRegistry)

Updates GPU buffers with current mesh settings.

Trait Implementations§

Source§

impl HasQuantities for SurfaceMesh

Source§

fn add_quantity(&mut self, quantity: Box<dyn Quantity>)

Adds a quantity to this structure.
Source§

fn get_quantity(&self, name: &str) -> Option<&dyn Quantity>

Gets a quantity by name.
Source§

fn get_quantity_mut(&mut self, name: &str) -> Option<&mut Box<dyn Quantity>>

Gets a mutable quantity by name.
Source§

fn remove_quantity(&mut self, name: &str) -> Option<Box<dyn Quantity>>

Removes a quantity by name.
Source§

fn quantities(&self) -> &[Box<dyn Quantity>]

Returns all quantities attached to this structure.
Source§

fn num_quantities(&self) -> usize

Returns the number of quantities attached.
Source§

impl Structure for SurfaceMesh

Source§

fn as_any(&self) -> &dyn Any

Returns a reference to self as Any for downcasting.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to self as Any for downcasting.
Source§

fn name(&self) -> &str

Returns the unique name of this structure.
Source§

fn type_name(&self) -> &'static str

Returns the type name of this structure (e.g., “PointCloud”, “SurfaceMesh”).
Source§

fn bounding_box(&self) -> Option<(Vec3, Vec3)>

Returns the axis-aligned bounding box in world coordinates. Read more
Source§

fn length_scale(&self) -> f32

Returns a characteristic length scale for this structure.
Source§

fn transform(&self) -> Mat4

Returns the current model transform matrix.
Source§

fn set_transform(&mut self, transform: Mat4)

Sets the model transform matrix.
Source§

fn is_enabled(&self) -> bool

Returns whether this structure is currently visible.
Source§

fn set_enabled(&mut self, enabled: bool)

Sets the visibility of this structure.
Source§

fn material(&self) -> &str

Returns the material name for this structure (e.g., “clay”, “wax”).
Source§

fn set_material(&mut self, material: &str)

Sets the material for this structure by name.
Source§

fn draw(&self, _ctx: &mut dyn RenderContext)

Draws this structure to the scene. Read more
Source§

fn draw_pick(&self, _ctx: &mut dyn RenderContext)

Draws this structure for picking/selection. Read more
Source§

fn build_ui(&mut self, _ui: &dyn Any)

Builds the ImGui UI for this structure.
Source§

fn build_pick_ui(&self, _ui: &dyn Any, _pick: &PickResult)

Builds the ImGui UI for a picked element.
Source§

fn clear_gpu_resources(&mut self)

Clears all GPU resources (render data, pick buffers, etc.). Read more
Source§

fn refresh(&mut self)

Refreshes GPU resources after data changes.
Source§

fn center_bounding_box(&mut self)

Centers the camera on this structure’s bounding box.
Source§

fn reset_transform(&mut self)

Resets the transform to identity.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,