Skip to main content

RenderPrimitive

Struct RenderPrimitive 

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

A single drawable primitive and its canonical CPU-side vertex attributes.

All buffers are CPU-side, decoded to a canonical layout (f32 vectors) so a renderer can upload them to the GPU as-is. Unskinned primitives retain their owning node’s rest-pose world transform; skinned primitives use the identity transform because their joint palette produces world-space output.

Implementations§

Source§

impl RenderPrimitive

Source

pub fn builder( node_id: NodeId, positions: Vec<[f32; 3]>, indices: Vec<u32>, ) -> RenderPrimitiveBuilder

Starts a type-safe builder for programmatic primitive data.

Source

pub fn node_index(&self) -> u32

Returns the raw glTF node index that instantiates this primitive.

Source

pub fn node_id(&self) -> NodeId

Returns the stable node identifier that instantiates this primitive.

Source

pub fn world_transform(&self) -> &Transform

Returns the transform applied when rendering the primitive.

This is the owning node’s rest-pose world transform for an unskinned primitive and identity for a skinned primitive, whose joint palette already produces world-space output.

Source

pub fn positions(&self) -> &[[f32; 3]]

Returns base vertex positions in local space.

Source

pub fn normals(&self) -> &[[f32; 3]]

Returns base unit normals in local space.

Source

pub fn indices(&self) -> &[u32]

Returns element indices in the topology described by Self::topology.

Source

pub fn joints(&self) -> &[[u16; 4]]

Returns the first JOINTS_0 set, or an empty slice if unskinned.

Source

pub fn weights(&self) -> &[[f32; 4]]

Returns the first WEIGHTS_0 set, or an empty slice if unskinned.

Source

pub fn skinning_sets(&self) -> &[SkinningSet]

Returns every consecutive JOINTS_n / WEIGHTS_n pair.

Source

pub fn morph_targets(&self) -> &[MorphTarget]

Returns morph targets in glTF target order.

Source

pub fn texcoords(&self) -> &[[f32; 2]]

Returns TEXCOORD_0, or an empty slice when absent.

Source

pub fn texcoord_sets(&self) -> &[Vec<[f32; 2]>]

Returns all consecutive TEXCOORD_n buffers.

Source

pub fn texcoord_set(&self, set: u32) -> Option<&[[f32; 2]]>

Returns one texture coordinate set by its glTF set index.

Source

pub fn tangents(&self) -> &[[f32; 4]]

Returns tangent vectors, with handedness stored in the fourth component.

Source

pub fn colors(&self) -> &[[f32; 4]]

Returns linear RGBA vertex colors.

Source

pub fn secondary_texcoords(&self) -> &[[f32; 2]]

Returns TEXCOORD_1, or an empty slice when absent.

Source

pub fn texture_index(&self) -> Option<usize>

Returns the raw base-color glTF texture index, if present.

Source

pub fn texture_id(&self) -> Option<TextureId>

Returns the stable base-color texture identifier, if present.

Source

pub fn material_index(&self) -> Option<usize>

Returns the raw glTF material index, if present.

Source

pub fn material_id(&self) -> Option<MaterialId>

Returns the stable material identifier, if present.

Source

pub fn topology(&self) -> PrimitiveTopology

Returns the primitive assembly topology.

Source

pub fn morph_weights(&self) -> &[f32]

Returns the primitive’s current mutable morph weights.

Source

pub fn base_morph_weights(&self) -> &[f32]

The original morph weights as defined by the glTF node/mesh, never modified by Self::apply_morph_update. Expression evaluation reads these as the base state.

Source

pub fn set_morph_weights(&mut self, weights: &[f32])

Overrides the current morph weights. The slice is clamped to the number of morph targets (extra values ignored, missing ones become zero).

Source

pub fn apply_morph_update(&mut self, target_index: u32, weight: f32)

Sets the weight of one morph target, ignoring out-of-range indices.

Values are clamped to 0..=1; any previously accumulated weight for this target is replaced. Missing slots (vector shorter than the target list) are extended with zeros first.

Source

pub fn reset_morph_weights(&mut self)

Restores the morph weights to the original glTF base state, so a frame that only drives some targets does not leave stale weights on the others.

Source

pub fn morphed_vertices(&self) -> MorphedVertices

Returns the vertex attributes with the current morph weights applied: each attribute is base + Σ(weight · delta).

Normals are renormalized after applying their deltas; flat-normal primitives (no NORMAL attribute) recompute flat normals from the morphed positions. Tangents only move when morph targets carry tangent deltas, otherwise they stay at their base value.

Source

pub fn morphed_vertices_with_weights( &self, morph_weights: &[f32], ) -> MorphedVertices

Returns morphed vertices for explicit instance weights without changing the immutable asset data.

Source

pub fn skin_index(&self) -> Option<usize>

Returns the raw glTF skin index, if this primitive is skinned.

Source

pub fn skin_id(&self) -> Option<SkinId>

Returns the stable skin identifier, if this primitive is skinned.

Source

pub fn base_color_texcoord(&self) -> u32

Returns the resolved UV-set index used by the base-color texture.

Trait Implementations§

Source§

impl Clone for RenderPrimitive

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderPrimitive

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.