game

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: MIT Imports: 19 Imported by: 5 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("resource not found")
	ErrStillLoading = errors.New("resource still loading")
)

Functions

func DefaultTransformFunc added in v0.9.0

func DefaultTransformFunc(parent, current dprec.Mat4) dprec.Mat4

DefaultTransformFunc is a TransformFunc that applies standard matrix multiplication rules.

Types

type Animation added in v0.9.0

type Animation struct {
	// contains filtered or unexported fields
}

func (*Animation) Apply added in v0.9.0

func (a *Animation) Apply(timestamp float64)

func (*Animation) EndTime added in v0.9.0

func (a *Animation) EndTime() float64

func (*Animation) Length added in v0.9.0

func (a *Animation) Length() float64

func (*Animation) Name added in v0.9.0

func (a *Animation) Name() string

func (*Animation) StartTime added in v0.9.0

func (a *Animation) StartTime() float64

type AnimationBindingDefinitionInfo added in v0.9.0

type AnimationBindingDefinitionInfo struct {
	NodeIndex            int
	NodeName             string //alternative in case of isolated animation
	TranslationKeyframes KeyframeList[dprec.Vec3]
	RotationKeyframes    KeyframeList[dprec.Quat]
	ScaleKeyframes       KeyframeList[dprec.Vec3]
}

type AnimationDefinition added in v0.9.0

type AnimationDefinition struct {
	// contains filtered or unexported fields
}

type AnimationDefinitionInfo added in v0.9.0

type AnimationDefinitionInfo struct {
	Name      string
	StartTime float64
	EndTime   float64
	Bindings  []AnimationBindingDefinitionInfo
}

type AnimationInfo added in v0.9.0

type AnimationInfo struct {
	Model      *Model
	Definition *AnimationDefinition
}

type Controller

type Controller struct {
	app.NopController
	// contains filtered or unexported fields
}

func NewController added in v0.9.0

func NewController(registry asset.Registry, api render.API, shaders graphics.ShaderCollection) *Controller

func (*Controller) Engine added in v0.9.0

func (c *Controller) Engine() *Engine

func (*Controller) OnCreate added in v0.9.0

func (c *Controller) OnCreate(window app.Window)

func (*Controller) OnDestroy added in v0.9.0

func (c *Controller) OnDestroy(window app.Window)

func (*Controller) OnRender added in v0.9.0

func (c *Controller) OnRender(window app.Window)

func (*Controller) OnResize added in v0.9.0

func (c *Controller) OnResize(window app.Window, width, height int)

type CubeTexture added in v0.9.0

type CubeTexture struct {
	// contains filtered or unexported fields
}

type Engine added in v0.9.0

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine added in v0.9.0

func NewEngine(opts ...EngineOption) *Engine

func (*Engine) ActiveScene added in v0.9.0

func (e *Engine) ActiveScene() *Scene

func (*Engine) Create added in v0.9.0

func (e *Engine) Create()

func (*Engine) CreateAnimationDefinition added in v0.9.0

func (e *Engine) CreateAnimationDefinition(info AnimationDefinitionInfo) *AnimationDefinition

func (*Engine) CreateResourceSet added in v0.9.0

func (e *Engine) CreateResourceSet() *ResourceSet

func (*Engine) CreateScene added in v0.9.0

func (e *Engine) CreateScene() *Scene

func (*Engine) Destroy added in v0.9.0

func (e *Engine) Destroy()

func (*Engine) ECS added in v0.9.0

func (e *Engine) ECS() *ecs.Engine

func (*Engine) GFXWorker added in v0.9.0

func (e *Engine) GFXWorker() Worker

func (*Engine) Graphics added in v0.9.0

func (e *Engine) Graphics() *graphics.Engine

func (*Engine) IOWorker added in v0.9.0

func (e *Engine) IOWorker() Worker

func (*Engine) Physics added in v0.9.0

func (e *Engine) Physics() *physics.Engine

func (*Engine) Registry added in v0.9.0

func (e *Engine) Registry() asset.Registry

