Documentation ¶
Index ¶
- Constants
- Variables
- func KiToNode(k ki.Ki) (Node, *NodeBase)
- type BBox
- type Body
- type BodyBase
- type Box
- type Capsule
- type Cylinder
- type Group
- type Node
- type NodeBase
- type NodeTypes
- type Phys
- func (ps *Phys) Defaults()
- func (ps *Phys) EulerRotation() mat32.Vec3
- func (ps *Phys) EulerRotationRad() mat32.Vec3
- func (ps *Phys) MoveOnAxis(x, y, z, dist float32)
- func (ps *Phys) MoveOnAxisAbs(x, y, z, dist float32)
- func (ps *Phys) RotateEuler(x, y, z float32)
- func (ps *Phys) RotateEulerRad(x, y, z, angle float32)
- func (ps *Phys) RotateOnAxis(x, y, z, angle float32)
- func (ps *Phys) RotateOnAxisRad(x, y, z, angle float32)
- func (ps *Phys) SetAxisRotation(x, y, z, angle float32)
- func (ps *Phys) SetAxisRotationRad(x, y, z, angle float32)
- func (ps *Phys) SetEulerRotation(x, y, z float32)
- func (ps *Phys) SetEulerRotationRad(x, y, z float32)
- type Sphere
- type Surface
Constants ¶
const ( Version = "v0.50.0" GitCommit = "f250cac" // the commit JUST BEFORE the release VersionDate = "2020-03-16 20:34" // UTC )
Variables ¶
var BoxProps = ki.Props{ "EnumType:Flag": ki.KiT_Flags, }
var CapsuleProps = ki.Props{ "EnumType:Flag": ki.KiT_Flags, }
var CylinderProps = ki.Props{ "EnumType:Flag": ki.KiT_Flags, }
var GroupProps = ki.Props{ "EnumType:Flag": ki.KiT_Flags, "ToolBar": ki.PropSlice{ {"InitWorld", ki.Props{ "desc": "initialize all elements in the world.", "icon": "reset", }}, }, }
GroupProps define the ToolBar and MenuBar for StructView
var KiT_Box = kit.Types.AddType(&Box{}, BoxProps)
var KiT_Capsule = kit.Types.AddType(&Capsule{}, CapsuleProps)
var KiT_Cylinder = kit.Types.AddType(&Cylinder{}, CylinderProps)
var KiT_Group = kit.Types.AddType(&Group{}, GroupProps)
var KiT_NodeTypes = kit.Enums.AddEnum(NodeTypesN, kit.NotBitFlag, nil)
var KiT_Phys = kit.Types.AddType(&Phys{}, PhysProps)
var KiT_Sphere = kit.Types.AddType(&Sphere{}, SphereProps)
var PhysProps = ki.Props{ "EnumType:Flag": ki.KiT_Flags, "ToolBar": ki.PropSlice{ {"SetEulerRotation", ki.Props{ "desc": "Set the local rotation (relative to parent) using Euler angles, in degrees.", "icon": "rotate-3d", "Args": ki.PropSlice{ {"Pitch", ki.Props{ "desc": "rotation up / down along the X axis (in the Y-Z plane), e.g., the altitude (climbing, descending) for motion along the Z depth axis", }}, {"Yaw", ki.Props{ "desc": "rotation along the Y axis (in the horizontal X-Z plane), e.g., the bearing or direction for motion along the Z depth axis", }}, {"Roll", ki.Props{ "desc": "rotation along the Z axis (in the X-Y plane), e.g., the bank angle for motion along the Z depth axis", }}, }, }}, {"SetAxisRotation", ki.Props{ "desc": "Set the local rotation (relative to parent) using Axis about which to rotate, and the angle.", "icon": "rotate-3d", "Args": ki.PropSlice{ {"X", ki.BlankProp{}}, {"Y", ki.BlankProp{}}, {"Z", ki.BlankProp{}}, {"Angle", ki.BlankProp{}}, }, }}, {"RotateEuler", ki.Props{ "desc": "rotate (relative to current rotation) using Euler angles, in degrees.", "icon": "rotate-3d", "Args": ki.PropSlice{ {"Pitch", ki.Props{ "desc": "rotation up / down along the X axis (in the Y-Z plane), e.g., the altitude (climbing, descending) for motion along the Z depth axis", }}, {"Yaw", ki.Props{ "desc": "rotation along the Y axis (in the horizontal X-Z plane), e.g., the bearing or direction for motion along the Z depth axis", }}, {"Roll", ki.Props{ "desc": "rotation along the Z axis (in the X-Y plane), e.g., the bank angle for motion along the Z depth axis", }}, }, }}, {"RotateOnAxis", ki.Props{ "desc": "Rotate (relative to current rotation) using Axis about which to rotate, and the angle.", "icon": "rotate-3d", "Args": ki.PropSlice{ {"X", ki.BlankProp{}}, {"Y", ki.BlankProp{}}, {"Z", ki.BlankProp{}}, {"Angle", ki.BlankProp{}}, }, }}, {"EulerRotation", ki.Props{ "desc": "The local rotation (relative to parent) in Euler angles in degrees (X = Pitch, Y = Yaw, Z = Roll)", "icon": "rotate-3d", "show-return": "true", }}, {"sep-rot", ki.BlankProp{}}, {"MoveOnAxis", ki.Props{ "desc": "Move given distance on given X,Y,Z axis relative to current rotation orientation.", "icon": "pan", "Args": ki.PropSlice{ {"X", ki.BlankProp{}}, {"Y", ki.BlankProp{}}, {"Z", ki.BlankProp{}}, {"Dist", ki.BlankProp{}}, }, }}, {"MoveOnAxisAbs", ki.Props{ "desc": "Move given distance on given X,Y,Z axis in absolute coords, not relative to current rotation orientation.", "icon": "pan", "Args": ki.PropSlice{ {"X", ki.BlankProp{}}, {"Y", ki.BlankProp{}}, {"Z", ki.BlankProp{}}, {"Dist", ki.BlankProp{}}, }, }}, }, }
PhysProps define the ToolBar and MenuBar for StructView
var SphereProps = ki.Props{ "EnumType:Flag": ki.KiT_Flags, }
Functions ¶
Types ¶
type BBox ¶
type BBox struct { BBox mat32.Box3 `desc:"bounding box in local coords"` BSphere mat32.Sphere `desc:"bounding sphere in local coords"` Area float32 `desc:"area"` Volume float32 `desc:"volume"` }
BBox contains bounding box and other gross object properties
func (*BBox) UpdateFmBBox ¶
func (bb *BBox) UpdateFmBBox()
UpdateFmBBox updates other values from BBox
type BodyBase ¶
type BodyBase struct { NodeBase Surf Surface `desc:"surface properties, including friction and bouncyness"` Vis string `desc:"visualization name -- looks up an entry in the scene library that provides the visual representation of this body"` Color string `desc:"default color of body for basic InitLibrary configuration"` }
BodyBase is the base type for all specific Body types
func (*BodyBase) AsBodyBase ¶
type Box ¶
type Box struct { BodyBase Size mat32.Vec3 `desc:"size of box in each dimension (units arbitrary, as long as they are all consistent -- meters is typical)"` }
Box is a box body shape
func (*Box) UpdatePhys ¶ added in v0.50.0
type Capsule ¶
type Capsule struct { BodyBase Height float32 `desc:"height of the cylinder portion of the capsule"` TopRad float32 `desc:"radius of the top hemisphere"` BotRad float32 `desc:"radius of the bottom hemisphere"` }
Capsule is a generalized cylinder body shape, with hemispheres at each end, with separate radii for top and bottom.
func AddNewCapsule ¶
AddNewCapsule adds a new capsule of given name, initial position and height, radius to given parent.
func (*Capsule) UpdatePhys ¶ added in v0.50.0
type Cylinder ¶
type Cylinder struct { BodyBase Height float32 `desc:"height of the cylinder"` TopRad float32 `desc:"radius of the top -- set to 0 for a cone"` BotRad float32 `desc:"radius of the bottom"` }
Cylinder is a generalized cylinder body shape, with separate radii for top and bottom. A cone has a zero radius at one end.
func AddNewCone ¶
AddNewCone adds a new cone of given name, initial position and height, radius to given parent.
func AddNewCylinder ¶
AddNewCylinder adds a new cylinder of given name, initial position and height, radius to given parent.
func (*Cylinder) UpdatePhys ¶ added in v0.50.0
type Group ¶
type Group struct {
NodeBase
}
Group is a container of bodies, joints, or other groups it should be used strategically to partition the space and its BBox is used to optimize tree-based collision detection. Use a group for the top-level World node as well.
func AddNewGroup ¶
AddNewGroup adds a new group of given name to given parent
func (*Group) InitWorld ¶ added in v0.50.0
func (gp *Group) InitWorld()
InitWorld does the full tree InitPhys and GroupBBox updates
func (*Group) UpdatePhys ¶ added in v0.50.0
func (*Group) UpdateWorld ¶ added in v0.50.0
func (gp *Group) UpdateWorld()
UpdateWorld does the full tree UpdatePhys and GroupBBox updates
type Node ¶
type Node interface { ki.Ki // NodeType returns the type of node this is (Body, Group, Joint) NodeType() NodeTypes // AsNodeBase returns a generic NodeBase for our node -- gives generic // access to all the base-level data structures without needing interface methods. AsNodeBase() *NodeBase // AsBody returns a generic Body interface for our node -- nil if not a Body AsBody() Body // InitPhys sets current physical state parameters from Initial values // which are local, relative to parent -- is passed the parent (nil = top). // Body nodes should also set their bounding boxes. // called in a FuncDownMeFirst traversal. InitPhys(par *NodeBase) // GroupBBox sets bounding boxes for groups based on groups or bodies. // called in a FuncDownMeLast traversal. GroupBBox() // UpdatePhys updates current world physical state parameters based on propagated // updates from higher levels -- is passed the parent (nil = top). // Body nodes should also update their bounding boxes. // called in a FuncDownMeFirst traversal. UpdatePhys(par *NodeBase) }
Node is the common interface for all eve nodes
type NodeBase ¶
type NodeBase struct { ki.Node Initial Phys `view:"inline" desc:"initial position, orientation, velocity in *local* coordinates (relative to parent)"` Rel Phys `` /* 143-byte string literal not displayed */ Abs Phys `inactive:"+" view:"inline" desc:"current absolute (world) position, orientation, velocity"` Mass float32 `desc:"mass of body or aggregate mass of group of bodies (just fyi for groups) -- 0 mass = no dynamics"` BBox BBox `desc:"bounding box in world coordinates (aggregated for groups)"` }
NodeBase is the basic eve node, which has position, rotation, velocity and computed bounding boxes, etc. There are only three different kinds of Nodes: Group, Body, and Joint
func (*NodeBase) AsNodeBase ¶
func (*NodeBase) InitBase ¶ added in v0.50.0
InitBase is the base-level initialization of basic Phys state from Initial conditions
func (*NodeBase) UpdateBase ¶ added in v0.50.0
UpdateBase is the base-level update of Phys state based on current relative values
type NodeTypes ¶
type NodeTypes int
NodeTypes is a list of node types
func (*NodeTypes) FromString ¶
type Phys ¶
type Phys struct { Pos mat32.Vec3 `desc:"position of center of mass of object"` Quat mat32.Quat `desc:"rotation specified as a Quat"` LinVel mat32.Vec3 `desc:"linear velocity"` AngVel mat32.Vec3 `desc:"angular velocity"` }
Phys contains the full specification of a given object's physical properties including position, orientation, velocity.
func (*Phys) Defaults ¶
func (ps *Phys) Defaults()
Defaults sets defaults only if current values are nil
func (*Phys) EulerRotation ¶
EulerRotation returns the current rotation in Euler angles (degrees).
func (*Phys) EulerRotationRad ¶
EulerRotationRad returns the current rotation in Euler angles (radians).
func (*Phys) MoveOnAxis ¶
MoveOnAxis moves (translates) the specified distance on the specified local axis, relative to the current rotation orientation.
func (*Phys) MoveOnAxisAbs ¶
MoveOnAxisAbs moves (translates) the specified distance on the specified local axis, in absolute X,Y,Z coordinates.
func (*Phys) RotateEuler ¶
RotateEuler rotates by given Euler angles (in degrees) relative to existing rotation.
func (*Phys) RotateEulerRad ¶
RotateEulerRad rotates by given Euler angles (in radians) relative to existing rotation.
func (*Phys) RotateOnAxis ¶
RotateOnAxis rotates around the specified local axis the specified angle in degrees.
func (*Phys) RotateOnAxisRad ¶
RotateOnAxisRad rotates around the specified local axis the specified angle in radians.
func (*Phys) SetAxisRotation ¶
SetAxisRotation sets rotation from local axis and angle in degrees.
func (*Phys) SetAxisRotationRad ¶
SetAxisRotationRad sets rotation from local axis and angle in radians.
func (*Phys) SetEulerRotation ¶
SetEulerRotation sets the rotation in Euler angles (degrees).
func (*Phys) SetEulerRotationRad ¶
SetEulerRotationRad sets the rotation in Euler angles (radians).
type Sphere ¶
Sphere is a spherical body shape.
func AddNewSphere ¶
AddNewSphere adds a new sphere of given name, initial position and radius.
func (*Sphere) UpdatePhys ¶ added in v0.50.0
type Surface ¶ added in v0.50.0
type Surface struct { Friction float32 `desc:"coulomb friction coefficient (mu). 0 = frictionless, 1e22 = infinity = no slipping"` Bounce float32 `desc:"(0-1) how bouncy is the surface (0 = hard, 1 = maximum bouncyness)"` }
Surface defines the physical surface properties of bodies