pub struct SurfaceData {
pub vertex_buffer: VertexBuffer,
pub geometry_buffer: TriangleBuffer,
pub blend_shapes_container: Option<BlendShapesContainer>,
/* private fields */
}
Expand description
Data source of a surface. Each surface can share same data source, this is used in instancing technique to render multiple instances of same model at different places.
Fields§
§vertex_buffer: VertexBuffer
Current vertex buffer.
geometry_buffer: TriangleBuffer
Current geometry buffer.
blend_shapes_container: Option<BlendShapesContainer>
A container for blend shapes.
Implementations§
Source§impl SurfaceData
impl SurfaceData
pub const VERTEX_BUFFER: &'static str = "vertex_buffer"
pub const GEOMETRY_BUFFER: &'static str = "geometry_buffer"
pub const BLEND_SHAPES_CONTAINER: &'static str = "blend_shapes_container"
Source§impl SurfaceData
impl SurfaceData
Sourcepub fn new(vertex_buffer: VertexBuffer, triangles: TriangleBuffer) -> Self
pub fn new(vertex_buffer: VertexBuffer, triangles: TriangleBuffer) -> Self
Creates new data source using given vertices and indices.
Sourcepub fn transform_geometry(
&mut self,
transform: &Matrix4<f32>,
) -> Result<(), VertexFetchError>
pub fn transform_geometry( &mut self, transform: &Matrix4<f32>, ) -> Result<(), VertexFetchError>
Applies given transform for every spatial part of the data (vertex position, normal, tangent).
Sourcepub fn from_raw_mesh<T>(raw: RawMesh<T>) -> Selfwhere
T: VertexTrait,
pub fn from_raw_mesh<T>(raw: RawMesh<T>) -> Selfwhere
T: VertexTrait,
Converts raw mesh into “renderable” mesh. It is useful to build procedural meshes. See RawMesh
docs for more
info.
Sourcepub fn calculate_tangents(&mut self) -> Result<(), VertexFetchError>
pub fn calculate_tangents(&mut self) -> Result<(), VertexFetchError>
Calculates tangents of surface. Tangents are needed for correct lighting, you will get incorrect lighting if tangents of your surface are invalid! When engine loads a mesh from “untrusted” source, it automatically calculates tangents for you, so there is no need to call this manually in this case. However if you making your mesh procedurally, you have to use this method! This method uses “classic” method which is described in: “Computing Tangent Space Basis Vectors for an Arbitrary Mesh” article by Eric Lengyel.
Sourcepub fn make_unit_xy_quad() -> Self
pub fn make_unit_xy_quad() -> Self
Creates a quad oriented on oXY plane with unit width and height.
Sourcepub fn make_collapsed_xy_quad() -> Self
pub fn make_collapsed_xy_quad() -> Self
Creates a degenerated quad which collapsed in a point. This is very special method for sprite renderer - shader will automatically “push” corners in correct sides so sprite will always face camera.
Sourcepub fn make_quad(transform: &Matrix4<f32>) -> Self
pub fn make_quad(transform: &Matrix4<f32>) -> Self
Creates new quad at oXY plane with given transform.
Sourcepub fn calculate_normals(&mut self) -> Result<(), VertexFetchError>
pub fn calculate_normals(&mut self) -> Result<(), VertexFetchError>
Calculates per-face normals. This method is fast, but have very poor quality, and surface will look facet.
Sourcepub fn make_sphere(
slices: usize,
stacks: usize,
r: f32,
transform: &Matrix4<f32>,
) -> Self
pub fn make_sphere( slices: usize, stacks: usize, r: f32, transform: &Matrix4<f32>, ) -> Self
Creates sphere of specified radius with given slices and stacks. The larger the slices
and stacks
, the smoother the sphere will be.
Typical values are [16..32]. The sphere is then transformed by the given transformation matrix, which could be Matrix4::identity
to not modify the sphere at all.
Sourcepub fn make_cone(sides: usize, r: f32, h: f32, transform: &Matrix4<f32>) -> Self
pub fn make_cone(sides: usize, r: f32, h: f32, transform: &Matrix4<f32>) -> Self
Creates vertical cone with the given amount of sides, radius, height. The larger the amount of sides, the smoother the cone
will be, typical values are [16..32]. The cone is then transformed using the given transformation matrix, which could be
Matrix4::identity
to not modify the cone at all.
Sourcepub fn make_torus(
inner_radius: f32,
outer_radius: f32,
num_rings: usize,
num_segments: usize,
transform: &Matrix4<f32>,
) -> Self
pub fn make_torus( inner_radius: f32, outer_radius: f32, num_rings: usize, num_segments: usize, transform: &Matrix4<f32>, ) -> Self
Creates a torus in oXY plane with the given inner and outer radii. num_rings
defines the amount of “slices” around the Z axis of the
torus shape, num_segments
defines the amount of segments in every slice. The larger the num_rings
and num_segments
are, the more
smooth the torus will be, typical values are 16..32
. Torus will be transformed using the given transformation matrix, which could be
Matrix4::identity
to not modify the torus at all.
Sourcepub fn make_cylinder(
sides: usize,
r: f32,
h: f32,
caps: bool,
transform: &Matrix4<f32>,
) -> Self
pub fn make_cylinder( sides: usize, r: f32, h: f32, caps: bool, transform: &Matrix4<f32>, ) -> Self
Creates vertical cylinder with the given amount of sides, radius, height and optional caps. The larger the sides
, the smoother the cylinder
will be, typical values are [16..32]. caps
defines whether the cylinder will have caps or not. The cylinder is transformed using the given
transformation matrix, which could be Matrix4::identity
to not modify the cylinder at all.
Sourcepub fn make_cube(transform: Matrix4<f32>) -> Self
pub fn make_cube(transform: Matrix4<f32>) -> Self
Creates unit cube with the given transform, which could be Matrix4::identity
to not modify the cube at all and leave it unit.
Sourcepub fn content_hash(&self) -> u64
pub fn content_hash(&self) -> u64
Calculates hash based on the contents of the surface shared data. This could be time-consuming if there’s a lot of vertices or indices.
Trait Implementations§
Source§impl Clone for SurfaceData
impl Clone for SurfaceData
Source§fn clone(&self) -> SurfaceData
fn clone(&self) -> SurfaceData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SurfaceData
impl Debug for SurfaceData
Source§impl Default for SurfaceData
impl Default for SurfaceData
Source§fn default() -> SurfaceData
fn default() -> SurfaceData
Source§impl Reflect for SurfaceDatawhere
Self: 'static,
VertexBuffer: Reflect,
TriangleBuffer: Reflect,
Option<BlendShapesContainer>: Reflect,
impl Reflect for SurfaceDatawhere
Self: 'static,
VertexBuffer: Reflect,
TriangleBuffer: Reflect,
Option<BlendShapesContainer>: Reflect,
fn source_path() -> &'static str
fn type_name(&self) -> &'static str
fn doc(&self) -> &'static str
Source§fn assembly_name(&self) -> &'static str
fn assembly_name(&self) -> &'static str
#[derive(Reflect)]
) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.Source§fn type_assembly_name() -> &'static str
fn type_assembly_name() -> &'static str
#[derive(Reflect)]
) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))
fn into_any(self: Box<Self>) -> Box<dyn Any>
fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn as_any(&self, func: &mut dyn FnMut(&dyn Any))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut dyn Any))
fn as_reflect(&self, func: &mut dyn FnMut(&dyn Reflect))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut dyn Reflect))
fn fields(&self, func: &mut dyn FnMut(&[&dyn Reflect]))
fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [&mut dyn Reflect]))
fn field(&self, name: &str, func: &mut dyn FnMut(Option<&dyn Reflect>))
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut dyn Reflect>), )
Source§fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>),
)
fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>), )
#[reflect(setter = ..)]
or falls back to
Reflect::field_mut
fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))
fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )
fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))
fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )
fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )
Source§impl ResourceData for SurfaceData
impl ResourceData for SurfaceData
Source§fn save(&mut self, _path: &Path) -> Result<(), Box<dyn Error>>
fn save(&mut self, _path: &Path) -> Result<(), Box<dyn Error>>
Source§fn can_be_saved(&self) -> bool
fn can_be_saved(&self) -> bool
true
if the resource data can be saved to a file, false
- otherwise. Not every
resource type supports saving, for example there might be temporary resource type that is
used only at runtime which does not need saving at all.Source§impl TypeUuidProvider for SurfaceData
impl TypeUuidProvider for SurfaceData
Source§impl Visit for SurfaceData
impl Visit for SurfaceData
Source§fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
Auto Trait Implementations§
impl Freeze for SurfaceData
impl !RefUnwindSafe for SurfaceData
impl Send for SurfaceData
impl Sync for SurfaceData
impl Unpin for SurfaceData
impl !UnwindSafe for SurfaceData
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any
. Could be used to downcast a trait object
to a particular type.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any
. Could be used to downcast a trait object
to a particular type.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§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()
.Source§impl<T> ReflectBase for Twhere
T: Reflect,
impl<T> ReflectBase for Twhere
T: Reflect,
fn as_any_raw(&self) -> &(dyn Any + 'static)
fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )
fn get_resolve_path<'p, T>(
&self,
path: &'p str,
func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>),
)where
T: Reflect,
fn get_resolve_path_mut<'p, T>(
&mut self,
path: &'p str,
func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>),
)where
T: Reflect,
Source§impl<T> ScriptMessagePayload for T
impl<T> ScriptMessagePayload for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
self
as &dyn Any
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self
as &dyn Any
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.