Components

package
v0.0.0-...-48b4d52 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package Components ...

Package Components ...

Package Graphics

Package Components ...

Package Text

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModelRenderer

func NewModelRenderer() *modelRenderer

NewSpriteRenderer creates a renderer and initializes its animation map

Types

type AXIS

type AXIS int

type AnimationManager

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

AnimationManager contains a map of animations, and allows the user to interface with them

func (*AnimationManager) AddAnimation

func (a *AnimationManager) AddAnimation(animationToAdd *FrameAnimation, nameToMap string)

AddAnimation maps a created animation inside the renderer

func (*AnimationManager) CurrentAnimation

func (a *AnimationManager) CurrentAnimation() *FrameAnimation

func (*AnimationManager) GetAnimation

func (a *AnimationManager) GetAnimation(mappedName string) *FrameAnimation

GetAnimation grabs a mapped animation and returns it for the user to manipulate if desired

func (*AnimationManager) SetCurrentAnimation

func (a *AnimationManager) SetCurrentAnimation(mappedAnimationName string)

SetCurrentAnimation takes a animation's name and tries to set that as the current animation

func (*AnimationManager) StartAnimation

func (a *AnimationManager) StartAnimation()

StartAnimation tells our current animation that it should animate (to be used when scripting)

func (*AnimationManager) StopAnimation

func (a *AnimationManager) StopAnimation()

StopAnimation tells our current animation that it should not animate (to be used when scripting)

type Child

type Child interface {
	SetParent(node *Node)
	GetParent() *Node
}

type ChildComponent

type ChildComponent struct {
	Parent *Node
}

func (*ChildComponent) GetParent

func (this *ChildComponent) GetParent() *Node

func (*ChildComponent) Intialize

func (this *ChildComponent) Intialize()

func (*ChildComponent) SetParent

func (this *ChildComponent) SetParent(node *Node)

func (*ChildComponent) Update

func (this *ChildComponent) Update(delta float32)

type Component

type Component interface {
	Child
	Initialize()
	Update(delta float32)
}

type FrameAnimation

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

FrameAnimation is a sequence of images and settings used by the renderer to animate sprites

func OBJAnimation

func OBJAnimation(loc string) *FrameAnimation

OBJAnimation takes the folder to OBJ files and creates animation from them

func SpliceFullSpriteSheetAnimation

func SpliceFullSpriteSheetAnimation(imageLoc string, frameWidth int, frameHeight int) *FrameAnimation

SpliceFullSpriteSheetAnimation manually cuts up an entire sprite sheet based on user defined frame dimensions

func SpliceSpriteSheetAnimation

func SpliceSpriteSheetAnimation(imageLoc string,
	frameWidth, frameHeight, noOfFrames, rowNum int) *FrameAnimation

SpliceSpriteSheetAnimation manually cuts up a row of a sprite sheet based on user defined dimensions and sets it as the current animation

func (*FrameAnimation) Append

func (f *FrameAnimation) Append(imageLoc string)

Append simply adds an image from the aggregate to the end of our animation

func (*FrameAnimation) AppendAnimation

func (f *FrameAnimation) AppendAnimation(animIn *FrameAnimation)

AppendAnimation adds a list of images to the end of our animation

func (*FrameAnimation) Remove

func (f *FrameAnimation) Remove(imageIdx int)

Remove an item from the animation via 1-based input

func (*FrameAnimation) Reorder

func (f *FrameAnimation) Reorder(imageOneIdx int, imageTwoIdx int)

Reorder simply swaps the order in which any two images are rendered ()

func (*FrameAnimation) SetAsOneTimeOnly

func (f *FrameAnimation) SetAsOneTimeOnly(setOneTime bool)

func (*FrameAnimation) SetFrequency

func (f *FrameAnimation) SetFrequency(freqIn float64, setFrequencyByTheFrame bool)

SetFrequency sets our animation's timing in either seconds or frames per toggle i.e. Frequency(4,true) sets to update every 4 frames i.e. Frequency(0.25,false) sets to update every 1/4 of a second

type Node

type Node struct {
	ChildComponent

	Name string
	// contains filtered or unexported fields
}

func NewNode

func NewNode(name string) *Node

func (*Node) AddComponent

func (this *Node) AddComponent(component Component)

func (*Node) AddNode

