Skip to main content

Material

Struct Material 

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

Complete material definition with textures, transforms, and shader parameters.

Materials contain all rendering data except geometry. The exact fields present depend on the material type - some types use only a subset of these fields.

§Field Organization

  • Identification: vertex_format, name
  • Unknown fields: uk_1 through uk_6 (only in certain material types)
  • Textures: texture_directory, textures list
  • Transforms: v_pivot, matrix1/2/3, matrix indices
  • Attachments: attachment_points for effects/weapons
  • Shader params: params_string, params_f32, params_i32, params_vector4df32
  • Cloth physics: uk_7, uk_8, uk_9 (cloth materials only)

§Matrix Storage

3x4 matrices are stored in the same format as skeleton bind pose matrices. The implicit fourth row [0, 0, 0, 1] must be added when converting to 4x4.

Implementations§

Source§

impl Material

Source

pub fn read_alpha_blend<R: ReadBytes>(data: &mut R) -> Result<Self>

Source

pub fn write_alpha_blend<W: WriteBytes>(&self, data: &mut W) -> Result<()>

Source§

impl Material

Source

pub fn read_cloth<R: ReadBytes>(data: &mut R) -> Result<Self>

Source

pub fn write_cloth<W: WriteBytes>(&self, buffer: &mut W) -> Result<()>

Source§

impl Material

Source

pub fn read_default<R: ReadBytes>(data: &mut R) -> Result<Self>

Source

pub fn write_default<W: WriteBytes>(&self, buffer: &mut W) -> Result<()>

Source§

impl Material

Source

pub fn read_rs_terrain<R: ReadBytes>(data: &mut R) -> Result<Self>

Source

pub fn write_rs_terrain<W: WriteBytes>(&self, data: &mut W) -> Result<()>

Source§

impl Material

Source

pub fn read_rs_river<R: ReadBytes>(_data: &mut R) -> Result<Self>

Source

pub fn write_rs_river<W: WriteBytes>(&self, _data: &mut W) -> Result<()>

Source§

impl Material

Source§

impl Material

Source§

impl Material

Source

pub fn vertex_format(&self) -> &VertexFormat

Vertex format determining vertex data layout.

Source

pub fn name(&self) -> &String

Material name (human-readable identifier).

Source

pub fn uk_1(&self) -> &u32

Unknown field 1 (only in RsTerrain and projected decal materials).

Source

pub fn uk_2(&self) -> &u32

Unknown field 2 (only in RsTerrain and projected decal materials).

Source

pub fn uk_3(&self) -> &u32

Unknown field 3 (only in RsTerrain and projected decal materials).

Source

pub fn uk_4(&self) -> &u32

Unknown field 4 (only in RsTerrain and projected decal materials).

Source

pub fn uk_5(&self) -> &u32

Unknown field 5 (only in RsTerrain and projected decal materials).

Source

pub fn uk_6(&self) -> &u32

Unknown field 6 (only in RsTerrain and projected decal materials).

Source

pub fn texture_directory(&self) -> &String

Directory path for texture files (relative to game data directory).

Source

pub fn filters(&self) -> &String

Filter settings (NOT part of file format, runtime-only).

Source

pub fn padding_byte0(&self) -> &u8

Padding byte 0 (alignment/reserved).

Source

pub fn padding_byte1(&self) -> &u8

Padding byte 1 (alignment/reserved).

Source

pub fn v_pivot(&self) -> &Vector3<f32>

Pivot point for transformations.

Source

pub fn matrix1(&self) -> &Matrix3x4<f32>

Transform matrix 1 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn matrix2(&self) -> &Matrix3x4<f32>

Transform matrix 2 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn matrix3(&self) -> &Matrix3x4<f32>

Transform matrix 3 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn i_matrix_index(&self) -> &i32

Matrix index in hierarchy.

Source

pub fn i_parent_matrix_index(&self) -> &i32

Parent matrix index for hierarchical transforms.

Source

pub fn sz_padding(&self) -> &Vec<u8>

Additional padding bytes (variable length).

Source

pub fn attachment_points(&self) -> &Vec<AttachmentPointEntry>

Named attachment points for weapons, effects, banners, etc.

Source

pub fn textures(&self) -> &Vec<Texture>

Texture list with type and path for each texture.

Source

pub fn params_string(&self) -> &Vec<(i32, String)>

String shader parameters (index, value pairs).

Source

pub fn params_f32(&self) -> &Vec<(i32, f32)>

Float shader parameters (index, value pairs).

Source

pub fn params_i32(&self) -> &Vec<(i32, i32)>

Integer shader parameters (index, value pairs).