func (*Engine) Render added in v0.9.0

func (e *Engine) Render(viewport graphics.Viewport)

func (*Engine) ResetDeltaTime added in v0.9.0

func (e *Engine) ResetDeltaTime()

func (*Engine) SetActiveScene added in v0.9.0

func (e *Engine) SetActiveScene(scene *Scene)

func (*Engine) SubscribePostUpdate added in v0.9.0

func (e *Engine) SubscribePostUpdate(callback UpdateCallback) *UpdateSubscription

func (*Engine) SubscribePreUpdate added in v0.9.0

func (e *Engine) SubscribePreUpdate(callback UpdateCallback) *UpdateSubscription

func (*Engine) Update added in v0.9.0

func (e *Engine) Update()

type EngineOption added in v0.9.0

type EngineOption func(e *Engine)

func WithECS added in v0.9.0

func WithECS(ecsEngine *ecs.Engine) EngineOption

func WithGFXWorker added in v0.9.0

func WithGFXWorker(worker Worker) EngineOption

func WithGraphics added in v0.9.0

func WithGraphics(gfxEngine *graphics.Engine) EngineOption

func WithIOWorker added in v0.9.0

func WithIOWorker(worker Worker) EngineOption

func WithPhysics added in v0.9.0

func WithPhysics(physicsEngine *physics.Engine) EngineOption

func WithRegistry added in v0.9.0

func WithRegistry(registry asset.Registry) EngineOption

type Keyframe added in v0.9.0

type Keyframe[T any] struct {
	Timestamp float64
	Value     T
}

type KeyframeList added in v0.9.0

type KeyframeList[T any] []Keyframe[T]

func (KeyframeList[T]) Keyframe added in v0.9.0

func (l KeyframeList[T]) Keyframe(timestamp float64) (Keyframe[T], Keyframe[T], float64)

type Model added in v0.9.0

type Model struct {
	// contains filtered or unexported fields
}

func (*Model) Animations added in v0.9.0

func (m *Model) Animations() []*Animation

func (*Model) BodyInstances added in v0.9.0

func (m *Model) BodyInstances() []*physics.Body

func (*Model) FindAnimation added in v0.9.0

func (m *Model) FindAnimation(name string) *Animation

func (*Model) Root added in v0.9.0

func (m *Model) Root() *Node

type ModelDefinition added in v0.9.0

type ModelDefinition struct {
	// contains filtered or unexported fields
}

func (*ModelDefinition) FindAnimation added in v0.9.0

func (d *ModelDefinition) FindAnimation(name string) *AnimationDefinition

type ModelInfo added in v0.9.0

type ModelInfo struct {
	// Name specifies the name of this instance. This should not be
	// confused with the name of the definition.
	Name string

	// Definition specifies the template from which this instance will
	// be created.
	Definition *ModelDefinition

	// Position is used to specify a location for the model instance.
	Position dprec.Vec3

	// Rotation is used to specify a rotation for the model instance.
	Rotation dprec.Quat

	// Scale is used to specify a scale for the model instance.
	Scale dprec.Vec3

	// IsDynamic determines whether the model can be repositioned once
	// placed in the Scene.
	// (i.e. whether it should be added to the scene hierarchy)
	IsDynamic bool

	// PrepareAnimations indicates whether animation definitions should be
	// instantiated for this model.
	PrepareAnimations bool
}

ModelInfo contains the information necessary to place a Model instance into a Scene.

type Node added in v0.9.0

type Node struct {
	// contains filtered or unexported fields
}

Node represents a positioning of an object or part of one in the 3D scene.

func NewNode added in v0.9.0

func NewNode() *Node

NewNode creates a new detached Node instance.

func (*Node) AbsoluteMatrix added in v0.9.0

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

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

func (*Node) AppendChild added in v0.9.0

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 added in v0.9.0

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

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

func (*Node) Armature added in v0.9.0

func (n *Node) Armature() *graphics.Armature

Armature returns the graphics Armature that is attached to this Node.

func (*Node) ArmatureBone added in v0.9.0