func (this *Node) AddNode(node *Node)

func (*Node) GetComponent

func (this *Node) GetComponent(componentType string) Component

func (*Node) Initialize

func (this *Node) Initialize()

func (*Node) Transform

func (this *Node) Transform() *Transform

func (*Node) Update

func (this *Node) Update(delta float32)

Update ... This function should possibly be private; however, it is designed to be called by the scene, not sure how to accomodate this protected type situation in Go...

type Renderer

type Renderer struct {
	ChildComponent
	Color *Image.Color
	// contains filtered or unexported fields
}

ScriptComponent becomes a user defined script Contains helper methods

func (*Renderer) CustomTransform

func (this *Renderer) CustomTransform(f func(mathgl.Vec4) mathgl.Vec4)

CustomTransforms allows the caller to apply a transformation to the current vertex data

func (*Renderer) Initialize

func (this *Renderer) Initialize()

func (*Renderer) Render

func (this *Renderer) Render(obj Opengl.RenderObject)

Render writes vertex data of RenderObjects to opengl

func (*Renderer) Update

func (this *Renderer) Update(delta float32)

Update is called just in case it is not overloaded

type ScriptComponent

type ScriptComponent struct {
	ChildComponent
}

ScriptComponent becomes a user defined script Contains helper methods

func (ScriptComponent) Transform

func (this ScriptComponent) Transform() *Transform

Transform - returns the parent's Transform

type SpriteRenderer

type SpriteRenderer struct {
	// ChildComponent
	Renderer

	// holds our map of animations as well as actions necessary to control them
	AnimationManager *AnimationManager
	// contains filtered or unexported fields
}

SpriteRenderer is a component which allows a sprite to be drawn or animated

func NewSpriteRenderer

func NewSpriteRenderer() *SpriteRenderer

NewSpriteRenderer creates a renderer and initializes its animation map

func (*SpriteRenderer) SetColor

func (s *SpriteRenderer) SetColor(r, g, b, a float32)

SetColor allows us to modify image coloring of whatever is set in the Renderer

func (*SpriteRenderer) SetImage

func (s *SpriteRenderer) SetImage(imageLoc string)

SetImage puts a designated image from the agregate into our image which will be rendered

func (*SpriteRenderer) SetSubImage

func (s *SpriteRenderer) SetSubImage(imageLoc string, bounds image.Rectangle)

SetSubImage sets a designated part of an image for this sprite renderer

@param  {[string]} this *SpriteRenderer [the base image path]
@param  {[image.Rectangle]} this *SpriteRenderer [the rectangular bounds of designated part of image]
@return

func (*SpriteRenderer) Update

func (s *SpriteRenderer) Update(delta float32)

Update gets called every frame and accounts for all settings in the renderer as well as shifts animations

type TextRenderer

type TextRenderer struct {
	Renderer
	// contains filtered or unexported fields
}

func NewTextRenderer

func NewTextRenderer() *TextRenderer

func (*TextRenderer) SetColor

func (s *TextRenderer) SetColor(r, g, b, a float32)

func (*TextRenderer) SetFont

func (this *TextRenderer) SetFont(font string)

func (*TextRenderer) SetSize

func (this *TextRenderer) SetSize(size int)

size of text in pixels (current max 100)

func (*TextRenderer) SetText

func (this *TextRenderer) SetText(text string)

func (*TextRenderer) TextTransform

func (this *TextRenderer) TextTransform(vertex mathgl.Vec4) mathgl.Vec4

func (*TextRenderer) Update

func (this *TextRenderer) Update(delta float32)

type Transform

type Transform struct {

	// location
	X, Y, Z float32

	// rotation radians
	Rot float32

	// rotation (Euler Angle)
	XR, YR, ZR float32

	//scale
	XS, YS, ZS float32
	// contains filtered or unexported fields
}

func NewTransform

func NewTransform() Transform

func (*Transform) GetUpdatedModel

func (this *Transform) GetUpdatedModel() mathgl.Mat4

func (*Transform) Rotate

func (this *Transform) Rotate(r, x, y, z float32)

Rotate first rotates on x, then y, then z

func (*Transform) Scale

func (s *Transform) Scale(x, y, z float32)

func (*Transform) Translate

func (s *Transform) Translate(x, y, z float32)

Jump to

Keyboard shortcuts

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