eve2d

package
v2.0.0-dev0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type View

type View struct {

	// width of lines for shape rendering, in normalized units
	LineWidth float32

	// projection matrix for converting 3D to 2D -- resulting X, Y coordinates are used from Vector3
	Prjn math32.Matrix4

	// the root Group node of the virtual world
	World *eve.Group

	// the SVG rendering canvas for visualizing in 2D
	Scene *svg.SVG

	// the root Group node in the Scene under which the world is rendered
	Root *svg.Group

	// library of shapes for bodies -- name matches Body.Vis
	Library map[string]*svg.Group
}

View connects a Virtual World with a 2D SVG Scene to visualize the world

func NewView

func NewView(world *eve.Group, sc *svg.SVG, root *svg.Group) *View

NewView returns a new View that links given world with given scene and root group

func (*View) AddFromLibrary

func (vw *View) AddFromLibrary(nm string, gp *svg.Group)

AddFromLibrary adds shape from library to given group

func (*View) ConfigBodyShape

func (vw *View) ConfigBodyShape(bod eve.Body, shp svg.Node)

ConfigBodyShape configures a shape for a body with current values

func (*View) ConfigView

func (vw *View) ConfigView(wn eve.Node, vn svg.Node)

ConfigView configures the view node to properly display world node

func (*View) Image

func (vw *View) Image() (*image.RGBA, error)

Image returns the current rendered image

func (*View) InitLibShape

func (vw *View) InitLibShape(bod eve.Body)

InitLibShape initializes Scene library with basic shape for given body

func (*View) InitLibrary

func (vw *View) InitLibrary()

InitLibrary initializes Scene library with basic shapes based on bodies in the virtual world. More complex visualizations can be configured after this.

func (*View) InitLibraryBody

func (vw *View) InitLibraryBody(wn eve.Node)

InitLibraryBody initializes Scene library with basic shapes based on bodies in the virtual world. More complex visualizations can be configured after this.

func (*View) NewInLibrary

func (vw *View) NewInLibrary(nm string) *svg.Group

NewInLibrary adds a new item of given name in library

func (*View) Prjn2D

func (vw *View) Prjn2D(pos math32.Vector3) math32.Vector2

Prjn2D projects position from 3D to 2D

func (*View) ProjectXY

func (vw *View) ProjectXY()

ProjectXY sets 2D projection to reflect 3D X,Y coords

func (*View) ProjectXZ

func (vw *View) ProjectXZ()

ProjectXZ sets 2D projection to reflect 3D X,Z coords

func (*View) Sync

func (vw *View) Sync() bool

Sync synchronizes the view to the world

func (*View) SyncNode

func (vw *View) SyncNode(wn eve.Node, vn svg.Node) bool

SyncNode updates the view tree to match the world tree, using ConfigChildren to maximally preserve existing tree elements returns true if view tree was modified (elements added / removed etc)

func (*View) Transform2D

func (vw *View) Transform2D(phys *eve.Phys) math32.Matrix2

Transform2D returns the full 2D transform matrix for a given position and quat rotation in 3D

func (*View) UpdateBodyView

func (vw *View) UpdateBodyView(bodyNames []string)

UpdateBodyView updates the display properties of given body name recurses the tree until this body name is found.

func (*View) UpdateBodyViewNode

func (vw *View) UpdateBodyViewNode(bodyNames []string, wn eve.Node, vn svg.Node)

UpdateBodyViewNode updates the body view info for given name(s) Essential that both trees are already synchronized.

func (*View) UpdatePose

func (vw *View) UpdatePose()

UpdatePose updates the view pose values only from world tree. Essential that both trees are already synchronized.

func (*View) UpdatePoseNode

func (vw *View) UpdatePoseNode(wn eve.Node, vn svg.Node)

UpdatePoseNode updates the view pose values only from world tree. Essential that both trees are already synchronized.

Jump to

Keyboard shortcuts

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