Source

pub fn params_vector4df32(&self) -> &Vec<(i32, Vector4<f32>)>

Vector4 shader parameters (index, value pairs).

Source

pub fn uk_7(&self) -> &Vec<Uk7>

Cloth physics data section 1 (cloth materials only, format undocumented).

Source

pub fn uk_8(&self) -> &Vec<Uk8>

Cloth physics data section 2 (cloth materials only, format undocumented).

Source

pub fn uk_9(&self) -> &Vec<Uk9>

Cloth physics data section 3 (cloth materials only, format undocumented).

Source§

impl Material

Source

pub fn vertex_format_mut(&mut self) -> &mut VertexFormat

Vertex format determining vertex data layout.

Source

pub fn name_mut(&mut self) -> &mut String

Material name (human-readable identifier).

Source

pub fn uk_1_mut(&mut self) -> &mut u32

Unknown field 1 (only in RsTerrain and projected decal materials).

Source

pub fn uk_2_mut(&mut self) -> &mut u32

Unknown field 2 (only in RsTerrain and projected decal materials).

Source

pub fn uk_3_mut(&mut self) -> &mut u32

Unknown field 3 (only in RsTerrain and projected decal materials).

Source

pub fn uk_4_mut(&mut self) -> &mut u32

Unknown field 4 (only in RsTerrain and projected decal materials).

Source

pub fn uk_5_mut(&mut self) -> &mut u32

Unknown field 5 (only in RsTerrain and projected decal materials).

Source

pub fn uk_6_mut(&mut self) -> &mut u32

Unknown field 6 (only in RsTerrain and projected decal materials).

Source

pub fn texture_directory_mut(&mut self) -> &mut String

Directory path for texture files (relative to game data directory).

Source

pub fn filters_mut(&mut self) -> &mut String

Filter settings (NOT part of file format, runtime-only).

Source

pub fn padding_byte0_mut(&mut self) -> &mut u8

Padding byte 0 (alignment/reserved).

Source

pub fn padding_byte1_mut(&mut self) -> &mut u8

Padding byte 1 (alignment/reserved).

Source

pub fn v_pivot_mut(&mut self) -> &mut Vector3<f32>

Pivot point for transformations.

Source

pub fn matrix1_mut(&mut self) -> &mut Matrix3x4<f32>

Transform matrix 1 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn matrix2_mut(&mut self) -> &mut Matrix3x4<f32>

Transform matrix 2 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn matrix3_mut(&mut self) -> &mut Matrix3x4<f32>

Transform matrix 3 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn i_matrix_index_mut(&mut self) -> &mut i32

Matrix index in hierarchy.

Source

pub fn i_parent_matrix_index_mut(&mut self) -> &mut i32

Parent matrix index for hierarchical transforms.

Source

pub fn sz_padding_mut(&mut self) -> &mut Vec<u8>

Additional padding bytes (variable length).

Source

pub fn attachment_points_mut(&mut self) -> &mut Vec<AttachmentPointEntry>

Named attachment points for weapons, effects, banners, etc.

Source

pub fn textures_mut(&mut self) -> &mut Vec<Texture>

Texture list with type and path for each texture.

Source

pub fn params_string_mut(&mut self) -> &mut Vec<(i32, String)>

String shader parameters (index, value pairs).

Source

pub fn params_f32_mut(&mut self) -> &mut Vec<(i32, f32)>

Float shader parameters (index, value pairs).

Source

pub fn params_i32_mut(&mut self) -> &mut Vec<(i32, i32)>

Integer shader parameters (index, value pairs).

Source

pub fn params_vector4df32_mut(&mut self) -> &mut Vec<(i32, Vector4<f32>)>

Vector4 shader parameters (index, value pairs).

Source

pub fn uk_7_mut(&mut self) -> &mut Vec<Uk7>

Cloth physics data section 1 (cloth materials only, format undocumented).

Source

pub fn uk_8_mut(&mut self) -> &mut Vec<Uk8>

Cloth physics data section 2 (cloth materials only, format undocumented).

Source

pub fn uk_9_mut(&mut self) -> &mut Vec<Uk9>

Cloth physics data section 3 (cloth materials only, format undocumented).

Source§

impl Material

Source

pub fn set_vertex_format(&mut self, val: VertexFormat) -> &mut Self

Vertex format determining vertex data layout.

Source

pub fn set_name(&mut self, val: String) -> &mut Self

Material name (human-readable identifier).

Source

pub fn set_uk_1(&mut self, val: u32) -> &mut Self

Unknown field 1 (only in RsTerrain and projected decal materials).

Source