func (n *Node) ArmatureBone() int

ArmatureBone returns the bone index if the Armature that is affected by this Node.

func (*Node) Body added in v0.9.0

func (n *Node) Body() *physics.Body

Body returns the physics Body that is attached to this Node.

func (*Node) Camera added in v0.9.0

func (n *Node) Camera() *graphics.Camera

Camera returns the graphics Camera that is attached to this Node.

func (*Node) Detach added in v0.9.0

func (n *Node) Detach()

Detach removes this Node from the hierarchy but does not release any resources.

func (*Node) FindNode added in v0.9.0

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 added in v0.9.0

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 added in v0.9.0

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 added in v0.9.0

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) Light added in v0.9.0

func (n *Node) Light() *graphics.Light

Light returns the graphics Light that is attached to this Node.

func (*Node) Matrix added in v0.9.0

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

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

func (*Node) Mesh added in v0.9.0

func (n *Node) Mesh() *graphics.Mesh

Mesh returns the graphics Mesh that is attached to this Node.

func (*Node) Name added in v0.9.0

func (n *Node) Name() string

Name returns this Node's name.

func (*Node) Parent added in v0.9.0

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 added in v0.9.0

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

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

func (*Node) PrependChild added in v0.9.0

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 added in v0.9.0

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

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

func (*Node) PrintHierarchy added in v0.9.0

func (n *Node) PrintHierarchy(depth int)

PrintHierarchy prints debug information regarding the hierarchy that starts from this node.

func (*Node) RemoveChild added in v0.9.0

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 added in v0.9.0

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 added in v0.9.0

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

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

func (*Node) Scale added in v0.9.0

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

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

func (*Node) SetArmature added in v0.9.0

func (n *Node) SetArmature(armature *graphics.Armature)

SetArmature attaches a graphics Armature to this Node.

func (*Node) SetArmatureBone added in v0.9.0

func (n *Node) SetArmatureBone(bone int)

SetArmatureBone configures the bone index of the Armature that is affected by this Node.

func (*Node) SetBody added in v0.9.0

func (n *Node) SetBody(body *physics.Body)

SetBody attaches a physics Body to this node.

func (*Node) SetCamera added in v0.9.0

func (n *Node) SetCamera(camera *graphics.Camera)

SetCamera attaches a graphics Camera to this Node.

func (*Node) SetLight added in v0.9.0

func (n *Node) SetLight(light *graphics.Light)

SetLight attaches a graphics Light to this Node.

func (*Node) SetMesh added in v0.9.0

func (n *Node) SetMesh(mesh *graphics.Mesh)

SetMesh attaches a graphics Mesh to this Node.

func (*Node) SetName added in v0.9.0

func (n *Node) SetName(name string)

SetName changes this Node's name.

func (*Node) SetPosition added in v0.9.0

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

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

func (*Node) SetRotation added in v0.9.0

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

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

func (*Node) SetScale added in v0.9.0

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

SetScale changes this Node's scale relative to the parent.

func (*Node) UseTransformation added in v0.9.0

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 default behavior.

type Operation added in v0.9.0

type Operation struct {
	// contains filtered or unexported fields
}

func NewOperation added in v0.9.0

func NewOperation() Operation

func (Operation) Complete added in v0.9.0

func (o Operation) Complete(err error)

func (Operation) Wait added in v0.9.0

func (o Operation) Wait() error

type Promise added in v0.9.0

type Promise[T any] struct {
	// contains filtered or unexported fields
}

func NewPromise added in v0.9.0

func NewPromise[T any](engine *Engine) Promise[T]

func SafePromise added in v0.9.0

func SafePromise[T any](delegate async.Promise[T], engine *Engine) Promise[T]

func (Promise[T]) OnError added in v0.9.0

func (p Promise[T]) OnError(cb func(err error))

func (Promise[T]) OnSuccess added in v0.9.0

func (p Promise[T]) OnSuccess(cb func(value T))

func (Promise[T]) Ready added in v0.9.0

func (p Promise[T]) Ready() bool

