Skip to main content

ModelPart

Struct ModelPart 

#[non_exhaustive]
pub struct ModelPart { pub x: f32, pub y: f32, pub z: f32, pub x_rot: f32, pub y_rot: f32, pub z_rot: f32, pub x_scale: f32, pub y_scale: f32, pub z_scale: f32, pub visible: bool, pub skip_draw: bool, pub polygons: Vec<ModelPolygon>, /* private fields */ }
Expand description

ModelPart: a baked part, its children by name, and the pose a mod sets each frame before drawing it (setupAnim), from the pose it was baked with (reset_pose).

Wire uses JSON with at most 32 nested containers; named children consume object, list and tuple levels. Encoding preflights children before serialization.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§x: f32

Where it sits in its parent, in texels.

§y: f32

Position on the y axis, in texels.

§z: f32

Position on the z axis, in texels.

§x_rot: f32

Its rotation in radians, applied about z, then y, then x.

§y_rot: f32

Rotation around y, in radians.

§z_rot: f32

Rotation around z, in radians.

§x_scale: f32

Scale on the x axis.

§y_scale: f32

Scale on the y axis.

§z_scale: f32

Scale on the z axis.

§visible: bool

False draws neither it nor its children.

§skip_draw: bool

True draws its children but not its own faces (skipDraw).

§polygons: Vec<ModelPolygon>

Its boxes’ faces.

Implementations§

§

impl ModelPart

pub fn new( polygons: Vec<ModelPolygon>, children: Vec<(String, ModelPart)>, pose: PartPose, ) -> ModelPart

A part with polygons and children at pose, which it is reset to.

pub fn get_child(&self, name: &str) -> Option<&ModelPart>

Its part name (getChild).

pub fn get_child_mut(&mut self, name: &str) -> Option<&mut ModelPart>

Its mutable child by name.

pub fn children(&self) -> impl Iterator<Item = (&str, &ModelPart)>

Its parts by name, in the order they draw.

pub fn children_mut(&mut self) -> impl Iterator<Item = (&str, &mut ModelPart)>

Its mutable children in drawing order.

pub fn is_empty(&self) -> bool

Whether it has no faces of its own (isEmpty).

pub fn store_pose(&self) -> PartPose

Its pose now (storePose).

pub fn load_pose(&mut self, pose: PartPose)

Puts it at pose (loadPose).

pub fn initial_pose(&self) -> PartPose

The pose it was baked with, unless set since (getInitialPose).

pub fn set_initial_pose(&mut self, pose: PartPose)

Replace the pose used by reset_pose.

pub fn reset_pose(&mut self)

Puts it back at its initial pose (resetPose), its children as they are.

pub fn reset_all_poses(&mut self)

Puts it and every part under it back at their initial poses, as Model.resetPose does before each frame’s setupAnim.

pub fn copy_from(&mut self, other: &ModelPart)

Takes other’s position, rotation and scale (copyFrom).

pub fn set_pos(&mut self, x: f32, y: f32, z: f32)

Set its position in texels.

pub fn set_rotation(&mut self, x_rot: f32, y_rot: f32, z_rot: f32)

Set its rotation in radians.

pub fn offset_pos(&mut self, by: [f32; 3])

Moves it by by texels (offsetPos), as keyframe animations do.

pub fn offset_rotation(&mut self, by: [f32; 3])

Turns it by by radians (offsetRotation).

pub fn offset_scale(&mut self, by: [f32; 3])

Scales it by by more (offsetScale: added, as vanilla adds it).

Trait Implementations§

§

impl Clone for ModelPart

§

fn clone(&self) -> ModelPart

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
§

impl Debug for ModelPart

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for ModelPart

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ModelPart, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl PartialEq for ModelPart

§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
§

impl Serialize for ModelPart

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StructuralPartialEq for ModelPart

§

impl TryFrom<String> for ModelPart

§

type Error = Error

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

fn try_from( value: String, ) -> Result<ModelPart, <ModelPart as TryFrom<String>>::Error>

Performs the conversion.
§

impl Wire for ModelPart

§

const MIN: usize = String::MIN

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn take(input: &mut Reader<'_>) -> Result<ModelPart, WireError>

Decodes one value, leaving any following bytes for the caller.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.

§

impl<T> Put for T
where T: Wire,

§

fn put_to(&self, out: &mut Writer)

Writes it.
§

impl<T> Record for T
where T: Wire,

§

fn encode(&self, out: &mut Writer)

Writes the argument into a hook call.
§

fn apply(&mut self, bytes: &[u8]) -> Result<(), WireError>

Applies one complete reply, refusing malformed or trailing bytes atomically.
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 = 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.