Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Scene.SceneNode.SceneNode Class Reference

A scene node object. More...

Inheritance diagram for UM.Scene.SceneNode.SceneNode:
UM.Scene.Camera.Camera UM.Scene.Platform.Platform UM.Scene.ToolHandle.ToolHandle

Public Member Functions

 __init__ (self, Optional["SceneNode"] parent=None, **kwargs)
 Construct a scene node.
 
 __deepcopy__ (self, memo)
 
 setCenterPosition (self, Vector center)
 Set the center position of this node.
 
Optional["SceneNode"] getParent (self)
 Get the parent of this node.
 
Vector getMirror (self)
 
Vector setMirror (self, vector)
 
Optional[MeshDatagetBoundingBoxMesh (self)
 Get the MeshData of the bounding box.
 
 calculateBoundingBoxMesh (self)
 (re)Calculate the bounding box mesh.
 
 addDecorator (self, SceneNodeDecorator decorator)
 Add a SceneNodeDecorator to this SceneNode.
 
List[SceneNodeDecoratorgetDecorators (self)
 Get all SceneNodeDecorators that decorate this SceneNode.
 
Optional[SceneNodeDecoratorgetDecorator (self, dec_type)
 Get SceneNodeDecorators by type.
 
 removeDecorators (self)
 Remove all decorators.
 
 removeDecorator (self, SceneNodeDecorator dec_type)
 Remove decorator by type.
 
 callDecoration (self, str function, *args, **kwargs)
 Call a decoration of this SceneNode.
 
bool hasDecoration (self, str function)
 Does this SceneNode have a certain Decoration (as defined by a Decorator)
 
str getName (self)
 
 setName (self, str name)
 
int getDepth (self)
 How many nodes is this node removed from the root?
 
 setParent (self, Optional["SceneNode"] scene_node)
 Set the parent of this object.
 
bool isVisible (self)
 Get the visibility of this node.
 
 setVisible (self, bool visible)
 Set the visibility of this SceneNode.
 
Optional[MeshDatagetMeshData (self)
 Get the (original) mesh data from the scene node/object.
 
Optional[MeshDatagetMeshDataTransformed (self)
 Get the transformed mesh data from the scene node/object, based on the transformation of scene nodes wrt root.
 
numpy.ndarray getMeshDataTransformedVertices (self)
 Get the transformed vertices from this scene node/object, based on the transformation of scene nodes wrt root.
 
numpy.ndarray getMeshDataTransformedNormals (self)
 Get the transformed normals from this scene node/object, based on the transformation of scene nodes wrt root.
 
 setMeshData (self, Optional[MeshData] mesh_data)
 Set the mesh of this node/object.
 
 addChild (self, "SceneNode" scene_node)
 Add a child to this node and set it's parent as this node.
 
 removeChild (self, "SceneNode" child)
 remove a single child
 
 removeAllChildren (self)
 Removes all children and its children's children.
 
List["SceneNode"] getChildren (self)
 Get the list of direct children.
 
bool hasChildren (self)
 
List["SceneNode"] getAllChildren (self)
 Get list of all children (including it's children children children etc.)
 
Matrix getWorldTransformation (self)
 Computes and returns the transformation from world to local space.
 
Matrix getLocalTransformation (self)
 Returns the local transformation with respect to its parent.
 
 setTransformation (self, Matrix transformation)
 
Quaternion getOrientation (self)
 Get the local orientation value.
 
Quaternion getWorldOrientation (self)
 
 rotate (self, Quaternion rotation, int transform_space=TransformSpace.Local)
 Rotate the scene object (and thus its children) by given amount.
 
 setOrientation (self, Quaternion orientation, int transform_space=TransformSpace.Local)
 Set the local orientation of this scene node.
 
Vector getScale (self)
 Get the local scaling value.
 
Vector getWorldScale (self)
 
 scale (self, Vector scale, int transform_space=TransformSpace.Local)
 Scale the scene object (and thus its children) by given amount.
 
 setScale (self, Vector scale, int transform_space=TransformSpace.Local)
 Set the local scale value.
 
Vector getPosition (self)
 Get the local position.
 
Vector getWorldPosition (self)
 Get the position of this scene node relative to the world.
 
 translate (self, Vector translation, int transform_space=TransformSpace.Local)
 Translate the scene object (and thus its children) by given amount.
 
 setPosition (self, Vector position, int transform_space=TransformSpace.Local)
 Set the local position value.
 
 lookAt (self, Vector target, Vector up=Vector.Unit_Y)
 Rotate this scene node in such a way that it is looking at target.
 
 LOG_MATRIX (self, str_matrix_name, matrix)
 Can be overridden by child nodes if they need to perform special rendering.
 
bool render (self, renderer)
 
bool isEnabled (self)
 Get whether this SceneNode is enabled, that is, it can be modified in any way.
 
 setEnabled (self, bool enable)
 Set whether this SceneNode is enabled.
 
bool isSelectable (self)
 Get whether this SceneNode can be selected.
 
 setSelectable (self, bool select)
 Set whether this SceneNode can be selected.
 
Optional[AxisAlignedBoxgetBoundingBox (self)
 Get the bounding box of this node and its children.
 
 setCalculateBoundingBox (self, bool calculate)
 Set whether or not to calculate the bounding box for this node.
 
Vector getShear (self)
 
str getSetting (self, str key, str default_value="")
 
 setSetting (self, str key, str value)
 
 __str__ (self)
 String output for debugging.
 

Public Attributes

 calculateBoundingBoxMesh
 Signals.
 

Static Public Attributes

 decoratorsChanged = Signal()
 Signal for when a SceneNodeDecorator is added / removed.
 
 parentChanged = Signal()
 Emitted whenever the parent changes.
 
 meshDataChanged = Signal()
 Emitted whenever the attached mesh data object changes.
 
 childrenChanged = Signal()
 Emitted whenever the list of children of this object or any child object changes.
 
 transformationChanged = Signal()
 Signal.
 
 boundingBoxChanged = Signal()
 

Protected Member Functions

 _onParentChanged (self, Optional["SceneNode"] node)
 Handler for the ParentChanged signal.
 
 _onMeshDataChanged (self)
 
 _transformChanged (self)
 private:
 
 _updateTransformation (self)
 
 _resetAABB (self)
 
 _calculateAABB (self)
 

Protected Attributes

 _children
 
 _mesh_data
 
 _transformation
 
 _position
 
 _scale
 
 _shear
 
 _mirror
 
 _orientation
 
 _rotationX
 
 _rotationY
 
 _rotationZ
 
 _world_transformation
 
 _derived_position
 
 _derived_orientation
 
 _derived_scale
 
 _parent
 
 _enabled
 
 _selectable
 
 _calculate_aabb
 
 _aabb
 
 _bounding_box_mesh
 
 _visible
 
 _name
 
 _decorators
 
 _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.

See also
SceneNodeDecorator
Todo:
Add unit testing

Constructor & Destructor Documentation

◆ __init__()

UM.Scene.SceneNode.SceneNode.__init__ (   self,
Optional["SceneNode"]   parent = None,
**  kwargs 
)

Construct a scene node.

Parameters
parentThe parent of this node (if any). Only a root node should have None as a parent.
kwargsKeyword arguments. Possible keywords:
  • visible bool Is the SceneNode (and thus, all it's children) visible? Defaults to True
  • name string Name of the SceneNode. Defaults to empty string.

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

Member Function Documentation

◆ _onParentChanged()

UM.Scene.SceneNode.SceneNode._onParentChanged (   self,
Optional["SceneNode"]  node 
)
protected

Handler for the ParentChanged signal.

Parameters
nodeNode from which this event was triggered.

◆ addChild()

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()

UM.Scene.SceneNode.SceneNode.addDecorator (   self,
SceneNodeDecorator  decorator 
)

Add a SceneNodeDecorator to this SceneNode.

Parameters
<em>SceneNodeDecorator</em>decorator The decorator to add.

◆ callDecoration()

UM.Scene.SceneNode.SceneNode.callDecoration (   self,
str  function,
args,
**  kwargs 
)

Call a decoration of this SceneNode.

SceneNodeDecorators add Decorations, which are callable functions.

Parameters
<em>string</em>function The function to be called.
*args
**kwargs

◆ 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'

◆ getBoundingBoxMesh()

Optional[MeshData] UM.Scene.SceneNode.SceneNode.getBoundingBoxMesh (   self)

Get the MeshData of the bounding box.

Returns
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,
  dec_type 
)

Get SceneNodeDecorators by type.

Parameters
dec_typetype of decorator to return.

◆ getDecorators()

List[SceneNodeDecorator] UM.Scene.SceneNode.SceneNode.getDecorators (   self)

Get all SceneNodeDecorators that decorate this SceneNode.

Returns
list of all SceneNodeDecorators.

◆ getDepth()

int UM.Scene.SceneNode.SceneNode.getDepth (   self)

How many nodes is this node removed from the root?

Returns
|tupe{int} Steps from root (0 means it -is- the root).

◆ getLocalTransformation()

Matrix UM.Scene.SceneNode.SceneNode.getLocalTransformation (   self)

Returns the local transformation with respect to its parent.

(from parent to local) \retuns transformation 4x4 (homogenous) 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()

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.

Returns
numpy.ndarray

◆ getMeshDataTransformedVertices()

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.

Returns
numpy.ndarray

◆ 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.

◆ getWorldTransformation()

Matrix UM.Scene.SceneNode.SceneNode.getWorldTransformation (   self)

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)

Parameters
<em>string</em>function the function to check for.

◆ 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.

◆ LOG_MATRIX()

UM.Scene.SceneNode.SceneNode.LOG_MATRIX (   self,
  str_matrix_name,
  matrix 
)

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.

Parameters
rendererThe renderer object to use for rendering.
Returns
False if the view should render this node, True if we handle our own rendering.

◆ lookAt()

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.

Parameters
targetVector The target to look at.
upVector The vector to consider up. Defaults to Vector.Unit_Y, i.e. (0, 1, 0).

◆ removeChild()

UM.Scene.SceneNode.SceneNode.removeChild (   self,
"SceneNode"  child 
)

remove a single child

Parameters
childScene node that needs to be removed.

◆ removeDecorator()

UM.Scene.SceneNode.SceneNode.removeDecorator (   self,
SceneNodeDecorator  dec_type 
)

Remove decorator by type.

Parameters
dec_typetype of the decorator to remove.

◆ rotate()

UM.Scene.SceneNode.SceneNode.rotate (   self,
Quaternion  rotation,
int   transform_space = TransformSpace.Local 
)

Rotate the scene object (and thus its children) by given amount.

Parameters
rotationQuaternion A quaternion indicating the amount of rotation.
transform_spaceThe space relative to which to rotate. Can be any one of the constants in SceneNode::TransformSpace.

◆ scale()

UM.Scene.SceneNode.SceneNode.scale (   self,
Vector  scale,
int   transform_space = TransformSpace.Local 
)

Scale the scene object (and thus its children) by given amount.

Parameters
scaleVector A Vector with three scale values
transform_spaceThe space relative to which to scale. Can be any one of the constants in SceneNode::TransformSpace.

◆ setCalculateBoundingBox()

UM.Scene.SceneNode.SceneNode.setCalculateBoundingBox (   self,
bool  calculate 
)

Set whether or not to calculate the bounding box for this node.

Parameters
calculateTrue if the bounding box should be calculated, False if not.

◆ setCenterPosition()

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()

UM.Scene.SceneNode.SceneNode.setEnabled (   self,
bool  enable 
)

Set whether this SceneNode is enabled.

Parameters
enableTrue if this object should be enabled, False if not.
See also
isEnabled

◆ setMeshData()

UM.Scene.SceneNode.SceneNode.setMeshData (   self,
Optional[MeshData mesh_data 
)

Set the mesh of this node/object.

Parameters
mesh_dataMeshData object

Reimplemented in UM.Scene.Camera.Camera.

◆ setOrientation()

UM.Scene.SceneNode.SceneNode.setOrientation (   self,
Quaternion  orientation,
int   transform_space = TransformSpace.Local 
)

Set the local orientation of this scene node.

Parameters
orientationQuaternion The new orientation of this scene node.
transform_spaceThe space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.

◆ setParent()

UM.Scene.SceneNode.SceneNode.setParent (   self,
Optional["SceneNode"]  scene_node 
)

Set the parent of this object.

Parameters
scene_nodeSceneNode that is the parent of this object.

◆ setPosition()

UM.Scene.SceneNode.SceneNode.setPosition (   self,
Vector  position,
int   transform_space = TransformSpace.Local 
)

Set the local position value.

Parameters
positionThe new position value of the SceneNode.
transform_spaceThe space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.

◆ setScale()

UM.Scene.SceneNode.SceneNode.setScale (   self,
Vector  scale,
int   transform_space = TransformSpace.Local 
)

Set the local scale value.

Parameters
scaleVector The new scale value of the scene node.
transform_spaceThe space relative to which to rotate. Can be Local or World from SceneNode::TransformSpace.

◆ setSelectable()

UM.Scene.SceneNode.SceneNode.setSelectable (   self,
bool  select 
)

Set whether this SceneNode can be selected.

Parameters
selectTrue if this SceneNode should be selectable, False if not.

◆ translate()

UM.Scene.SceneNode.SceneNode.translate (   self,
Vector  translation,
int   transform_space = TransformSpace.Local 
)

Translate the scene object (and thus its children) by given amount.

Parameters
translationVector The amount to translate by.
transform_spaceThe space relative to which to translate. Can be any one of the constants in SceneNode::TransformSpace.

Member Data Documentation

◆ childrenChanged

UM.Scene.SceneNode.SceneNode.childrenChanged = Signal()
static

Emitted whenever the list of children of this object or any child object changes.

Parameters
objectThe object that triggered the change.

◆ transformationChanged

UM.Scene.SceneNode.SceneNode.transformationChanged = Signal()
static

Signal.

Emitted whenever the transformation of this object or any child object changes.

Parameters
objectThe object that caused the change.

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