pub struct Mesh3dAttributes { /* private fields */ }Expand description
Extensible model-vertex data for super::Mesh3d::with_attributes.
Omitted colors multiply by white. Supplied arrays must match the model vertex count exactly, including unused vertices; an explicit empty array is not omission. No normals or simulation quantities are generated here.
use sim_engine::{Color, Mesh3d, Mesh3dAttributes, Vec3};
let attributes = Mesh3dAttributes::new().with_vertex_colors(vec![
Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 1.0, 0.0), Color::rgb(0.0, 0.0, 1.0),
])?;
let mesh = Mesh3d::with_attributes(
vec![Vec3::ZERO, Vec3::X, Vec3::Y], vec![0, 1, 2], Vec::new(), attributes,
)?;
assert_eq!(mesh.vertex_colors().len(), 3);Implementations§
Source§impl Mesh3dAttributes
impl Mesh3dAttributes
Sourcepub fn with_texture_coordinates(
self,
coordinates: Vec<TextureCoordinate2d>,
) -> Self
pub fn with_texture_coordinates( self, coordinates: Vec<TextureCoordinate2d>, ) -> Self
Supplies normalized model UVs; mesh construction validates the count.
Sourcepub fn with_vertex_colors(self, colors: Vec<Color>) -> Result<Self, Mesh3dError>
pub fn with_vertex_colors(self, colors: Vec<Color>) -> Result<Self, Mesh3dError>
Supplies normalized, straight-linear RGBA colors without clamping.
Reports the source vertex index of the first non-finite or out-of-range channel. Mesh construction separately checks the exact vertex count. Opaque surfaces ignore vertex alpha; Mask and Blend use the combined alpha. RGBA is interpolated perspectively and multiplies surface/texture tint. Mathematical display edges keep their independent wireframe colors.
Sourcepub fn with_normals(self, normals: Vec<Vec3>) -> Result<Self, Mesh3dError>
pub fn with_normals(self, normals: Vec<Vec3>) -> Result<Self, Mesh3dError>
Supplies finite nonzero model normals, normalized robustly in place. No face normals are inferred. Every value, including unused vertices, is validated; mesh construction separately requires an exact vertex count. Nonuniform transforms use inverse-transpose direction transport, followed by perspective interpolation and fragment normalization, not vertex normalization.
Sourcepub fn normals(&self) -> Option<&[Vec3]>
pub fn normals(&self) -> Option<&[Vec3]>
Supplied normalized model normals, distinguishing omission from empty.
Sourcepub fn texture_coordinates(&self) -> Option<&[TextureCoordinate2d]>
pub fn texture_coordinates(&self) -> Option<&[TextureCoordinate2d]>
Supplied UVs, distinguishing omission from an explicit empty array.
Sourcepub fn vertex_colors(&self) -> Option<&[Color]>
pub fn vertex_colors(&self) -> Option<&[Color]>
Supplied straight-linear colors, distinguishing omission from empty.