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_1throughuk_6(only in certain material types) - Textures:
texture_directory,textureslist - Transforms:
v_pivot,matrix1/2/3, matrix indices - Attachments:
attachment_pointsfor 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
impl Material
pub fn read_alpha_blend<R: ReadBytes>(data: &mut R) -> Result<Self>
pub fn write_alpha_blend<W: WriteBytes>(&self, data: &mut W) -> Result<()>
Source§impl Material
impl Material
pub fn read_cloth<R: ReadBytes>(data: &mut R) -> Result<Self>
pub fn write_cloth<W: WriteBytes>(&self, buffer: &mut W) -> Result<()>
Source§impl Material
impl Material
pub fn read_default<R: ReadBytes>(data: &mut R) -> Result<Self>
pub fn write_default<W: WriteBytes>(&self, buffer: &mut W) -> Result<()>
Source§impl Material
impl Material
pub fn read_rs_terrain<R: ReadBytes>(data: &mut R) -> Result<Self>
pub fn write_rs_terrain<W: WriteBytes>(&self, data: &mut W) -> Result<()>
Source§impl Material
impl Material
pub fn read_rs_river<R: ReadBytes>(_data: &mut R) -> Result<Self>
pub fn write_rs_river<W: WriteBytes>(&self, _data: &mut W) -> Result<()>
Source§impl Material
impl Material
pub fn read_projected_decal_v4<R: ReadBytes>(data: &mut R) -> Result<Self>
pub fn write_projected_decal_v4<W: WriteBytes>( &self, data: &mut W, ) -> Result<()>
Source§impl Material
impl Material
pub fn read_weighted_texture_blend<R: ReadBytes>(data: &mut R) -> Result<Self>
pub fn write_weighted_texture_blend<W: WriteBytes>( &self, data: &mut W, ) -> Result<()>
Source§impl Material
impl Material
Sourcepub fn vertex_format(&self) -> &VertexFormat
pub fn vertex_format(&self) -> &VertexFormat
Vertex format determining vertex data layout.
Sourcepub fn texture_directory(&self) -> &String
pub fn texture_directory(&self) -> &String
Directory path for texture files (relative to game data directory).
Sourcepub fn padding_byte0(&self) -> &u8
pub fn padding_byte0(&self) -> &u8
Padding byte 0 (alignment/reserved).
Sourcepub fn padding_byte1(&self) -> &u8
pub fn padding_byte1(&self) -> &u8
Padding byte 1 (alignment/reserved).
Sourcepub fn matrix1(&self) -> &Matrix3x4<f32>
pub fn matrix1(&self) -> &Matrix3x4<f32>
Transform matrix 1 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn matrix2(&self) -> &Matrix3x4<f32>
pub fn matrix2(&self) -> &Matrix3x4<f32>
Transform matrix 2 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn matrix3(&self) -> &Matrix3x4<f32>
pub fn matrix3(&self) -> &Matrix3x4<f32>
Transform matrix 3 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn i_matrix_index(&self) -> &i32
pub fn i_matrix_index(&self) -> &i32
Matrix index in hierarchy.
Sourcepub fn i_parent_matrix_index(&self) -> &i32
pub fn i_parent_matrix_index(&self) -> &i32
Parent matrix index for hierarchical transforms.
Sourcepub fn sz_padding(&self) -> &Vec<u8> ⓘ
pub fn sz_padding(&self) -> &Vec<u8> ⓘ
Additional padding bytes (variable length).
Sourcepub fn attachment_points(&self) -> &Vec<AttachmentPointEntry>
pub fn attachment_points(&self) -> &Vec<AttachmentPointEntry>
Named attachment points for weapons, effects, banners, etc.
Sourcepub fn params_string(&self) -> &Vec<(i32, String)>
pub fn params_string(&self) -> &Vec<(i32, String)>
String shader parameters (index, value pairs).
Sourcepub fn params_f32(&self) -> &Vec<(i32, f32)>
pub fn params_f32(&self) -> &Vec<(i32, f32)>
Float shader parameters (index, value pairs).
Sourcepub fn params_i32(&self) -> &Vec<(i32, i32)>
pub fn params_i32(&self) -> &Vec<(i32, i32)>
Integer shader parameters (index, value pairs).
Sourcepub fn params_vector4df32(&self) -> &Vec<(i32, Vector4<f32>)>
pub fn params_vector4df32(&self) -> &Vec<(i32, Vector4<f32>)>
Vector4 shader parameters (index, value pairs).
Sourcepub fn uk_7(&self) -> &Vec<Uk7>
pub fn uk_7(&self) -> &Vec<Uk7>
Cloth physics data section 1 (cloth materials only, format undocumented).
Source§impl Material
impl Material
Sourcepub fn vertex_format_mut(&mut self) -> &mut VertexFormat
pub fn vertex_format_mut(&mut self) -> &mut VertexFormat
Vertex format determining vertex data layout.
Sourcepub fn uk_1_mut(&mut self) -> &mut u32
pub fn uk_1_mut(&mut self) -> &mut u32
Unknown field 1 (only in RsTerrain and projected decal materials).
Sourcepub fn uk_2_mut(&mut self) -> &mut u32
pub fn uk_2_mut(&mut self) -> &mut u32
Unknown field 2 (only in RsTerrain and projected decal materials).
Sourcepub fn uk_3_mut(&mut self) -> &mut u32
pub fn uk_3_mut(&mut self) -> &mut u32
Unknown field 3 (only in RsTerrain and projected decal materials).
Sourcepub fn uk_4_mut(&mut self) -> &mut u32
pub fn uk_4_mut(&mut self) -> &mut u32
Unknown field 4 (only in RsTerrain and projected decal materials).
Sourcepub fn uk_5_mut(&mut self) -> &mut u32
pub fn uk_5_mut(&mut self) -> &mut u32
Unknown field 5 (only in RsTerrain and projected decal materials).
Sourcepub fn uk_6_mut(&mut self) -> &mut u32
pub fn uk_6_mut(&mut self) -> &mut u32
Unknown field 6 (only in RsTerrain and projected decal materials).
Sourcepub fn texture_directory_mut(&mut self) -> &mut String
pub fn texture_directory_mut(&mut self) -> &mut String
Directory path for texture files (relative to game data directory).
Sourcepub fn filters_mut(&mut self) -> &mut String
pub fn filters_mut(&mut self) -> &mut String
Filter settings (NOT part of file format, runtime-only).
Sourcepub fn padding_byte0_mut(&mut self) -> &mut u8
pub fn padding_byte0_mut(&mut self) -> &mut u8
Padding byte 0 (alignment/reserved).
Sourcepub fn padding_byte1_mut(&mut self) -> &mut u8
pub fn padding_byte1_mut(&mut self) -> &mut u8
Padding byte 1 (alignment/reserved).
Sourcepub fn v_pivot_mut(&mut self) -> &mut Vector3<f32>
pub fn v_pivot_mut(&mut self) -> &mut Vector3<f32>
Pivot point for transformations.
Sourcepub fn matrix1_mut(&mut self) -> &mut Matrix3x4<f32>
pub fn matrix1_mut(&mut self) -> &mut Matrix3x4<f32>
Transform matrix 1 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn matrix2_mut(&mut self) -> &mut Matrix3x4<f32>
pub fn matrix2_mut(&mut self) -> &mut Matrix3x4<f32>
Transform matrix 2 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn matrix3_mut(&mut self) -> &mut Matrix3x4<f32>
pub fn matrix3_mut(&mut self) -> &mut Matrix3x4<f32>
Transform matrix 3 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn i_matrix_index_mut(&mut self) -> &mut i32
pub fn i_matrix_index_mut(&mut self) -> &mut i32
Matrix index in hierarchy.
Sourcepub fn i_parent_matrix_index_mut(&mut self) -> &mut i32
pub fn i_parent_matrix_index_mut(&mut self) -> &mut i32
Parent matrix index for hierarchical transforms.
Sourcepub fn sz_padding_mut(&mut self) -> &mut Vec<u8> ⓘ
pub fn sz_padding_mut(&mut self) -> &mut Vec<u8> ⓘ
Additional padding bytes (variable length).
Sourcepub fn attachment_points_mut(&mut self) -> &mut Vec<AttachmentPointEntry>
pub fn attachment_points_mut(&mut self) -> &mut Vec<AttachmentPointEntry>
Named attachment points for weapons, effects, banners, etc.
Sourcepub fn textures_mut(&mut self) -> &mut Vec<Texture>
pub fn textures_mut(&mut self) -> &mut Vec<Texture>
Texture list with type and path for each texture.
Sourcepub fn params_string_mut(&mut self) -> &mut Vec<(i32, String)>
pub fn params_string_mut(&mut self) -> &mut Vec<(i32, String)>
String shader parameters (index, value pairs).
Sourcepub fn params_f32_mut(&mut self) -> &mut Vec<(i32, f32)>
pub fn params_f32_mut(&mut self) -> &mut Vec<(i32, f32)>
Float shader parameters (index, value pairs).
Sourcepub fn params_i32_mut(&mut self) -> &mut Vec<(i32, i32)>
pub fn params_i32_mut(&mut self) -> &mut Vec<(i32, i32)>
Integer shader parameters (index, value pairs).
Sourcepub fn params_vector4df32_mut(&mut self) -> &mut Vec<(i32, Vector4<f32>)>
pub fn params_vector4df32_mut(&mut self) -> &mut Vec<(i32, Vector4<f32>)>
Vector4 shader parameters (index, value pairs).
Sourcepub fn uk_7_mut(&mut self) -> &mut Vec<Uk7>
pub fn uk_7_mut(&mut self) -> &mut Vec<Uk7>
Cloth physics data section 1 (cloth materials only, format undocumented).
Source§impl Material
impl Material
Sourcepub fn set_vertex_format(&mut self, val: VertexFormat) -> &mut Self
pub fn set_vertex_format(&mut self, val: VertexFormat) -> &mut Self
Vertex format determining vertex data layout.
Sourcepub fn set_name(&mut self, val: String) -> &mut Self
pub fn set_name(&mut self, val: String) -> &mut Self
Material name (human-readable identifier).
Sourcepub fn set_uk_1(&mut self, val: u32) -> &mut Self
pub fn set_uk_1(&mut self, val: u32) -> &mut Self
Unknown field 1 (only in RsTerrain and projected decal materials).
Sourcepub fn set_uk_2(&mut self, val: u32) -> &mut Self
pub fn set_uk_2(&mut self, val: u32) -> &mut Self
Unknown field 2 (only in RsTerrain and projected decal materials).
Sourcepub fn set_uk_3(&mut self, val: u32) -> &mut Self
pub fn set_uk_3(&mut self, val: u32) -> &mut Self
Unknown field 3 (only in RsTerrain and projected decal materials).
Sourcepub fn set_uk_4(&mut self, val: u32) -> &mut Self
pub fn set_uk_4(&mut self, val: u32) -> &mut Self
Unknown field 4 (only in RsTerrain and projected decal materials).
Sourcepub fn set_uk_5(&mut self, val: u32) -> &mut Self
pub fn set_uk_5(&mut self, val: u32) -> &mut Self
Unknown field 5 (only in RsTerrain and projected decal materials).
Sourcepub fn set_uk_6(&mut self, val: u32) -> &mut Self
pub fn set_uk_6(&mut self, val: u32) -> &mut Self
Unknown field 6 (only in RsTerrain and projected decal materials).
Sourcepub fn set_texture_directory(&mut self, val: String) -> &mut Self
pub fn set_texture_directory(&mut self, val: String) -> &mut Self
Directory path for texture files (relative to game data directory).
Sourcepub fn set_filters(&mut self, val: String) -> &mut Self
pub fn set_filters(&mut self, val: String) -> &mut Self
Filter settings (NOT part of file format, runtime-only).
Sourcepub fn set_padding_byte0(&mut self, val: u8) -> &mut Self
pub fn set_padding_byte0(&mut self, val: u8) -> &mut Self
Padding byte 0 (alignment/reserved).
Sourcepub fn set_padding_byte1(&mut self, val: u8) -> &mut Self
pub fn set_padding_byte1(&mut self, val: u8) -> &mut Self
Padding byte 1 (alignment/reserved).
Sourcepub fn set_v_pivot(&mut self, val: Vector3<f32>) -> &mut Self
pub fn set_v_pivot(&mut self, val: Vector3<f32>) -> &mut Self
Pivot point for transformations.
Sourcepub fn set_matrix1(&mut self, val: Matrix3x4<f32>) -> &mut Self
pub fn set_matrix1(&mut self, val: Matrix3x4<f32>) -> &mut Self
Transform matrix 1 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn set_matrix2(&mut self, val: Matrix3x4<f32>) -> &mut Self
pub fn set_matrix2(&mut self, val: Matrix3x4<f32>) -> &mut Self
Transform matrix 2 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn set_matrix3(&mut self, val: Matrix3x4<f32>) -> &mut Self
pub fn set_matrix3(&mut self, val: Matrix3x4<f32>) -> &mut Self
Transform matrix 3 (3x4, implicit 4th row: [0, 0, 0, 1]).
Sourcepub fn set_i_matrix_index(&mut self, val: i32) -> &mut Self
pub fn set_i_matrix_index(&mut self, val: i32) -> &mut Self
Matrix index in hierarchy.
Sourcepub fn set_i_parent_matrix_index(&mut self, val: i32) -> &mut Self
pub fn set_i_parent_matrix_index(&mut self, val: i32) -> &mut Self
Parent matrix index for hierarchical transforms.
Sourcepub fn set_sz_padding(&mut self, val: Vec<u8>) -> &mut Self
pub fn set_sz_padding(&mut self, val: Vec<u8>) -> &mut Self
Additional padding bytes (variable length).
Sourcepub fn set_attachment_points(
&mut self,
val: Vec<AttachmentPointEntry>,
) -> &mut Self
pub fn set_attachment_points( &mut self, val: Vec<AttachmentPointEntry>, ) -> &mut Self
Named attachment points for weapons, effects, banners, etc.
Sourcepub fn set_textures(&mut self, val: Vec<Texture>) -> &mut Self
pub fn set_textures(&mut self, val: Vec<Texture>) -> &mut Self
Texture list with type and path for each texture.
Sourcepub fn set_params_string(&mut self, val: Vec<(i32, String)>) -> &mut Self
pub fn set_params_string(&mut self, val: Vec<(i32, String)>) -> &mut Self
String shader parameters (index, value pairs).
Sourcepub fn set_params_f32(&mut self, val: Vec<(i32, f32)>) -> &mut Self
pub fn set_params_f32(&mut self, val: Vec<(i32, f32)>) -> &mut Self
Float shader parameters (index, value pairs).
Sourcepub fn set_params_i32(&mut self, val: Vec<(i32, i32)>) -> &mut Self
pub fn set_params_i32(&mut self, val: Vec<(i32, i32)>) -> &mut Self
Integer shader parameters (index, value pairs).
Sourcepub fn set_params_vector4df32(
&mut self,
val: Vec<(i32, Vector4<f32>)>,
) -> &mut Self
pub fn set_params_vector4df32( &mut self, val: Vec<(i32, Vector4<f32>)>, ) -> &mut Self
Vector4 shader parameters (index, value pairs).
Sourcepub fn set_uk_7(&mut self, val: Vec<Uk7>) -> &mut Self
pub fn set_uk_7(&mut self, val: Vec<Uk7>) -> &mut Self
Cloth physics data section 1 (cloth materials only, format undocumented).
Source§impl Material
impl Material
Sourcepub fn read<R: ReadBytes>(data: &mut R, mtype: MaterialType) -> Result<Self>
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.
Sourcepub fn write<W: WriteBytes>(
&self,
buffer: &mut W,
mtype: MaterialType,
) -> Result<()>
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<'de> Deserialize<'de> for Material
impl<'de> Deserialize<'de> for Material
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Material
Auto Trait Implementations§
impl Freeze for Material
impl RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl UnsafeUnpin for Material
impl UnwindSafe for Material
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.