Struct kiss3d::scene::PlanarSceneNode
source · [−]pub struct PlanarSceneNode { /* private fields */ }
Expand description
A node of the scene graph.
This may represent a group of other nodes, and/or contain an object that can be rendered.
Implementations
sourceimpl PlanarSceneNode
impl PlanarSceneNode
sourcepub fn new(
local_scale: Vector2<f32>,
local_transform: Isometry2<f32>,
object: Option<PlanarObject>
) -> PlanarSceneNode
pub fn new(
local_scale: Vector2<f32>,
local_transform: Isometry2<f32>,
object: Option<PlanarObject>
) -> PlanarSceneNode
Creates a new scene node that is not rooted.
sourcepub fn new_empty() -> PlanarSceneNode
pub fn new_empty() -> PlanarSceneNode
Creates a new empty, not rooted, node with identity transformations.
sourcepub fn data(&self) -> Ref<'_, PlanarSceneNodeData>
pub fn data(&self) -> Ref<'_, PlanarSceneNodeData>
The data of this scene node.
sourcepub fn data_mut(&mut self) -> RefMut<'_, PlanarSceneNodeData>
pub fn data_mut(&mut self) -> RefMut<'_, PlanarSceneNodeData>
The data of this scene node.
sourcepub fn add_group(&mut self) -> PlanarSceneNode
pub fn add_group(&mut self) -> PlanarSceneNode
Adds a node without object to this node children.
sourcepub fn add_child(&mut self, node: PlanarSceneNode)
pub fn add_child(&mut self, node: PlanarSceneNode)
sourcepub fn add_object(
&mut self,
local_scale: Vector2<f32>,
local_transform: Isometry2<f32>,
object: PlanarObject
) -> PlanarSceneNode
pub fn add_object(
&mut self,
local_scale: Vector2<f32>,
local_transform: Isometry2<f32>,
object: PlanarObject
) -> PlanarSceneNode
Adds a node containing an object to this node children.
sourcepub fn add_rectangle(&mut self, wx: f32, wy: f32) -> PlanarSceneNode
pub fn add_rectangle(&mut self, wx: f32, wy: f32) -> PlanarSceneNode
Adds a rectangle as a children of this node. The rectangle is initially axis-aligned and centered at (0, 0).
Arguments
wx
- the rectangle extent along the x axiswy
- the rectangle extent along the y axis
sourcepub fn add_circle(&mut self, r: f32) -> PlanarSceneNode
pub fn add_circle(&mut self, r: f32) -> PlanarSceneNode
Adds a circle as a children of this node. The circle is initially centered at (0, 0, 0).
Arguments
r
- the circle radius
sourcepub fn add_capsule(&mut self, r: f32, h: f32) -> PlanarSceneNode
pub fn add_capsule(&mut self, r: f32, h: f32) -> PlanarSceneNode
Adds a 2D capsule as a children of this node. The capsule is initially centered at (0, 0).
Arguments
r
- the circle radius
sourcepub fn add_geom_with_name(
&mut self,
geometry_name: &str,
scale: Vector2<f32>
) -> Option<PlanarSceneNode>
pub fn add_geom_with_name(
&mut self,
geometry_name: &str,
scale: Vector2<f32>
) -> Option<PlanarSceneNode>
Creates and adds a new object using the geometry registered as geometry_name
.
sourcepub fn add_mesh(
&mut self,
mesh: Rc<RefCell<PlanarMesh>>,
scale: Vector2<f32>
) -> PlanarSceneNode
pub fn add_mesh(
&mut self,
mesh: Rc<RefCell<PlanarMesh>>,
scale: Vector2<f32>
) -> PlanarSceneNode
Creates and adds a new object to this node children using a 2D mesh.
sourcepub fn add_convex_polygon(
&mut self,
polygon: Vec<Point2<f32>>,
scale: Vector2<f32>
) -> PlanarSceneNode
pub fn add_convex_polygon(
&mut self,
polygon: Vec<Point2<f32>>,
scale: Vector2<f32>
) -> PlanarSceneNode
Creates and adds a new object to this node children using a convex polyline
sourcepub fn apply_to_scene_nodes_mut<F: FnMut(&mut PlanarSceneNode)>(
&mut self,
f: &mut F
)
pub fn apply_to_scene_nodes_mut<F: FnMut(&mut PlanarSceneNode)>(
&mut self,
f: &mut F
)
Applies a closure to each object contained by this node and its children.
sourcepub fn apply_to_scene_nodes<F: FnMut(&PlanarSceneNode)>(&self, f: &mut F)
pub fn apply_to_scene_nodes<F: FnMut(&PlanarSceneNode)>(&self, f: &mut F)
Applies a closure to each object contained by this node and its children.
sourcepub fn render(&mut self, camera: &mut dyn PlanarCamera)
pub fn render(&mut self, camera: &mut dyn PlanarCamera)
Render the scene graph rooted by this node.
sourcepub fn set_material(
&mut self,
material: Rc<RefCell<Box<dyn PlanarMaterial + 'static>>>
)
pub fn set_material(
&mut self,
material: Rc<RefCell<Box<dyn PlanarMaterial + 'static>>>
)
Sets the material of the objects contained by this node and its children.
sourcepub fn set_material_with_name(&mut self, name: &str)
pub fn set_material_with_name(&mut self, name: &str)
Sets the material of the objects contained by this node and its children.
sourcepub fn set_lines_width(&mut self, width: f32)
pub fn set_lines_width(&mut self, width: f32)
Sets the width of the lines drawn for the objects contained by this node and its children.
sourcepub fn set_lines_color(&mut self, color: Option<Point3<f32>>)
pub fn set_lines_color(&mut self, color: Option<Point3<f32>>)
Sets the color of the lines drawn for the objects contained by this node and its children.
sourcepub fn set_points_size(&mut self, size: f32)
pub fn set_points_size(&mut self, size: f32)
Sets the size of the points drawn for the objects contained by this node and its children.
sourcepub fn set_surface_rendering_activation(&mut self, active: bool)
pub fn set_surface_rendering_activation(&mut self, active: bool)
Activates or deactivates the rendering of the surfaces of the objects contained by this node and its children.
sourcepub fn enable_backface_culling(&mut self, active: bool)
pub fn enable_backface_culling(&mut self, active: bool)
Activates or deactivates backface culling for the objects contained by this node and its children.
sourcepub fn modify_vertices<F: FnMut(&mut Vec<Point2<f32>>)>(&mut self, f: &mut F)
pub fn modify_vertices<F: FnMut(&mut Vec<Point2<f32>>)>(&mut self, f: &mut F)
Mutably accesses the vertices of the objects contained by this node and its children.
The provided closure is called once per object.
sourcepub fn read_vertices<F: FnMut(&[Point2<f32>])>(&self, f: &mut F)
pub fn read_vertices<F: FnMut(&[Point2<f32>])>(&self, f: &mut F)
Accesses the vertices of the objects contained by this node and its children.
The provided closure is called once per object.
sourcepub fn modify_faces<F: FnMut(&mut Vec<Point3<u16>>)>(&mut self, f: &mut F)
pub fn modify_faces<F: FnMut(&mut Vec<Point3<u16>>)>(&mut self, f: &mut F)
Mutably accesses the faces of the objects contained by this node and its children.
The provided closure is called once per object.
sourcepub fn read_faces<F: FnMut(&[Point3<u16>])>(&self, f: &mut F)
pub fn read_faces<F: FnMut(&[Point3<u16>])>(&self, f: &mut F)
Accesses the faces of the objects contained by this node and its children.
The provided closure is called once per object.
sourcepub fn modify_uvs<F: FnMut(&mut Vec<Point2<f32>>)>(&mut self, f: &mut F)
pub fn modify_uvs<F: FnMut(&mut Vec<Point2<f32>>)>(&mut self, f: &mut F)
Mutably accesses the texture coordinates of the objects contained by this node and its children.
The provided closure is called once per object.
sourcepub fn read_uvs<F: FnMut(&[Point2<f32>])>(&self, f: &mut F)
pub fn read_uvs<F: FnMut(&[Point2<f32>])>(&self, f: &mut F)
Accesses the texture coordinates of the objects contained by this node and its children.
The provided closure is called once per object.
sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Get the visibility status of node.
sourcepub fn set_visible(&mut self, visible: bool)
pub fn set_visible(&mut self, visible: bool)
Sets the visibility of this node.
The node and its children are not rendered if it is not visible.
sourcepub fn set_color(&mut self, r: f32, g: f32, b: f32)
pub fn set_color(&mut self, r: f32, g: f32, b: f32)
Sets the color of the objects contained by this node and its children.
Colors components must be on the range [0.0, 1.0]
.
sourcepub fn set_texture_from_file(&mut self, path: &Path, name: &str)
pub fn set_texture_from_file(&mut self, path: &Path, name: &str)
Sets the texture of the objects contained by this node and its children.
The texture is loaded from a file and registered by the global TextureManager
.
Arguments
path
- relative path of the texture on the diskname
- &str to identify this texture inTextureManager
sourcepub fn set_texture_from_memory(&mut self, image_data: &[u8], name: &str)
pub fn set_texture_from_memory(&mut self, image_data: &[u8], name: &str)
Sets the texture of the objects contained by this node and its children.
The texture is loaded from a file and registered by the global TextureManager
.
Arguments
image_data
- slice of bytes containing encoded imagename
- &str to identify this texture inTextureManager
sourcepub fn set_texture_with_name(&mut self, name: &str)
pub fn set_texture_with_name(&mut self, name: &str)
Sets the texture of the objects contained by this node and its children.
The texture must already have been registered as name
.
sourcepub fn set_texture(&mut self, texture: Rc<Texture>)
pub fn set_texture(&mut self, texture: Rc<Texture>)
Sets the texture of the objects contained by this node and its children.
sourcepub fn set_local_scale(&mut self, sx: f32, sy: f32)
pub fn set_local_scale(&mut self, sx: f32, sy: f32)
Sets the local scaling factors of the object.
sourcepub fn append_transformation(&mut self, t: &Isometry2<f32>)
pub fn append_transformation(&mut self, t: &Isometry2<f32>)
Appends a transformation to this node local transformation.
sourcepub fn prepend_to_local_transformation(&mut self, t: &Isometry2<f32>)
pub fn prepend_to_local_transformation(&mut self, t: &Isometry2<f32>)
Prepends a transformation to this node local transformation.
sourcepub fn set_local_transformation(&mut self, t: Isometry2<f32>)
pub fn set_local_transformation(&mut self, t: Isometry2<f32>)
Set this node local transformation.
sourcepub fn append_translation(&mut self, t: &Translation2<f32>)
pub fn append_translation(&mut self, t: &Translation2<f32>)
Appends a translation to this node local transformation.
sourcepub fn prepend_to_local_translation(&mut self, t: &Translation2<f32>)
pub fn prepend_to_local_translation(&mut self, t: &Translation2<f32>)
Prepends a translation to this node local transformation.
sourcepub fn set_local_translation(&mut self, t: Translation2<f32>)
pub fn set_local_translation(&mut self, t: Translation2<f32>)
Sets the local translation of this node.
sourcepub fn append_rotation(&mut self, r: &UnitComplex<f32>)
pub fn append_rotation(&mut self, r: &UnitComplex<f32>)
Appends a rotation to this node local transformation.
sourcepub fn append_rotation_wrt_center(&mut self, r: &UnitComplex<f32>)
pub fn append_rotation_wrt_center(&mut self, r: &UnitComplex<f32>)
Appends a rotation to this node local transformation.
sourcepub fn prepend_to_local_rotation(&mut self, r: &UnitComplex<f32>)
pub fn prepend_to_local_rotation(&mut self, r: &UnitComplex<f32>)
Prepends a rotation to this node local transformation.
sourcepub fn set_local_rotation(&mut self, r: UnitComplex<f32>)
pub fn set_local_rotation(&mut self, r: UnitComplex<f32>)
Sets the local rotation of this node.
Trait Implementations
sourceimpl Clone for PlanarSceneNode
impl Clone for PlanarSceneNode
sourcefn clone(&self) -> PlanarSceneNode
fn clone(&self) -> PlanarSceneNode
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for PlanarSceneNode
impl !Send for PlanarSceneNode
impl !Sync for PlanarSceneNode
impl Unpin for PlanarSceneNode
impl !UnwindSafe for PlanarSceneNode
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert 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
. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
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
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.