func (Promise[T]) Unsafe added in v0.9.0

func (p Promise[T]) Unsafe() async.Promise[T]

type ResourceSet added in v0.9.0

type ResourceSet struct {
	// contains filtered or unexported fields
}

func (*ResourceSet) CreateResourceSet added in v0.9.0

func (s *ResourceSet) CreateResourceSet() *ResourceSet

func (*ResourceSet) Delete added in v0.9.0

func (s *ResourceSet) Delete()

Delete schedules all resources managed by this ResourceSet for deletion. After this method returns, the resources are not guaranteed to have been released.

Calling this method twice is not allowed. Allocating new resources after this method has been called is also not allowed.

func (*ResourceSet) OpenCubeTexture added in v0.9.0

func (s *ResourceSet) OpenCubeTexture(id string) async.Promise[*CubeTexture]

func (*ResourceSet) OpenModel added in v0.9.0

func (s *ResourceSet) OpenModel(id string) async.Promise[*ModelDefinition]

func (*ResourceSet) OpenModelByName added in v0.9.0

func (s *ResourceSet) OpenModelByName(name string) async.Promise[*ModelDefinition]

func (*ResourceSet) OpenScene added in v0.9.0

func (s *ResourceSet) OpenScene(id string) async.Promise[*SceneDefinition]

func (*ResourceSet) OpenSceneByName added in v0.9.0

func (s *ResourceSet) OpenSceneByName(name string) async.Promise[*SceneDefinition]

func (*ResourceSet) OpenTwoDTexture added in v0.9.0

func (s *ResourceSet) OpenTwoDTexture(id string) async.Promise[*TwoDTexture]

type Scene added in v0.9.0

type Scene struct {
	// contains filtered or unexported fields
}

func (*Scene) CreateAnimation added in v0.9.0

func (s *Scene) CreateAnimation(info AnimationInfo) *Animation

func (*Scene) CreateModel added in v0.9.0

func (s *Scene) CreateModel(info ModelInfo) *Model

func (*Scene) Delete added in v0.9.0

func (s *Scene) Delete()

func (*Scene) ECS added in v0.9.0

func (s *Scene) ECS() *ecs.Scene

func (*Scene) Graphics added in v0.9.0

func (s *Scene) Graphics() *graphics.Scene

func (*Scene) Initialize added in v0.9.0

func (s *Scene) Initialize(definition *SceneDefinition)

func (*Scene) Physics added in v0.9.0

func (s *Scene) Physics() *physics.Scene

func (*Scene) Root added in v0.9.0

func (s *Scene) Root() *Node

func (*Scene) Update added in v0.9.0

func (s *Scene) Update(elapsedSeconds float64)

type SceneDefinition added in v0.9.0

type SceneDefinition struct {
	// contains filtered or unexported fields
}

type TransformFunc added in v0.9.0

type TransformFunc func(parent, current dprec.Mat4) dprec.Mat4

TransformFunc is a mechanism to calculate a custom absolute matrix off of the parent and the current matrix, circumventing standard matrix multiplication rules.

type TwoDTexture added in v0.9.0

type TwoDTexture struct {
	// contains filtered or unexported fields
}

type UpdateCallback added in v0.9.0

type UpdateCallback func(engine *Engine, scene *Scene, elapsedSeconds float64)

type UpdateSubscription added in v0.9.0

type UpdateSubscription struct {
	// contains filtered or unexported fields
}

func (*UpdateSubscription) Delete added in v0.9.0

func (s *UpdateSubscription) Delete()

type Worker added in v0.9.0

type Worker interface {
	Schedule(fn func() error) Operation
	ScheduleVoid(fn func()) Operation
}

type WorkerFunc added in v0.9.0

type WorkerFunc func(fn func() error) Operation

func (WorkerFunc) Schedule added in v0.9.0

func (f WorkerFunc) Schedule(fn func() error) Operation

func (WorkerFunc) ScheduleVoid added in v0.9.0

func (f WorkerFunc) ScheduleVoid(fn func()) Operation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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