pub struct WorldMesh { /* private fields */ }
Expand description
Represents a reference to a mesh registered with the world.
Implementations
sourceimpl WorldMesh
impl WorldMesh
sourcepub fn create_with_material(mesh: Mesh, material: WorldMaterial) -> Self
pub fn create_with_material(mesh: Mesh, material: WorldMaterial) -> Self
Creates a WorldMesh
from the passed-in raw mesh data.
sourcepub fn create_from_gltf(
debug_name: &str,
gltf_data: &[u8],
buffer_data: &[u8],
flags: GltfFlags
) -> Self
pub fn create_from_gltf(
debug_name: &str,
gltf_data: &[u8],
buffer_data: &[u8],
flags: GltfFlags
) -> Self
Creates a WorldMesh
from GLTF data and additional buffer data.
Supports .gltf and .glb, and a single additional buffer file.
sourcepub fn create_from_gltf_resource(
debug_name: &str,
gltf_resource: ResourceHandleRepr,
buffer_resource: Option<ResourceHandleRepr>,
flags: GltfFlags
) -> Self
pub fn create_from_gltf_resource(
debug_name: &str,
gltf_resource: ResourceHandleRepr,
buffer_resource: Option<ResourceHandleRepr>,
flags: GltfFlags
) -> Self
Creates a WorldMesh
from a GLTF resource handle and additional buffer resource handle
sourcepub fn get_properties(&self) -> MeshProperties
pub fn get_properties(&self) -> MeshProperties
Gets some properties of the mesh, such as its internal bounding box and sphere.
sourcepub fn get_morph_target_names(&self) -> Vec<String>
pub fn get_morph_target_names(&self) -> Vec<String>
Gets the names of all morph target associated with the mesh.
It is recommended to store the return value instead of calling it every frame.
sourcepub fn get_material_descs(&self) -> Vec<MaterialDesc>
pub fn get_material_descs(&self) -> Vec<MaterialDesc>
Obtain all materials associated with the mesh.
It is recommended to store the return value instead of calling it every frame.
sourcepub fn get_material_descs_with_names(
&self
) -> Vec<(Option<String>, MaterialDesc)>
pub fn get_material_descs_with_names(
&self
) -> Vec<(Option<String>, MaterialDesc)>
Obtain all materials and their name associated with the mesh.
It is recommended to store the return value instead of calling it every frame.
sourcepub fn get_dominant_colors_with_area(&self) -> Vec<(ColorRgba8, f32)>
pub fn get_dominant_colors_with_area(&self) -> Vec<(ColorRgba8, f32)>
Get the dominant vertex colors of each mesh section and the area they occupy in vertex space
A mesh section is a part of the mesh that has its own material index.
sourcepub fn get_section_material_index(&self, section_idx: usize) -> usize
pub fn get_section_material_index(&self, section_idx: usize) -> usize
Get the material index assigned to a mesh section
sourcepub fn set_debug_name(&self, name: &str)
pub fn set_debug_name(&self, name: &str)
Sets a debug name of this data object. Useful for debugging memory usage and leaks.
sourcepub fn as_ffi(&self) -> DataHandle
pub fn as_ffi(&self) -> DataHandle
Gets the DataHandle
of this mesh.
sourcepub fn from_ffi(handle: DataHandle) -> Self
pub fn from_ffi(handle: DataHandle) -> Self
Adopts a raw data handle and increases its ref count.
sourcepub fn try_from_ffi(handle: DataHandle) -> Option<Self>
pub fn try_from_ffi(handle: DataHandle) -> Option<Self>
Adopts a raw data handle and increases its ref count if it is a valid data object.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true
if this is a valid mesh. This should always be the case unless
something has gone very wrong, such as the case where a user created this object from
sourcepub fn simplify(
&self,
threshold: f32,
target_error: f32,
min_triangle_count: u32,
max_triangle_count: u32,
flags: MeshSimplifiedFlags
) -> Self
pub fn simplify(
&self,
threshold: f32,
target_error: f32,
min_triangle_count: u32,
max_triangle_count: u32,
flags: MeshSimplifiedFlags
) -> Self
Returns this mesh as a simplified WorldMesh
using target_error
and threshold
parameters.
threshold
meaning what percentage (0-1) of the original primitives it should keep.
target_error
is an approximate measure of the deviation from the original
mesh using distance normalized to 0..1 (so 1e-2f means that simplifier will
try to maintain the error to be below 1% of the mesh extents). Note that because of
topological restrictions and error bounds simplifier isn’t guaranteed to reach the
target index count and can stop earlier.
min_triangle_count
and max_triangle_count
can be used instead
of threshold or in conjunction to define a minimum limit and maximum budget.
If this range is outside of the number of triangles for the mesh no simplification
will be done (target triangle count will be equal to the amount of triangles in the mesh)
sourcepub fn simplify_to_num_triangles(
&self,
target_triangle_count: u32,
max_error: f32,
flags: MeshSimplifiedFlags
) -> Self
pub fn simplify_to_num_triangles(
&self,
target_triangle_count: u32,
max_error: f32,
flags: MeshSimplifiedFlags
) -> Self
Returns a new mesh simplified to target_triangle_count
, as long as it can keep
the error below max_error
. max_error
is an approximate measure of the deviation
from the original mesh using distance normalized to 0..1 (so 1e-2f means that simplifier will
try to maintain the error to be below 1% of the mesh extents).
sourcepub fn simplify_to_error(
&self,
target_error: f32,
flags: MeshSimplifiedFlags
) -> Self
pub fn simplify_to_error(
&self,
target_error: f32,
flags: MeshSimplifiedFlags
) -> Self
Returns a new mesh simplified as much as it can while not exceeding target_error
.
target_error
is an approximate measure of the deviation from the original mesh using
distance normalized to 0..1 (so 1e-2f means that simplifier will try to maintain the
error to be below 1% of the mesh extents).
Trait Implementations
sourceimpl PartialEq<WorldMesh> for WorldMesh
impl PartialEq<WorldMesh> for WorldMesh
sourceimpl ValueConverterTrait<WorldMesh> for ValueConverter
impl ValueConverterTrait<WorldMesh> for ValueConverter
sourcefn into_value(v: WorldMesh) -> Value
fn into_value(v: WorldMesh) -> Value
Wraps the passed-in value in a Value
enum.
sourcefn from_value(v: &Value) -> WorldMesh
fn from_value(v: &Value) -> WorldMesh
Extracts the value from a Value
enum.
impl Eq for WorldMesh
impl StructuralEq for WorldMesh
impl StructuralPartialEq for WorldMesh
Auto Trait Implementations
impl RefUnwindSafe for WorldMesh
impl Send for WorldMesh
impl Sync for WorldMesh
impl Unpin for WorldMesh
impl UnwindSafe for WorldMesh
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more