Struct three_d::renderer::object::Model [−][src]
pub struct Model<M: ForwardMaterial> {
pub cull: Cull,
pub material: M,
// some fields omitted
}Expand description
A 3D model consisting of a triangle mesh and any material that implements the ForwardMaterial trait.
Fields
cull: Cullset in render states on material instead
material: MThe material applied to the model
Implementations
Creates a new 3D model with a triangle mesh as geometry and a default ColorMaterial.
pub fn new_with_material(
context: &Context,
cpu_mesh: &CPUMesh,
material: M
) -> ThreeDResult<Self>
pub fn new_with_material(
context: &Context,
cpu_mesh: &CPUMesh,
material: M
) -> ThreeDResult<Self>
Creates a new 3D model with a triangle mesh as geometry and the given material.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the mesh with a color per triangle vertex. The colors are defined when constructing the mesh and are assumed to be in gamma color space (sRGBA). Must be called in a render target render function, for example in the callback function of Screen::write. Will render the model transparent if the colors contain alpha values below 255, you only need to render the model after all solid models.
Errors
Will return an error if the mesh has no colors.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the mesh with the given color. The color is assumed to be in gamma color space (sRGBA). Must be called in a render target render function, for example in the callback function of Screen::write. Will render the model transparent if the color contains an alpha value below 255, you only need to render the model after all solid models.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the uv coordinates of the mesh in red (u) and green (v) for debug purposes. Must be called in a render target render function, for example in the callback function of Screen::write.
Errors
Will return an error if the mesh has no uv coordinates.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the normals of the mesh for debug purposes. Must be called in a render target render function, for example in the callback function of Screen::write.
Errors
Will return an error if the mesh has no normals.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the mesh with the given texture which is assumed to be in sRGB color space with or without an alpha channel. Must be called in a render target render function, for example in the callback function of Screen::write. Will render the model transparent if the texture contain an alpha channel (ie. the format is Format::RGBA), you only need to render the model after all solid models.
Errors
Will return an error if the mesh has no uv coordinates.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the depth (scaled such that a value of 1 corresponds to max_depth) into the red channel of the current color render target which for example is used for picking. Must be called in a render target render function, for example in the callback function of Screen::write.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render only the depth into the current depth render target which is useful for shadow maps or depth pre-pass. Must be called in a render target render function, for example in the callback function of Screen::write.
Trait Implementations
Returns the AxisAlignedBoundingBox for this geometry. Read more
Returns the local to world transformation applied to this geometry. Read more
Set the local to world transformation applied to this geometry. Read more
Render the object. Must be called in a render target render function, for example in the callback function of Screen::write. You can use Lights::default() if you know the object does not require lights to be rendered. Read more
Returns whether or not this object should be considered transparent. Read more
fn render_forward(
&self,
material: &dyn ForwardMaterial,
camera: &Camera,
lights: &Lights
) -> ThreeDResult<()>
fn render_forward(
&self,
material: &dyn ForwardMaterial,
camera: &Camera,
lights: &Lights
) -> ThreeDResult<()>
Render the object with the given material. Must be called in a render target render function, for example in the callback function of Screen::write. You can use Lights::default() if you know the material does not require lights. Read more
fn render_deferred(
&self,
material: &dyn DeferredMaterial,
camera: &Camera,
viewport: Viewport
) -> ThreeDResult<()>
fn render_deferred(
&self,
material: &dyn DeferredMaterial,
camera: &Camera,
viewport: Viewport
) -> ThreeDResult<()>
Render the geometry and surface material parameters of the object. Should usually not be called directly but used in DeferredPipeline::geometry_pass. Read more
fn render_with_lighting(
&self,
camera: &Camera,
material: &PhysicalMaterial,
lighting_model: LightingModel,
ambient_light: Option<&AmbientLight>,
directional_lights: &[&DirectionalLight],
spot_lights: &[&SpotLight],
point_lights: &[&PointLight]
) -> ThreeDResult<()>
fn render_with_lighting(
&self,
camera: &Camera,
material: &PhysicalMaterial,
lighting_model: LightingModel,
ambient_light: Option<&AmbientLight>,
directional_lights: &[&DirectionalLight],
spot_lights: &[&SpotLight],
point_lights: &[&PointLight]
) -> ThreeDResult<()>
Use ‘render_forward’ instead
Render the object shaded with the given lights using physically based rendering (PBR). Must be called in a render target render function, for example in the callback function of Screen::write. Will render transparent if the material contain an albedo color with alpha value below 255 or if the albedo texture contain an alpha channel (ie. the format is Format::RGBA), you only need to render the model after all solid models. Read more
fn geometry_pass(
&self,
camera: &Camera,
viewport: Viewport,
material: &PhysicalMaterial
) -> ThreeDResult<()>
fn geometry_pass(
&self,
camera: &Camera,
viewport: Viewport,
material: &PhysicalMaterial
) -> ThreeDResult<()>
Use ‘render_deferred’ instead
Render the geometry and surface material parameters of the object. Should not be called directly but used in a deferred render pass. Read more
Auto Trait Implementations
impl<M> !RefUnwindSafe for Model<M>
impl<M> !UnwindSafe for Model<M>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more