Documentation ¶
Overview ¶
Package hierarchy provides the means to represent a hierarchy of 3D objects.
Index ¶
- func DefaultTransformFunc(node *Node) dprec.Mat4
- type Node
- func (n *Node) AbsoluteMatrix() dprec.Mat4
- func (n *Node) AppendChild(child *Node)
- func (n *Node) AppendSibling(sibling *Node)
- func (n *Node) ApplyFromSource(recursive bool)
- func (n *Node) ApplyToTarget(recursive bool)
- func (n *Node) BaseAbsoluteMatrix() dprec.Mat4
- func (n *Node) Delete()
- func (n *Node) Detach()
- func (n *Node) FindNode(name string) *Node
- func (n *Node) FirstChild() *Node
- func (n *Node) LastChild() *Node
- func (n *Node) LeftSibling() *Node
- func (n *Node) Matrix() dprec.Mat4
- func (n *Node) Name() string
- func (n *Node) Parent() *Node
- func (n *Node) Position() dprec.Vec3
- func (n *Node) PrependChild(child *Node)
- func (n *Node) PrependSibling(sibling *Node)
- func (n *Node) RemoveChild(child *Node)
- func (n *Node) RightSibling() *Node
- func (n *Node) Rotation() dprec.Quat
- func (n *Node) Scale() dprec.Vec3
- func (n *Node) SetAbsoluteMatrix(matrix dprec.Mat4)
- func (n *Node) SetMatrix(matrix dprec.Mat4)
- func (n *Node) SetName(name string)
- func (n *Node) SetPosition(position dprec.Vec3)
- func (n *Node) SetRotation(rotation dprec.Quat)
- func (n *Node) SetScale(scale dprec.Vec3)
- func (n *Node) SetSource(source NodeSource)
- func (n *Node) SetTarget(target NodeTarget)
- func (n *Node) Source() NodeSource
- func (n *Node) Target() NodeTarget
- func (n *Node) UseTransformation(transform TransformFunc)
- type NodeSource
- type NodeTarget
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTransformFunc ¶
DefaultTransformFunc is a TransformFunc that applies standard matrix multiplication rules.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents the transformation of an object or part of one in 3D space.
func (*Node) AbsoluteMatrix ¶
AbsoluteMatrix returns the matrix transformation of this Node relative to the root coordinate system.
func (*Node) AppendChild ¶
AppendChild adds the specified Node as the right-most child of this Node. If the appended Node already has a parent, it is first detached from that parent.
func (*Node) AppendSibling ¶
AppendSibling attaches a Node to the right of the current one.
func (*Node) ApplyFromSource ¶
ApplyFromSource requests that this node be updated based on its source. If recursive is specified, the same is applied down the hierarchy as well.
func (*Node) ApplyToTarget ¶
ApplyToTarget requests that this node be applied to its target. If recursive is specified, the same is applied down the hierarchy as well.
func (*Node) BaseAbsoluteMatrix ¶
BaseAbsoluteMatrix returns the absolute matrix of the parent, if there is one, otherwise the identity matrix.
func (*Node) Delete ¶ added in v0.19.0
func (n *Node) Delete()
Delete removes this Node from the hierarchy and deletes all of its children.
The node can be reused after deletion.
func (*Node) FindNode ¶
FindNode searches the hierarchy starting from this Node (inclusive) for a Node that has the specified name.
func (*Node) FirstChild ¶
FirstChild returns the first (left-most) child Node of this Node. If this Node does not have any children then this method returns nil.
func (*Node) LastChild ¶
LastChild returns the last (right-most) child Node of this Node. If this Node does not have any children then this method returns nil.
func (*Node) LeftSibling ¶
LeftSibling returns the left sibling Node of this Node. If this Node is the left-most child of its parent or does not have a parent then this method returns nil.
func (*Node) Parent ¶
Parent returns the parent Node in the hierarchy. If this is the top-most Node then nil is returned.
func (*Node) PrependChild ¶
PrependChild adds the specified Node as the left-most child of this Node. If the preprended Node already has a parent, it is first detached from that parent.
func (*Node) PrependSibling ¶
PrependSibling attaches a Node to the left of the current one.
func (*Node) RemoveChild ¶
RemoveChild removes the specified Node from the list of children held by this Node. If the specified Node is not a child of this Node, then nothing happens.
func (*Node) RightSibling ¶
RightSibling returns the right sibling Node of this Node. If this Node is the right-most child of its parent or does not have a parent then this method returns nil.
func (*Node) SetAbsoluteMatrix ¶
SetAbsoluteMatrix changes the relative position, rotation and scale of this node based on the specified absolute transformation matrix.
func (*Node) SetMatrix ¶
SetMatrix changes this node's relative transformation th the specified matrix.
func (*Node) SetPosition ¶
SetPosition changes this Node's relative position to the parent.
func (*Node) SetRotation ¶
SetRotation changes this Node's rotation relative to the parent.
func (*Node) SetSource ¶
func (n *Node) SetSource(source NodeSource)
SetSource changes the transformation input for this node.
func (*Node) SetTarget ¶
func (n *Node) SetTarget(target NodeTarget)
SetTarget changes the transformation output for this node.
func (*Node) Source ¶
func (n *Node) Source() NodeSource
Source returns the transformation input for this node.
func (*Node) Target ¶
func (n *Node) Target() NodeTarget
Target returns the transformation output for this node.
func (*Node) UseTransformation ¶
func (n *Node) UseTransformation(transform TransformFunc)
UseTransformation configures a TransformFunc to be used for calculating the absolute matrix of this node. Pass nil to restore the default behavior.
type NodeSource ¶
type NodeSource interface { // ApplyTo requests that any transform be applied to the specified node. ApplyTo(node *Node) // Release indicates that the node has been deleted and the source can be // deleted. Release() }
NodeSource represents an abstraction that is able to apply its transform to a node.
type NodeTarget ¶
type NodeTarget interface { // ApplyFrom requests that the node's transform be applied to the receiver. ApplyFrom(node *Node) // Release indicates that the node has been deleted and the target can be // deleted. Release() }
NodeTarget represents an abstraction that is able to modify its transform based on a node's positioning.
type TransformFunc ¶
TransformFunc is a mechanism to calculate a custom absolute matrix for the node.