pub fn set_uk_2(&mut self, val: u32) -> &mut Self

Unknown field 2 (only in RsTerrain and projected decal materials).

Source

pub fn set_uk_3(&mut self, val: u32) -> &mut Self

Unknown field 3 (only in RsTerrain and projected decal materials).

Source

pub fn set_uk_4(&mut self, val: u32) -> &mut Self

Unknown field 4 (only in RsTerrain and projected decal materials).

Source

pub fn set_uk_5(&mut self, val: u32) -> &mut Self

Unknown field 5 (only in RsTerrain and projected decal materials).

Source

pub fn set_uk_6(&mut self, val: u32) -> &mut Self

Unknown field 6 (only in RsTerrain and projected decal materials).

Source

pub fn set_texture_directory(&mut self, val: String) -> &mut Self

Directory path for texture files (relative to game data directory).

Source

pub fn set_filters(&mut self, val: String) -> &mut Self

Filter settings (NOT part of file format, runtime-only).

Source

pub fn set_padding_byte0(&mut self, val: u8) -> &mut Self

Padding byte 0 (alignment/reserved).

Source

pub fn set_padding_byte1(&mut self, val: u8) -> &mut Self

Padding byte 1 (alignment/reserved).

Source

pub fn set_v_pivot(&mut self, val: Vector3<f32>) -> &mut Self

Pivot point for transformations.

Source

pub fn set_matrix1(&mut self, val: Matrix3x4<f32>) -> &mut Self

Transform matrix 1 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn set_matrix2(&mut self, val: Matrix3x4<f32>) -> &mut Self

Transform matrix 2 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn set_matrix3(&mut self, val: Matrix3x4<f32>) -> &mut Self

Transform matrix 3 (3x4, implicit 4th row: [0, 0, 0, 1]).

Source

pub fn set_i_matrix_index(&mut self, val: i32) -> &mut Self

Matrix index in hierarchy.

Source

pub fn set_i_parent_matrix_index(&mut self, val: i32) -> &mut Self

Parent matrix index for hierarchical transforms.

Source

pub fn set_sz_padding(&mut self, val: Vec<u8>) -> &mut Self

Additional padding bytes (variable length).

Source

pub fn set_attachment_points( &mut self, val: Vec<AttachmentPointEntry>, ) -> &mut Self

Named attachment points for weapons, effects, banners, etc.

Source

pub fn set_textures(&mut self, val: Vec<Texture>) -> &mut Self

Texture list with type and path for each texture.

Source

pub fn set_params_string(&mut self, val: Vec<(i32, String)>) -> &mut Self

String shader parameters (index, value pairs).

Source

pub fn set_params_f32(&mut self, val: Vec<(i32, f32)>) -> &mut Self

Float shader parameters (index, value pairs).

Source

pub fn set_params_i32(&mut self, val: Vec<(i32, i32)>) -> &mut Self

Integer shader parameters (index, value pairs).

Source

pub fn set_params_vector4df32( &mut self, val: Vec<(i32, Vector4<f32>)>, ) -> &mut Self

Vector4 shader parameters (index, value pairs).

Source

pub fn set_uk_7(&mut self, val: Vec<Uk7>) -> &mut Self

Cloth physics data section 1 (cloth materials only, format undocumented).

Source

pub fn set_uk_8(&mut self, val: Vec<Uk8>) -> &mut Self

Cloth physics data section 2 (cloth materials only, format undocumented).

Source

pub fn set_uk_9(&mut self, val: Vec<Uk9>) -> &mut Self

Cloth physics data section 3 (cloth materials only, format undocumented).

Source§

impl Material

Source

pub fn read<R: ReadBytes>(data: &mut R, mtype: MaterialType) -> Result<Self>

Reads a material from binary data based on the material type.

Different material types have different binary layouts. This function dispatches to the appropriate type-specific reader.

§Errors

Returns RLibError::DecodingRigidModelUnsupportedMaterialType if the material type is not supported.

Source

pub fn write<W: WriteBytes>( &self, buffer: &mut W, mtype: MaterialType, ) -> Result<()>

Writes a material to binary data based on the material type.

Different material types have different binary layouts. This function dispatches to the appropriate type-specific writer.

§Errors

Returns RLibError::DecodingRigidModelUnsupportedMaterialType if the material type is not supported.

Trait Implementations§

Source§

impl Clone for Material

Source§

fn clone(&self) -> Material

Returns a duplicate 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 Material

Source§

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

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

impl Default for Material

Source§

fn default() -> Material

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Material

Source§

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

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

impl PartialEq for Material

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Material

Source§

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

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

impl StructuralPartialEq for Material

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> 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,