Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Scene.SceneNode.SceneNode Class Reference
Inheritance diagram for UM.Scene.SceneNode.SceneNode:
UM.Scene.Camera.Camera UM.Scene.Platform.Platform UM.Scene.ToolHandle.ToolHandle

Public Member Functions

None __init__ (self, Optional["SceneNode"] parent=None, bool visible=True, str name="", str node_id="")
 
"SceneNode" __deepcopy__ (self, Dict[int, object] memo)
 
None setCenterPosition (self, Vector center)
 
Optional["SceneNode"] getParent (self)
 
Vector getMirror (self)
 
None setMirror (self, vector)
 
Optional[MeshDatagetBoundingBoxMesh (self)
 
None calculateBoundingBoxMesh (self)
 
bool collidesWithBbox (self, AxisAlignedBox check_bbox)
 
None addDecorator (self, SceneNodeDecorator decorator)
 
List[SceneNodeDecoratorgetDecorators (self)
 
Optional[SceneNodeDecoratorgetDecorator (self, type dec_type)
 
 removeDecorators (self)
 
None removeDecorator (self, type dec_type)
 
Any callDecoration (self, str function, *args, **kwargs)
 
bool hasDecoration (self, str function)
 
str getName (self)
 
None setName (self, str name)
 
str getId (self)
 
None setId (self, str node_id)
 
int getDepth (self)
 
None setParent (self, Optional["SceneNode"] scene_node)
 
bool isVisible (self)
 
None setVisible (self, bool visible)
 
Optional[MeshDatagetMeshData (self)
 
Optional[MeshDatagetMeshDataTransformed (self)
 
Optional[numpy.ndarray] getMeshDataTransformedVertices (self)
 
Optional[numpy.ndarray] getMeshDataTransformedNormals (self)
 
None setMeshData (self, Optional[MeshData] mesh_data)
 
None addChild (self, "SceneNode" scene_node)
 
None removeChild (self, "SceneNode" child)
 
None removeAllChildren (self)
 
List["SceneNode"] getChildren (self)
 
bool hasChildren (self)
 
List["SceneNode"] getAllChildren (self)
 
Matrix getCachedNormalMatrix (self)
 
Matrix getWorldTransformation (self, copy=True)
 
Matrix getLocalTransformation (self, copy=True)
 
 setTransformation (self, Matrix transformation)
 
Quaternion getOrientation (self)
 
Quaternion getWorldOrientation (self)
 
None rotate (self, Quaternion rotation, int transform_space=TransformSpace.Local)
 
None setOrientation (self, Quaternion orientation, int transform_space=TransformSpace.Local)
 
Vector getScale (self)
 
Vector getWorldScale (self)
 
None scale (self, Vector scale, int transform_space=TransformSpace.Local)
 
None setScale (self, Vector scale, int transform_space=TransformSpace.Local)
 
Vector getPosition (self)
 
Vector getWorldPosition (self)
 
None translate (self, Vector translation, int transform_space=TransformSpace.Local)
 
None setPosition (self, Vector position, int transform_space=TransformSpace.Local)
 
None lookAt (self, Vector target, Vector up=Vector.Unit_Y)
 
bool render (self, renderer)
 
bool isEnabled (self)
 
None setEnabled (self, bool enable)
 
bool isSelectable (self)
 
None setSelectable (self, bool select)
 
Optional[AxisAlignedBoxgetBoundingBox (self)
 
None setCalculateBoundingBox (self, bool calculate)
 
Vector getShear (self)
 
Any getSetting (self, str key, Any default_value=None)
 
None setSetting (self, str key, Any value)
 
None invertNormals (self)
 
str __str__ (self)
 

Public Attributes

dict metadata = {}
 
 source_mime_type = None
 

Static Public Attributes

 decoratorsChanged = Signal()
 
 parentChanged = Signal()
 
 meshDataChanged = Signal()
 
 childrenChanged = Signal()
 
 transformationChanged = Signal()
 
 boundingBoxChanged = Signal()
 

Protected Member Functions

None _onParentChanged (self, Optional["SceneNode"] node)
 
None _onMeshDataChanged (self)
 
None _updateCachedNormalMatrix (self)
 
None _transformChanged (self)
 
None _updateLocalTransformation (self)
 
None _updateWorldTransformation (self)
 
None _updateTransformation (self)
 
None _resetAABB (self)
 
None _calculateAABB (self)
 

Protected Attributes

list _children = []
 
 _mesh_data = None
 
 _transformation = Matrix()
 
 _position = Vector()
 
 _scale = Vector(1.0, 1.0, 1.0)
 
 _shear = Vector(0.0, 0.0, 0.0)
 
 _mirror = Vector(1.0, 1.0, 1.0)
 
 _orientation = Quaternion()
 
Matrix _world_transformation = Matrix()
 
 _cached_normal_matrix = Matrix()
 
 _derived_position = Vector()
 
 _derived_orientation = Quaternion()
 
 _derived_scale = Vector()
 
 _parent = parent
 
bool _enabled = True
 
bool _selectable = False
 
bool _calculate_aabb = True
 
 _aabb = None
 
 _bounding_box_mesh = None
 
 _visible = visible
 
 _name = name
 
 _id = node_id
 
list _decorators = []
 
dict _settings = {}
 
 _onParentChanged
 Signals.
 

Detailed Description

A scene node object.

These objects can hold a mesh and multiple children. Each node has a transformation matrix
that maps it it's parents space to the local space (it's inverse maps local space to parent).

SceneNodes can be "Decorated" by adding SceneNodeDecorator objects.
These decorators can add functionality to scene nodes.
:sa SceneNodeDecorator
:todo Add unit testing

Constructor & Destructor Documentation

◆ __init__()

None UM.Scene.SceneNode.SceneNode.__init__ ( self,
Optional["SceneNode"] parent = None,
bool visible = True,
str name = "",
str node_id = "" )
Construct a scene node.

:param parent: The parent of this node (if any). Only a root node should have None as a parent.
:param visible: Is the SceneNode (and thus, all its children) visible?
:param name: Name of the SceneNode.

Member Function Documentation

◆ __str__()

str UM.Scene.SceneNode.SceneNode.__str__ ( self)
String output for debugging.

◆ _onParentChanged()

None UM.Scene.SceneNode.SceneNode._onParentChanged ( self,
Optional["SceneNode"] node )
protected
Handler for the ParentChanged signal
:param node: Node from which this event was triggered.

◆ addChild()

None UM.Scene.SceneNode.SceneNode.addChild ( self,
"SceneNode" scene_node )
Add a child to this node and set it's parent as this node.

:params scene_node SceneNode to add.

◆ addDecorator()

None UM.Scene.SceneNode.SceneNode.addDecorator ( self,
SceneNodeDecorator decorator )
Add a SceneNodeDecorator to this SceneNode.

:param decorator: The decorator to add.

◆ calculateBoundingBoxMesh()

None UM.Scene.SceneNode.SceneNode.calculateBoundingBoxMesh ( self)
(re)Calculate the bounding box mesh.

◆ callDecoration()

Any UM.Scene.SceneNode.SceneNode.callDecoration ( self,
str function,
* args,
** kwargs )
Call a decoration of this SceneNode.

SceneNodeDecorators add Decorations, which are callable functions.
:param function: The function to be called.
:param *args
:param **kwargs

◆ collidesWithBbox()

bool UM.Scene.SceneNode.SceneNode.collidesWithBbox ( self,
AxisAlignedBox check_bbox )
Return if the provided bbox collides with the bbox of this SceneNode

◆ getAllChildren()

List["SceneNode"] UM.Scene.SceneNode.SceneNode.getAllChildren ( self)
Get list of all children (including it's children children children etc.)

:returns: list ALl children in this 'tree'

◆ getBoundingBox()

Optional[AxisAlignedBox] UM.Scene.SceneNode.SceneNode.getBoundingBox ( self)
Get the bounding box of this node and its children.

◆ getBoundingBoxMesh()

Optional[MeshData] UM.Scene.SceneNode.SceneNode.getBoundingBoxMesh ( self)
Get the MeshData of the bounding box

:returns: :type{MeshData} Bounding box mesh.

◆ getChildren()

List["SceneNode"] UM.Scene.SceneNode.SceneNode.getChildren ( self)
Get the list of direct children

:returns: List of children

◆ getDecorator()

Optional[SceneNodeDecorator] UM.Scene.SceneNode.SceneNode.getDecorator ( self,
type dec_type )
Get SceneNodeDecorators by type.

:param dec_type: type of decorator to return.

◆ getDecorators()

List[SceneNodeDecorator] UM.Scene.SceneNode.SceneNode.getDecorators ( self)
Get all SceneNodeDecorators that decorate this SceneNode.

:return: list of all SceneNodeDecorators.

◆ getDepth()

int UM.Scene.SceneNode.SceneNode.getDepth ( self)
How many nodes is this node removed from the root?

:return: Steps from root (0 means it -is- the root).

◆ getLocalTransformation()

Matrix UM.Scene.SceneNode.SceneNode.getLocalTransformation ( self,
copy = True )
Returns the local transformation with respect to its parent. (from parent to local)

:returns transformation 4x4 (homogeneous) matrix

◆ getMeshData()

Optional[MeshData] UM.Scene.SceneNode.SceneNode.getMeshData ( self)
Get the (original) mesh data from the scene node/object.

:returns: MeshData

◆ getMeshDataTransformed()

Optional[MeshData] UM.Scene.SceneNode.SceneNode.getMeshDataTransformed ( self)
Get the transformed mesh data from the scene node/object, based on the transformation of scene nodes wrt root.

If this node is a group, it will recursively concatenate all child nodes/objects.
:returns: MeshData

◆ getMeshDataTransformedNormals()

Optional[numpy.ndarray] UM.Scene.SceneNode.SceneNode.getMeshDataTransformedNormals ( self)
Get the transformed normals from this scene node/object, based on the transformation of scene nodes wrt root.

If this node is a group, it will recursively concatenate all child nodes/objects.
:return: numpy.ndarray

◆ getMeshDataTransformedVertices()

Optional[numpy.ndarray] UM.Scene.SceneNode.SceneNode.getMeshDataTransformedVertices ( self)
Get the transformed vertices from this scene node/object, based on the transformation of scene nodes wrt root.

If this node is a group, it will recursively concatenate all child nodes/objects.
:return: numpy.ndarray

◆ getOrientation()

Quaternion UM.Scene.SceneNode.SceneNode.getOrientation ( self)
Get the local orientation value.

◆ getParent()

Optional["SceneNode"] UM.Scene.SceneNode.SceneNode.getParent ( self)
Get the parent of this node.

If the node has no parent, it is the root node.

:returns: SceneNode if it has a parent and None if it's the root node.

◆ getPosition()

Vector UM.Scene.SceneNode.SceneNode.getPosition ( self)
Get the local position.

◆ getScale()

Vector UM.Scene.SceneNode.SceneNode.getScale ( self)
Get the local scaling value.

◆ getWorldPosition()

Vector UM.Scene.SceneNode.SceneNode.getWorldPosition ( self)
Get the position of this scene node relative to the world.

◆ getWorldTransformation()

Matrix UM.Scene.SceneNode.SceneNode.getWorldTransformation ( self,
copy = True )
Computes and returns the transformation from world to local space.

:returns: 4x4 transformation matrix

◆ hasDecoration()

bool UM.Scene.SceneNode.SceneNode.hasDecoration ( self,
str function )
Does this SceneNode have a certain Decoration (as defined by a Decorator)
:param :type{string} function the function to check for.

◆ isEnabled()

bool UM.Scene.SceneNode.SceneNode.isEnabled ( self)
Get whether this SceneNode is enabled, that is, it can be modified in any way.

◆ isSelectable()

bool UM.Scene.SceneNode.SceneNode.isSelectable ( self)
Get whether this SceneNode can be selected.

:note This will return false if isEnabled() returns false.

◆ isVisible()

bool UM.Scene.SceneNode.SceneNode.isVisible ( self)
Get the visibility of this node.
The parents visibility overrides the visibility.
TODO: Let renderer actually use the visibility to decide whether to render or not.

◆ lookAt()

None UM.Scene.SceneNode.SceneNode.lookAt ( self,
Vector target,
Vector up = Vector.Unit_Y )
Rotate this scene node in such a way that it is looking at target.

:param target: :type{Vector} The target to look at.
:param up: :type{Vector} The vector to consider up. Defaults to Vector.Unit_Y, i.e. (0, 1, 0).

◆ removeAllChildren()

None UM.Scene.SceneNode.SceneNode.removeAllChildren ( self)
Removes all children and its children's children.

◆ removeChild()

None UM.Scene.SceneNode.SceneNode.removeChild ( self,
"SceneNode" child )
remove a single child

:param child: Scene node that needs to be removed.

◆ removeDecorator()

None UM.Scene.SceneNode.SceneNode.removeDecorator ( self,
type dec_type )
Remove decorator by type.

:param dec_type: type of the decorator to remove.

◆ removeDecorators()

UM.Scene.SceneNode.SceneNode.removeDecorators ( self)
Remove all decorators

◆ render()

bool UM.Scene.SceneNode.SceneNode.render ( self,
renderer )
Can be overridden by child nodes if they need to perform special rendering.
If you need to handle rendering in a special way, for example for tool handles,
you can override this method and render the node. Return True to prevent the
view from rendering any attached mesh data.

:param renderer: The renderer object to use for rendering.

:return: False if the view should render this node, True if we handle our own rendering.

Reimplemented in UM.Scene.Camera.Camera, UM.Scene.Platform.Platform, and UM.Scene.ToolHandle.ToolHandle.

◆ rotate()

None UM.Scene.SceneNode.SceneNode.rotate ( self,
Quaternion rotation,
int transform_space = TransformSpace.Local )
Rotate the scene object (and thus its children) by given amount

:param rotation: :type{Quaternion} A quaternion indicating the amount of rotation.
:param transform_space: The space relative to which to rotate. Can be any one of the constants in SceneNode::TransformSpace.

◆ scale()

None UM.Scene.SceneNode.SceneNode.scale ( self,
Vector scale,
int transform_space = TransformSpace.Local )
Scale the scene object (and thus its children) by given amount

:param scale: :type{Vector} A Vector with three scale values
:param transform_space: The space relative to which to scale. Can be any one of the constants in SceneNode::TransformSpace.

◆ setCalculateBoundingBox()

None UM.Scene.SceneNode.SceneNode.setCalculateBoundingBox ( self,
bool calculate )
Set whether or not to calculate the bounding box for this node.

:param calculate: True if the bounding box should be calculated, False if not.

◆ setCenterPosition()

None UM.Scene.SceneNode.SceneNode.setCenterPosition ( self,
Vector center )
Set the center position of this node.

This is used to modify it's mesh data (and it's children) in such a way that they are centered.
In most cases this means that we use the center of mass as center (which most objects don't use)

◆ setEnabled()

None UM.Scene.SceneNode.SceneNode.setEnabled ( self,
bool enable )
Set whether this SceneNode is enabled.

:param enable: True if this object should be enabled, False if not.
:sa isEnabled

Reimplemented in UM.Scene.ToolHandle.ToolHandle.

◆ setMeshData()

None UM.Scene.SceneNode.SceneNode.setMeshData ( self,
Optional[MeshData] mesh_data )
Set the mesh of this node/object

:param mesh_data: MeshData object

Reimplemented in UM.Scene.Camera.Camera.

◆ setOrientation()

None UM.Scene.SceneNode.SceneNode.setOrientation ( self,
Quaternion orientation,
int transform_space = TransformSpace.Local )
Set the local orientation of this scene node.

:param orientation: :type{Quaternion} The new orientation of this scene node.
:param transform_space: The space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.

◆ setParent()

None UM.Scene.SceneNode.SceneNode.setParent ( self,
Optional["SceneNode"] scene_node )
:brief Set the parent of this object

:param scene_node: SceneNode that is the parent of this object.

◆ setPosition()

None UM.Scene.SceneNode.SceneNode.setPosition ( self,
Vector position,
int transform_space = TransformSpace.Local )
Set the local position value.

:param position: The new position value of the SceneNode.
:param transform_space: The space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.

◆ setScale()

None UM.Scene.SceneNode.SceneNode.setScale ( self,
Vector scale,
int transform_space = TransformSpace.Local )
Set the local scale value.

:param scale: :type{Vector} The new scale value of the scene node.
:param transform_space: The space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.

◆ setSelectable()

None UM.Scene.SceneNode.SceneNode.setSelectable ( self,
bool select )
Set whether this SceneNode can be selected.

:param select: True if this SceneNode should be selectable, False if not.

◆ setVisible()

None UM.Scene.SceneNode.SceneNode.setVisible ( self,
bool visible )
Set the visibility of this SceneNode.

◆ translate()

None UM.Scene.SceneNode.SceneNode.translate ( self,
Vector translation,
int transform_space = TransformSpace.Local )
Translate the scene object (and thus its children) by given amount.

:param translation: :type{Vector} The amount to translate by.
:param transform_space: The space relative to which to translate. Can be any one of the constants in SceneNode::TransformSpace.

The documentation for this class was generated from the following file: