hierarchy

package
v0.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package hierarchy provides the means to represent a hierarchy of 3D objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultTransformFunc

func DefaultTransformFunc(node *Node) dprec.Mat4

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 NewNode

func NewNode() *Node

NewNode creates a new detached Node instance.

func (*Node) AbsoluteMatrix

func (n *Node) AbsoluteMatrix() dprec.Mat4

AbsoluteMatrix returns the matrix transformation of this Node relative to the root coordinate system.

func (*Node) AppendChild

func (n *Node) AppendChild(child *Node)

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

func (n *Node) AppendSibling(sibling *Node)

AppendSibling attaches a Node to the right of the current one.

func (*Node) ApplyFromSource

func (n *Node) ApplyFromSource(recursive bool)

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

func (n *Node) ApplyToTarget(recursive bool)

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

func (n *Node) BaseAbsoluteMatrix() dprec.Mat4

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

func (n *Node) Detach()

Detach removes this Node from the hierarchy.

func (*Node) FindNode

func (n *Node) FindNode(name string) *Node

FindNode searches the hierarchy starting from this Node (inclusive) for a Node that has the specified name.

func (*Node) FirstChild

func (n *Node) FirstChild() *Node

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

func (n *Node) LastChild() *Node

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

func (n *Node) LeftSibling() *Node

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

func (n *Node) Matrix() dprec.Mat4

Matrix returns the matrix transformation of this Node relative to the parent.

func (*Node) Name

func (n *Node) Name() string

Name returns this Node's name.

func (*Node) Parent

func (n *Node) Parent() *Node

Parent returns the parent Node in the hierarchy. If this is the top-most Node then nil is returned.

func (*Node) Position

func (n *Node) Position() dprec.Vec3

Position returns this Node's relative position to the parent.

func (*Node) PrependChild

func (n *Node) PrependChild(child *Node)

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

func (n *Node) PrependSibling(sibling *Node)

PrependSibling attaches a Node to the left of the current one.

func (*Node) RemoveChild

func (n *Node) RemoveChild(child *Node)

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

func (n *Node) RightSibling() *Node

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

func (n *Node) Rotation() dprec.Quat

Rotation returns this Node's rotation relative to the parent.

func (*Node) Scale

func (n *Node) Scale() dprec.Vec3

Scale returns this Node's scale relative to the parent.

func (*Node) SetAbsoluteMatrix

func (n *Node) SetAbsoluteMatrix(matrix dprec.Mat4)

SetAbsoluteMatrix changes the relative position, rotation and scale of this node based on the specified absolute transformation matrix.

func (*Node) SetMatrix

func (n *Node) SetMatrix(matrix dprec.Mat4)

SetMatrix changes this node's relative transformation th the specified matrix.

func (*Node) SetName

func (n *Node) SetName(name string)

SetName changes this Node's name.

func (*Node) SetPosition

func (n *Node) SetPosition(position dprec.Vec3)

SetPosition changes this Node's relative position to the parent.

func (*Node) SetRotation

func (n *Node) SetRotation(rotation dprec.Quat)

SetRotation changes this Node's rotation relative to the parent.

func (*Node) SetScale

func (n *Node) SetScale(scale dprec.Vec3)

SetScale changes this Node's scale 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

type TransformFunc func(node *Node) dprec.Mat4

TransformFunc is a mechanism to calculate a custom absolute matrix for the node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL