eve

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: BSD-3-Clause Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Version     = "v0.50.0"
	GitCommit   = "f250cac"          // the commit JUST BEFORE the release
	VersionDate = "2020-03-16 20:34" // UTC
)

Variables

View Source
var BoxProps = ki.Props{
	"EnumType:Flag": ki.KiT_Flags,
}
View Source
var CapsuleProps = ki.Props{
	"EnumType:Flag": ki.KiT_Flags,
}
View Source
var CylinderProps = ki.Props{
	"EnumType:Flag": ki.KiT_Flags,
}
View Source
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

View Source
var KiT_Box = kit.Types.AddType(&Box{}, BoxProps)
View Source
var KiT_Capsule = kit.Types.AddType(&Capsule{}, CapsuleProps)
View Source
var KiT_Cylinder = kit.Types.AddType(&Cylinder{}, CylinderProps)
View Source
var KiT_Group = kit.Types.AddType(&Group{}, GroupProps)
View Source
var KiT_NodeTypes = kit.Enums.AddEnum(NodeTypesN, kit.NotBitFlag, nil)
View Source
var KiT_Phys = kit.Types.AddType(&Phys{}, PhysProps)
View Source
var KiT_Sphere = kit.Types.AddType(&Sphere{}, SphereProps)
View Source
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

View Source
var SphereProps = ki.Props{
	"EnumType:Flag": ki.KiT_Flags,
}

Functions

func KiToNode

func KiToNode(k ki.Ki) (Node, *NodeBase)

KiToNode converts Ki to a Node interface and a Node3DBase obj -- nil if not.

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

func (bb *BBox) SetBounds(min, max mat32.Vec3)

SetBounds sets BBox from min, max and updates other factors based on that

func (*BBox) UpdateFmBBox

func (bb *BBox) UpdateFmBBox()

UpdateFmBBox updates other values from BBox

func (*BBox) XForm

func (bb *BBox) XForm(q mat32.Quat, pos mat32.Vec3)

XForm transforms bounds with given quat and position offset

type Body

type Body interface {
	Node

	// AsBodyBase returns the body as a BodyBase
	AsBodyBase() *BodyBase
}

Body is the common interface for all body types

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

func (bb *BodyBase) AsBody() Body

func (*BodyBase) AsBodyBase

func (bb *BodyBase) AsBodyBase() *BodyBase

func (*BodyBase) GroupBBox

func (bb *BodyBase) GroupBBox()

func (*BodyBase) NodeType

func (bb *BodyBase) NodeType() NodeTypes

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 AddNewBox

func AddNewBox(parent ki.Ki, name string, pos, size mat32.Vec3) *Box

AddNewBox adds a new box of given name, initial position and size to given parent

func (*Box) InitPhys added in v0.50.0

func (bx *Box) InitPhys(par *NodeBase)

func (*Box) SetBBox

func (bx *Box) SetBBox()

func (*Box) UpdatePhys added in v0.50.0

func (bx *Box) UpdatePhys(par *NodeBase)

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

func AddNewCapsule(parent ki.Ki, name string, pos mat32.Vec3, height, radius float32) *Capsule

AddNewCapsule adds a new capsule of given name, initial position and height, radius to given parent.

func (*Capsule) InitPhys added in v0.50.0

func (cp *Capsule) InitPhys(par *NodeBase)

func (*Capsule) SetBBox

func (cp *Capsule) SetBBox()

func (*Capsule) UpdatePhys added in v0.50.0

func (cp *Capsule) UpdatePhys(par *NodeBase)

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

func AddNewCone(parent ki.Ki, name string, pos mat32.Vec3, height, radius float32) *Cylinder

AddNewCone adds a new cone of given name, initial position and height, radius to given parent.

func AddNewCylinder

func AddNewCylinder(parent ki.Ki, name string, pos mat32.Vec3, height, radius float32) *Cylinder

AddNewCylinder adds a new cylinder of given name, initial position and height, radius to given parent.

func (*Cylinder) InitPhys added in v0.50.0

func (cy *Cylinder) InitPhys(par *NodeBase)

func (*Cylinder) SetBBox

func (cy *Cylinder) SetBBox()

func (*Cylinder) UpdatePhys added in v0.50.0

func (cy *Cylinder) UpdatePhys(par *NodeBase)

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

func AddNewGroup(parent ki.Ki, name string) *Group

AddNewGroup adds a new group of given name to given parent

func (*Group) GroupBBox

func (gp *Group) GroupBBox()

func (*Group) InitPhys added in v0.50.0

func (gp *Group) InitPhys(par *NodeBase)

func (*Group) InitWorld added in v0.50.0

func (gp *Group) InitWorld()

InitWorld does the full tree InitPhys and GroupBBox updates

func (*Group) NodeType

func (gp *Group) NodeType() NodeTypes

func (*Group) UpdatePhys added in v0.50.0

func (gp *Group) UpdatePhys(par *NodeBase)

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

func (nb *NodeBase) AsBody() Body

func (*NodeBase) AsNodeBase

func (nb *NodeBase) AsNodeBase() *NodeBase

func (*NodeBase) InitBase added in v0.50.0

func (nb *NodeBase) InitBase(par *NodeBase)

InitBase is the base-level initialization of basic Phys state from Initial conditions

func (*NodeBase) UpdateBase added in v0.50.0

func (nb *NodeBase) UpdateBase(par *NodeBase)

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

const (
	// note: uppercase required to not conflict with type names
	BODY NodeTypes = iota
	GROUP
	JOINT
	NodeTypesN
)

func (*NodeTypes) FromString

func (i *NodeTypes) FromString(s string) error

func (NodeTypes) String

func (i NodeTypes) String() string

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

func (ps *Phys) EulerRotation() mat32.Vec3

EulerRotation returns the current rotation in Euler angles (degrees).

func (*Phys) EulerRotationRad

func (ps *Phys) EulerRotationRad() mat32.Vec3

EulerRotationRad returns the current rotation in Euler angles (radians).

func (*Phys) MoveOnAxis

func (ps *Phys) MoveOnAxis(x, y, z, dist float32)

MoveOnAxis moves (translates) the specified distance on the specified local axis, relative to the current rotation orientation.

func (*Phys) MoveOnAxisAbs

func (ps *Phys) MoveOnAxisAbs(x, y, z, dist float32)

MoveOnAxisAbs moves (translates) the specified distance on the specified local axis, in absolute X,Y,Z coordinates.

func (*Phys) RotateEuler

func (ps *Phys) RotateEuler(x, y, z float32)

RotateEuler rotates by given Euler angles (in degrees) relative to existing rotation.

func (*Phys) RotateEulerRad

func (ps *Phys) RotateEulerRad(x, y, z, angle float32)

RotateEulerRad rotates by given Euler angles (in radians) relative to existing rotation.

func (*Phys) RotateOnAxis

func (ps *Phys) RotateOnAxis(x, y, z, angle float32)

RotateOnAxis rotates around the specified local axis the specified angle in degrees.

func (*Phys) RotateOnAxisRad

func (ps *Phys) RotateOnAxisRad(x, y, z, angle float32)

RotateOnAxisRad rotates around the specified local axis the specified angle in radians.

func (*Phys) SetAxisRotation

func (ps *Phys) SetAxisRotation(x, y, z, angle float32)

SetAxisRotation sets rotation from local axis and angle in degrees.

func (*Phys) SetAxisRotationRad

func (ps *Phys) SetAxisRotationRad(x, y, z, angle float32)

SetAxisRotationRad sets rotation from local axis and angle in radians.

func (*Phys) SetEulerRotation

func (ps *Phys) SetEulerRotation(x, y, z float32)

SetEulerRotation sets the rotation in Euler angles (degrees).

func (*Phys) SetEulerRotationRad

func (ps *Phys) SetEulerRotationRad(x, y, z float32)

SetEulerRotationRad sets the rotation in Euler angles (radians).

type Sphere

type Sphere struct {
	BodyBase
	Radius float32 `desc:"radius"`
}

Sphere is a spherical body shape.

func AddNewSphere

func AddNewSphere(parent ki.Ki, name string, pos mat32.Vec3, radius float32) *Sphere

AddNewSphere adds a new sphere of given name, initial position and radius.

func (*Sphere) InitPhys added in v0.50.0

func (sp *Sphere) InitPhys(par *NodeBase)

func (*Sphere) SetBBox

func (sp *Sphere) SetBBox()

func (*Sphere) UpdatePhys added in v0.50.0

func (sp *Sphere) UpdatePhys(par *NodeBase)

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

Jump to

Keyboard shortcuts

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