Documentation
¶
Overview ¶
Package components provides the various components used by the different engine systems.
Index ¶
Constants ¶
View Source
const ( // TypeMesh represents a mesh component's type. TypeMesh = "mesh" // MeshSrcDir is the expected location of meshes MeshSrcDir = "assets/models/" )
View Source
const (
// TypeAcceleration represents an acceleration component's type.
TypeAcceleration = "acceleration"
)
View Source
const (
// TypeCamera represents a Camera component's type.
TypeCamera = "Camera"
)
View Source
const (
// TypeTransform represents a transform component's type.
TypeTransform = "transform"
)
View Source
const (
// TypeVelocity represents a velocity component's type.
TypeVelocity = "velocity"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Acceleration ¶
type Acceleration interface {
Component
// Rotational retrieves the rotational acceleration in radians per second.
Rotational() mgl32.Vec3
// Translational retrieves the translational acceleration.
Translational() mgl32.Vec3
// SetRotational sets the rotational acceleration.
SetRotational(mgl32.Vec3)
// SetTranslational sets the translational acceleration.
SetTranslational(mgl32.Vec3)
// Set sets the rotational and translational accerlation vectors.
Set(rotational, translational mgl32.Vec3)
}
Acceleration represents the acceleration of an entity.
func NewAcceleration ¶
func NewAcceleration() Acceleration
NewAcceleration creates a new Acceleration component.
type Camera ¶
type Camera interface {
// SetView sets the view matrix.
SetView(camEye, camLookAt, camUp [3]float32)
// SetProjection sets the projection matrix.
SetProjection(fovY, nearPlane, farPlane float32, windowWidth, windowHeight int)
// Projection retrieves the projection matrix.
Projection() mgl32.Mat4
// View retrieves the view matrix.
View() mgl32.Mat4
// PositionVec3 retrieves the camera position.
PositionVec3() mgl32.Vec3
// LookAtVec3 retrieves the point the camera is looking.
LookAtVec3() mgl32.Vec3
// UpVec3 retrieves the camera's up vector.
UpVec3() mgl32.Vec3
// FOVy retrieves the camera's FOVY.
FOVy() float32
// NearPlane retrieves the cameras current near plane.
NearPlane() float32
// FarPlane retrieves the camera's current far plane.
FarPlane() float32
// WindowHeight retrieves the window height used to calculate the perspective.
WindowHeight() int
// WindowWidth retrieves the window width used to calculate the perspective.
WindowWidth() int
}
Camera represents the behaviors of any camera.
type Component ¶
type Component interface {
// Type is expected to return a string representing the type of component.
Type() string
}
Component presents the behavior all components must have.
type Mesh ¶
type Mesh interface {
Component
// Data retrieves the mesh data.
Data() MeshData
// Set updates the mesh data with the new data passed in as a parameter.
Set(MeshData)
// Load loads the mesh data from file.
Load(string) error
}
Mesh represents a component that holds the data representing a mesh.
type MeshData ¶
type MeshData struct {
Indexed bool `json:"indexed"`
Verts []float32 `json:"verts"`
Indices []uint32 `json:"indices"`
VertSize int32 `json:"vertSize"`
TextureFile string `json:"textureFile"`
FragShaderFile string `json:"fragShaderFile"`
VertShaderFile string `json:"vertShaderFile"`
}
MeshData represents the the data needed to construct a 3d mesh.
type Transform ¶
type Transform interface {
Component
// Set sets the transform to a specific matrix.
Set(mgl32.Mat4)
// Data retrieves the transforms matrix.
Data() mgl32.Mat4
// Rotate rotates the transform by the angles passed into the method.
Rotate(mgl32.Vec3)
// Translate translates the transform by the value passed into the method.
Translate(mgl32.Vec3)
// Update translates the transform based on the first argument then rotates it using the second argument.
Update(mgl32.Vec3, mgl32.Vec3)
}
Transform represents the world position of an entity.
type Velocity ¶
type Velocity interface {
Component
// Rotational retrieves the rotational velocity in radians per second.
Rotational() mgl32.Vec3
// Translational retrieves the translational velocity.
Translational() mgl32.Vec3
// SetRotational sets the rotational velocity.
SetRotational(mgl32.Vec3)
// SetTranslational sets the translational velocity.
SetTranslational(mgl32.Vec3)
// Set sets the rotational and translational velocities.
Set(rotational mgl32.Vec3, translational mgl32.Vec3)
}
Velocity represents the velocity of an entity.
Click to show internal directories.
Click to hide internal directories.