Documentation
¶
Overview ¶
Package mechtree implements a hierarchical tree structure of nodes in 3D space that ultimately form the visual content of a Mechane world.
Index ¶
- Constants
- func Localise(cam Camera) (mech.Depiction, mechoverlayer.Elements)
- func LocaliseDepictions(local *Node) mech.Depiction
- func NewChangeOfFrame(from *Node, to *Node) (maf.Aff, error)
- func NewLocaliser(f func(*Node, maf.Aff)) func(*Node, leafstar.PreviousStep, LocAcc) LocAcc
- type Camera
- type Interframe
- type LocAcc
- type Node
- func (nde *Node) AddChild(child *Node)
- func (nde *Node) AddDepictioner(dpr mech.Depictioner)
- func (nde *Node) AddDepictioners(vd ...mech.Depictioner)
- func (nde *Node) Children() []*Node
- func (nde *Node) Detach()
- func (nde *Node) Get() maf.Frame
- func (nde *Node) GetElement() OverlayElement
- func (nde *Node) IsMe(node *Node) bool
- func (nde *Node) IsRoot() bool
- func (nde *Node) Orient(fr maf.Frame)
- func (nde *Node) Overlay(e OverlayElement)
- func (nde *Node) Parent() *Node
- func (nde *Node) RemoveDepictioner(dpr mech.Depictioner)
- func (nde *Node) Set(fr maf.Frame)
- type OverlayElement
- type OverlayOrientation
- type OverlayOrigin
Constants ¶
const ( Top = OverlayOrigin("top") Bottom = OverlayOrigin("bottom") Left = OverlayOrigin("left") Right = OverlayOrigin("right") Center = OverlayOrigin("center") IconCenter = OverlayOrigin("icon-center") // Useful for a button with an icon. TopLeft = OverlayOrigin("top-left") TopRight = OverlayOrigin("top-right") BottomRight = OverlayOrigin("bottom-right") BottomLeft = OverlayOrigin("bottom-left") )
const ( // Flat does not apply an orientation to the overlay element, it is always // flat on and front facing. Flat = OverlayOrientation(iota) // XY orientation orients the overlay element so it matches the XY-plane // (Z=0) of its in-world frame as seen from the camera. When viewing the // element from the rear of the frame you see the same contents as the front // face but in an unusual right to left order, making it obvious it is the // rear side. XY // XYFront orientation orients the overlay element so it matches the // XY-plane (Z=0) of its in-world frame as seen from the camera, but does // not allow the overlay element's rear face to be seen. When viewing the // element from the rear of the frame the overlay element is rotated around // its in-world frame's Y-axis by 180 degrees. XYFront )
Variables ¶
This section is empty.
Functions ¶
func Localise ¶
func Localise(cam Camera) (mech.Depiction, mechoverlayer.Elements)
Localise the visual components on the tree from their various frames to that of the given camera's frame.
func LocaliseDepictions ¶
LocaliseDepictions on the tree from their various frames to that of the given node's frame.
func NewChangeOfFrame ¶
NewChangeOfFrame transformation from coordinates in the 'from' frame to coordinates in the 'to' frame.
func NewLocaliser ¶
NewLocaliser maps the given function, which expects a localising transformation argument, to a function suitable for use in a leafstar traversal.
A leafstar traversal used in conjunction with the returned function calls the given function for each node: providing the given function with the current node and a change of frame transformation that goes from the current node's frame to the leafstar traversal's start frame.
Types ¶
type Camera ¶
type Camera struct { Inverse maf.Mat4 // Inverse transformation to the lens transformation. Lens maf.Mat4 Name string Node *Node }
A Camera which is attached to a tree node and is used to view the contents of the tree from that node.
The camera is positioned at the origin of the node and looks down its negative Z-axis with the positive Y-axis direction as the 'up' direction.
type Interframe ¶
type Interframe struct { // Transform the coordinates of a point in frame A to its coordinates in // frame B. AToB maf.Aff // Transform the coordinates of a point in frame B to its coordinates in // frame A. BToA maf.Aff }
An Interframe has two change of frame transformations, one for each direction between two frames on a tree.
func NewInterframe ¶
func NewInterframe(a *Node, b *Node) (Interframe, error)
NewInterframe to change coordinates in either direction between the two given nodes on a tree.
type LocAcc ¶
type LocAcc struct {
// contains filtered or unexported fields
}
LocAcc is the accumulator for a localising leafstar traversal.
type Node ¶
type Node struct { sync.Mutex Cashpoint *Node Depictioners map[string]mech.Depictioner maf.Frame Kids []*Node OverlayElement OverlayElement }
A Node with its own coordinate system, a coordinate system which is embedded in (and specified relative to) the coordinate system of its parent node.
For the root node of a Mechane tree with no parent node the position and orientation of its frame are effectively meaningless.
func (*Node) AddChild ¶
AddChild to the receiver node, detaching it from its current parent, if any.
Adding a child is not an atomic operation: the detach is done first as a separate op.
Nothing happens if the child and receiver are the same node.
func (*Node) AddDepictioner ¶
func (nde *Node) AddDepictioner(dpr mech.Depictioner)
AddDepictioner to the node.
func (*Node) AddDepictioners ¶
func (nde *Node) AddDepictioners(vd ...mech.Depictioner)
AddDepictioners to the node.
func (*Node) Detach ¶
func (nde *Node) Detach()
Detach the receiver node from its parent making it the root of its own tree.
func (*Node) Overlay ¶
func (nde *Node) Overlay(e OverlayElement)
Overlay the display area with the given element.
The top left corner of the overlay element will coincide with the origin of the node's frame.
func (*Node) RemoveDepictioner ¶
func (nde *Node) RemoveDepictioner(dpr mech.Depictioner)
RemoveDepictioner from the node.
type OverlayElement ¶
type OverlayElement struct { // The HTML of the overlay element. HTML string // Each overlay element on a tree should have a unique name. Name string // On-screen orientation of an overlay element relative to its in-world // orientation. Orientation OverlayOrientation // Adjust the on-screen position of an overlay element relative to its node. OriginPosition OverlayOrigin // contains filtered or unexported fields }
An OverlayElement attached to a node on a tree.
type OverlayOrientation ¶
type OverlayOrientation int
An OverlayOrientation decides how an overlay element should be oriented on the screen.
The element's on-screen orientation can be made to match its in-world orientation.
type OverlayOrigin ¶
type OverlayOrigin string
An OverlayOrigin specifies which part of the overlay element coincides with the node's onscreen origin.