Struct ark_api::world::WorldMesh

source ·
pub struct WorldMesh { /* private fields */ }
Expand description

Represents a reference to a mesh registered with the world.

Implementations§

source§

impl WorldMesh

source

pub fn create(mesh: Mesh) -> Self

Creates a WorldMesh from the passed-in raw mesh data.

source

pub fn create_with_material(mesh: Mesh, material: WorldMaterial) -> Self

Creates a WorldMesh from the passed-in raw mesh data.

source

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.

source

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

source

pub fn get_properties(&self) -> MeshProperties

Gets some properties of the mesh, such as its internal bounding box and sphere.

source

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.

source

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.

source

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.

source

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.

source

pub fn get_section_material_index(&self, section_idx: usize) -> usize

Get the material index assigned to a mesh section

source

pub fn set_debug_name(&self, name: &str)

Sets a debug name of this data object. Useful for debugging memory usage and leaks.

source

pub fn as_ffi(&self) -> DataHandle

Gets the DataHandle of this mesh.

source

pub fn from_ffi(handle: DataHandle) -> Self

Adopts a raw data handle and increases its ref count.

source

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.

source

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

source

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)

source

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).

source

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§

source§

impl Clone for WorldMesh

source§

fn clone(&self) -> WorldMesh

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WorldMesh

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for WorldMesh

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<WorldMesh> for WorldMesh

source§

fn eq(&self, other: &WorldMesh) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ValueConverterTrait<WorldMesh> for ValueConverter

source§

fn into_value(v: WorldMesh) -> Value

Wraps the passed-in value in a Value enum.
source§

fn from_value(v: &Value) -> WorldMesh

Extracts the value from a Value enum.
source§

impl Eq for WorldMesh

source§

impl StructuralEq for WorldMesh

source§

impl StructuralPartialEq for WorldMesh

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.