vu

package module
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: BSD-2-Clause Imports: 18 Imported by: 1

README

Vu

Vu (Virtual Universe) is a 3D engine based on Go (Golang) programming language. Vu is composed of packages, detailed in GoDoc, and briefly summarized below. More getting started and background information is available on the Wiki

Vu is a small engine intended for simple games. It currently supports Vulkan on Windows.

  • vu/physics handles spheres and convex hulls.
  • vu/render uses Vulkan 1.3 without any extensions.
  • vu/device supports a basic window, button presses, mouse clicks, and mouse movement.

Vu started as a learning project for Go and 3D programming. It is currently being used by the author to develop games and other 3D applications.

Sub packages

  • audio Positions and plays sounds in a 3D environment.
  • device Links the application to native OS specific window and user events.
  • eg Examples that both demonstrate and test the vu engine.
  • load Asset loaders including models, textures, audio, shaders, and bitmapped fonts.
  • math/lin Linear math library for vectors, matricies, and quaternions.
  • physics Repositions bodies based on simulated physics.
  • render 3D drawing and graphics interface.

Build and Test

  • Clone the repo, ie: git clone git@github.com:gazed/vu.git
  • Use go generate in vu/assets/shaders to build the shaders. Requires glslc executable.
  • go build in vu\eg and run the examples.

Build Dependencies

Credit Where Credit is Due

Vu is built on the generous sharing of code and information by many talented, kind, and lucid developers. Thank you in particular to:

  • https://www.youtube.com/@TravisVroman Travis Vroman brilliantly explains how to use Vulkan in a game engine. His video devlog and code base provides an overall context for Vulkan that is difficult to get from the specification. Want a Vulkan C engine? Checkout https://github.com/travisvroman/kohi Apache License.

  • https://github.com/bbredesen/go-vk MIT License. Go bindings for Vulkan. This is a huge amount of work due to the size and complexity of the Vulkan spec. Bindings were generated from a hacked version, gazed/vk-gen, that uses Syscall instead of Cgo. The generated bindings were dropped into vu/internal/render/vk

  • https://github.com/felipeek/raw-physics MIT License. Raw-physics provides the ability to collide spheres and convex hulls in less than 4000 lines of code. This was perfect for porting from C into Go vu/physics pretty much line for line.

  • https://github.com/lxn/win Go bindings for the Windows API that do not require c-go and a C compiler. The parts needed were put directly into vu/internal/device/win along with the original License.

  • https://github.com/qmuntal/gltf BSD 2-Clause License. GLTF helps tremendously for importing 3D model data and thanks to qmuntal it was possible to pull a few thousand lines of Go code into vu/internal/load/gltf and get a working importer.

Documentation

Overview

Package vu - the virtual universe engine, provides 3D game support. Vu wraps subsystems like rendering, physics, asset loading, audio, etc. to provide higher level functionality that includes:

  • Transform graphs and composite objects.
  • Timestepped update/render loop.
  • Access to user input events.
  • Cameras and transform manipulation.
  • Loading and controlling groups of graphics and audio assets.

Refer to the vu/eg package for examples of engine functionality.

Vu dependencies are:

  • Vulkan for graphics card access. See package vu/render.
  • OpenAL for sound card access. See package vu/audio.
  • WinAPI for Windows display and input. See package vu/device.

Index

Constants

View Source
const (
	K0      = device.K0      // 0 48     Standard keyboard numbers.
	K1      = device.K1      // 1 49       "
	K2      = device.K2      // 2 50       "
	K3      = device.K3      // 3 51       "
	K4      = device.K4      // 4 52       "
	K5      = device.K5      // 5 53       "
	K6      = device.K6      // 6 54       "
	K7      = device.K7      // 7 55       "
	K8      = device.K8      // 8 56       "
	K9      = device.K9      // 9 57       "
	KA      = device.KA      // A 65     Standard keyboard letters.
	KB      = device.KB      // B 66       "
	KC      = device.KC      // C 67       "
	KD      = device.KD      // D 68       "
	KE      = device.KE      // E 69       "
	KF      = device.KF      // F 70       "
	KG      = device.KG      // G 71       "
	KH      = device.KH      // H 72       "
	KI      = device.KI      // I 73       "
	KJ      = device.KJ      // J 74       "
	KK      = device.KK      // K 75       "
	KL      = device.KL      // L 76       "
	KM      = device.KM      // M 77       "
	KN      = device.KN      // N 78       "
	KO      = device.KO      // O 79       "
	KP      = device.KP      // P 80       "
	KQ      = device.KQ      // Q 81       "
	KR      = device.KR      // R 82       "
	KS      = device.KS      // S 83       "
	KT      = device.KT      // T 84       "
	KU      = device.KU      // U 85       "
	KV      = device.KV      // V 86       "
	KW      = device.KW      // W 87       "
	KX      = device.KX      // X 88       "
	KY      = device.KY      // Y 89       "
	KZ      = device.KZ      // Z 90       "
	KEqual  = device.KEqual  // = 61     Standard keyboard punctuation keys.
	KMinus  = device.KMinus  // - 45       "
	KRBkt   = device.KRBkt   // ] 93       "
	KLBkt   = device.KLBkt   // [ 91       "
	KQuote  = device.KQuote  // " 34       "
	KSemi   = device.KSemi   // ; 59       "
	KBSl    = device.KBSl    // \ 92       "
	KComma  = device.KComma  // , 44       "
	KSlash  = device.KSlash  // / 47       "
	KDot    = device.KDot    // . 46       "
	KGrave  = device.KGrave  // ~ 126      "
	KRet    = device.KRet    // ⇦ 8678     "
	KTab    = device.KTab    // ⇨ 8680     "
	KSpace  = device.KSpace  // ▭ 9645     "
	KDel    = device.KDel    // ⇍ 8653     "
	KEsc    = device.KEsc    // ⊶ 8886     "
	KF1     = device.KF1     // α 945    General Function keys.
	KF2     = device.KF2     // β 946      "
	KF3     = device.KF3     // γ 947      "
	KF4     = device.KF4     // δ 948      "
	KF5     = device.KF5     // ε 949      "
	KF6     = device.KF6     // ζ 950      "
	KF7     = device.KF7     // η 951      "
	KF8     = device.KF8     // θ 952      "
	KF9     = device.KF9     // ι 953      "
	KF10    = device.KF10    // κ 954      "
	KF11    = device.KF11    // λ 955      "
	KF12    = device.KF12    // μ 956      "
	KF13    = device.KF13    // ν 957      "
	KF14    = device.KF14    // ξ 958      "
	KF15    = device.KF15    // ο 959      "
	KF16    = device.KF16    // π 960      "
	KF17    = device.KF17    // ρ 961      "
	KF18    = device.KF18    // ς 962      "
	KF19    = device.KF19    // σ 963      "
	KHome   = device.KHome   // ◈ 9672   Specific function keys.
	KPgUp   = device.KPgUp   // ⇑ 8657     "
	KFDel   = device.KFDel   // ⇏ 8655     "
	KEnd    = device.KEnd    // ▣ 9635     "
	KPgDn   = device.KPgDn   // ⇓ 8659     "
	KALeft  = device.KALeft  // ◀ 9664   Arrow keys
	KARight = device.KARight // ▶ 9654     "
	KADown  = device.KADown  // ▼ 9660     "
	KAUp    = device.KAUp    // ▲ 9650     "
	KPDot   = device.KPDot   // ⊙ 8857   Extended keyboard keypad keys
	KPMlt   = device.KPMlt   // ⊗ 8855     "
	KPAdd   = device.KPAdd   // ⊕ 8853     "
	KPClr   = device.KPClr   // ⊠ 8864     "
	KPDiv   = device.KPDiv   // ⊘ 8856     "
	KPEnt   = device.KPEnt   // ⇐ 8656     "
	KPSub   = device.KPSub   // ⊖ 8854     "
	KPEql   = device.KPEql   // ⊜ 8860     "
	KP0     = device.KP0     // ₀ 8320     "
	KP1     = device.KP1     // ₁ 8321     "
	KP2     = device.KP2     // ₂ 8322     "
	KP3     = device.KP3     // ₃ 8323     "
	KP4     = device.KP4     // ₄ 8324     "
	KP5     = device.KP5     // ₅ 8325     "
	KP6     = device.KP6     // ₆ 8326     "
	KP7     = device.KP7     // ₇ 8327     "
	KP8     = device.KP8     // ₈ 8328     "
	KP9     = device.KP9     // ₉ 8329     "
	KML     = device.KML     // ◐ 9680   Mouse buttons treated like keys.
	KMM     = device.KMM     // ◓ 9683     "
	KMR     = device.KMR     // ◑ 9681     "
	KCtl    = device.KCtl    // ● 9679   Modifier keys.
	KFn     = device.KFn     // ◍ 9677     "
	KShift  = device.KShift  // ⇧ 8679     "
	KCmd    = device.KCmd    // ◆ 9670     "
	KAlt    = device.KAlt    // ◇ 9671     "
)

Expose the device package keys as a convenience so the device package does not always need to be included. The symbol associated to each key is shown in the comments.

Keys are expected to be used for controlling game actions. There is no text entry or text layout support.

View Source
const (
	DirectionalLight = iota // no falloff ie: the sun
	PointLight              // falloff ie: light bulb
)

Types of lights

View Source
const (
	KinematicSim bool = false // movable
	StaticSim    bool = true  // immovable
)

Simulated bodies can either be kinematic-movable or static-immovable.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr added in v0.20.0

type Attr func(*Config) // type for attribute overrides

Attr defines optional application attributes that can be used to configure the engine.

eng, err := vu.NewEngine(
   vu.Title("Keyboard Controller"),
   vu.Size(200, 200, 900, 400),
   vu.Background(0.45, 0.45, 0.45, 1.0),
)

func Background added in v0.20.0

func Background(r, g, b, a float32) Attr

Background display clear color.

func Size added in v0.8.0

func Size(x, y, w, h int32) Attr

Size sets the window top left corner location and size in pixels when using windowed mode.

func Title added in v0.8.0

func Title(t string) Attr

Title sets the window title when using windowed mode. For use in NewEngine().

func Windowed added in v0.20.0

func Windowed() Attr

Windowed mode instead of fullscreen.

type Body added in v0.8.0

type Body *physics.Body

Body wraps physics.Body allowing the engine app to access common physics methods without including the physics package.

func Box added in v0.8.0

func Box(hx, hy, hz float64, static bool) Body

Box creates a box shaped physics body located at the origin. The box size is given by the half-extents so that actual size is w=2*hx, h=2*hy, d=2*hz.

func Sphere added in v0.8.0

func Sphere(radius float64, static bool) Body

Sphere creates a ball shaped physics body located at the origin. The sphere size is defined by the radius.

type Camera

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

Camera makes rendered models visible within a frame. A camera is associated with a scene where it is used to render the scenes models.

Camera combines a location+orientation using separate pitch angle tracking. This allows use as a first-person camera which can limit up/down to a given range (often 180 degrees). Overall orientation is calculated by combining Pitch and Yaw. Look is for walking cameras, Lookat is for flying cameras.

func (*Camera) At added in v0.6.5

func (c *Camera) At() (x, y, z float64)

At returns the cameras current location in world space.

func (*Camera) Lookat

func (c *Camera) Lookat() *lin.Q

Lookat returns the current camera rotation. The rotation is created from Pitch and Yaw.

func (*Camera) Move

func (c *Camera) Move(x, y, z float64, q *lin.Q)

Move adjusts the camera location relative to the given orientation. For orientation, use Lookat() to fly, use Look to run along XZ.

func (*Camera) Ray

func (c *Camera) Ray(mx, my, ww, wh int) (x, y, z float64, err error)

Ray applies inverse transforms to derive world space coordinates for a ray projected from the camera through the mouse's mx,my screen position given window width and height ww,wh.

func (*Camera) RayCastDisk added in v0.21.0

func (c *Camera) RayCastDisk(ray, center, normal *lin.V3, radius float64) (hit bool)

RayCastDisk checks for collision between a ray originating from the camera and a circle in world space. The ray must be a unit vector, see: camera.Ray(). See: https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection

func (*Camera) RayCastSphere added in v0.20.0

func (c *Camera) RayCastSphere(ray, sphere *lin.V3, radius float64) (hit bool)

RayCastSphere checks for collision between a ray originating from the camera and a sphere in world space. The ray must be a unit vector, see: camera.Ray().

func (*Camera) Screen

func (c *Camera) Screen(wx, wy, wz float64, ww, wh int) (sx, sy int)

Screen applies the camera transform on a 3D point in world space wx,wy,wz and returns the 2D screen coordinate sx,sy. The window width and height ww,wh are needed. Essentially the reverse of the Ray method and duplicates what is done in the rendering pipeline. Returns -1,-1 if the point is outside the screen area.

func (*Camera) SetAt added in v0.6.5

func (c *Camera) SetAt(x, y, z float64) *Camera

SetAt positions the camera in world space The camera instance is returned.

func (*Camera) SetClip added in v0.8.0

func (c *Camera) SetClip(near, far float64) *Camera

SetClip sets the near and far clipping planes for perspective and orthographic cameras.

func (*Camera) SetFov added in v0.8.0

func (c *Camera) SetFov(deg float64) *Camera

SetFov sets the field of view for perspective projection cameras. Ignored for orthographic projection cameras.

func (*Camera) SetLook added in v0.21.0

func (c *Camera) SetLook(q *lin.Q)

SetLook directly sets the camera orientation to the given quaternion. The orientation will be overwritten with new calls to SetPitch and SetYaw.

func (*Camera) SetPitch

func (c *Camera) SetPitch(deg float64) *Camera

SetPitch sets the rotation around the X axis and updates the Look direction. The camera instance is returned.

func (*Camera) SetYaw

func (c *Camera) SetYaw(deg float64) *Camera

SetYaw sets the rotation around the Y axis and updates the Look and Lookat directions. The camera instance is returned.

type Config added in v0.20.0

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

Config contains configuration attributes that can be set by the game before running the engine game loop.

type Engine added in v0.20.0

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

Engine controls the engine subsystems and the run loop.

eng.Run(updater) // Run the engine.

func NewEngine added in v0.20.0

func NewEngine(config ...Attr) (eng *Engine, err error)

NewEngine is called by the game to initialize the engine and its subsystems like rendering, physics, and audio. Eg:

eng, err := vu.NewEngine(vu.Windowed())

The app uses eng to create the initial scenes prior to running the engine.

func (*Engine) AddScene added in v0.20.0

func (eng *Engine) AddScene(st SceneType) *Entity

AddScene creates a new application scene graph and camera. Scene graphs use zero to indicate that this is a root node.

func (*Engine) AddSound added in v0.20.0

func (eng *Engine) AddSound(name string) (soundID uint32)

AddSound loads audio data and returns a unique sound identifier. Passing the sound identifier to an entity PlaySound() method will assigned using SetListener(). Sounds are louder the closer the played sound to the sound listener.

name is the sound asset filename without the .wav extension.

func (*Engine) ImportAssets added in v0.20.0

func (eng *Engine) ImportAssets(assetFilenames ...string)

ImportAssets creates assets from the given asset files. Expected to be called at least once initialization to create the assets referenced by models in a scene.

func (*Engine) MakeMeshes added in v0.21.0

func (eng *Engine) MakeMeshes(name string, meshes []load.MeshData) (err error)

MakeMeshes loads application generated mesh data.

func (*Engine) Run added in v0.20.0

func (eng *Engine) Run(updator Updator)

Run the game engine. This method starts the game loop and does not return until the game shuts down. The game Update method is called each time the game loop updates.

func (*Engine) SetResizeListener added in v0.20.0

func (eng *Engine) SetResizeListener(resizer Resizer)

SetResizeListener sets the application callback for when the window is resized.

func (*Engine) Shutdown added in v0.20.0

func (eng *Engine) Shutdown()

Shutdown is an application request to close down the engine. Mark the engine as shutdown which will cause the game loop to exit.

func (*Engine) ToggleFullscreen added in v0.21.0

func (eng *Engine) ToggleFullscreen()

ToggleFullscreen switches between a borderless fullscreen window and a bordered window.

type Entity added in v0.20.0

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

Entity track resoures created by the application. Common application entities are scenes and models, eg:

scene := eng.AddScene(vu.Scene3D)
model := scene.AddModel("shd:pbr0", "msh:box0", "mat:box0")

Scenes are used to group models with cameras. Models are used to group assets with shaders. Together they are used to render frames.

func (*Entity) AddInstancedModel added in v0.20.0

func (e *Entity) AddInstancedModel(assets ...string) (me *Entity)

AddInstancedModel adds a model where the immediate children are instances of the parent model. The parent model will be rendered for each childs transform data.

func (*Entity) AddLabel added in v0.20.0

func (e *Entity) AddLabel(s string, wrap int, assets ...string) (me *Entity)

AddLabel creates a static string model for 2D or 3D text display. It is intended for single letters, words or small phrases. eg:

letter2D := scene.AddLabel("text", 0, "shd:icon", "fnt:lucon18", "tex:color:lucon18")

A label requires a texture based shader, font mapping data, and a font texture atlas. The mesh is calculated from the string once the font assets have loaded.

func (*Entity) AddLight added in v0.20.0

func (e *Entity) AddLight(lightType int) *Entity

AddLight adds a light to a scene. Lighting aware shaders combine the light with the models material values. Objects in the scene with lighting capable shaders will be influenced by the light.

Each light is has a position and orientation in world space. The default position is 0,0,0 and the default direction is 0,0,-1. A lights default color is white 1,1,1.

Depends on Eng.AddScene.

func (*Entity) AddModel added in v0.20.0

func (e *Entity) AddModel(assets ...string) (me *Entity)

AddModel adds a new transform with a model component to the given entity.

func (*Entity) AddPart added in v0.21.0

func (e *Entity) AddPart() *Entity

AddPart creates a new entity with a point-of-view component (pov). A pov adds a location and orientation to an entity. The entity can now be positioned and rotated.

The entity is also added to the scene graph so that this entities world pov is affected by its parents and will also affect any child entities created from this one.

func (*Entity) AddToSimulation added in v0.20.0

func (e *Entity) AddToSimulation(b Body) *Entity

AddToSimulation Bodies are generally set on top level pov transforms which always have valid world coordindates.

b: a physics body eg: vu.Box, vu.Sphere.

func (*Entity) AddUpdatableTexture added in v0.21.0

func (e *Entity) AddUpdatableTexture(eng *Engine, name string, img *image.NRGBA) *Entity

AddUpdatableTexture uploads 2 textures to the GPU. One is for rendering and one is for updating.

func (*Entity) At added in v0.20.0

func (e *Entity) At() (x, y, z float64)

At gets the local space location. This is world space if the entity does not have a parent.

Returns 0,0,0 if there is no transform component.

func (*Entity) Body added in v0.20.0

func (e *Entity) Body() Body

Body returns the physics body for this entity, returning nil if no physics body exists.

func (*Entity) Cam added in v0.20.0

func (e *Entity) Cam() *Camera

Cam returns the camera instace for a scene, returning nil if the entity is not a scene.

Depends on Eng.AddScene.

func (*Entity) Cull added in v0.20.0

func (e *Entity) Cull(culled bool)

Cull sets the culled state.

Depends on transform.

func (*Entity) Culled added in v0.20.0

func (e *Entity) Culled() bool

Culled returns true if entity has been culled from rendering.

Depends on transform. Returns true if there was no part component.

func (*Entity) Dispose added in v0.20.0

func (e *Entity) Dispose(eng *Engine)

Dispose all components for this entity. If the entity is a scene or a part with child entities, then all child entities are also disposed.

func (*Entity) DisposeBody added in v0.20.0

func (e *Entity) DisposeBody()

DisposeBody removes the physics body from the given entity. Does nothing if there was no physics body.

func (*Entity) Exists added in v0.20.0

func (e *Entity) Exists() bool

Exists returns true if the entity has been created and not yet disposed.

func (*Entity) LabelSize added in v0.20.0

func (e *Entity) LabelSize() (w, h int)

LabelSize returns the Label width, height in pixels. Returns 0 if not loaded.

Depends on Ent.AddLabel.

func (*Entity) Move added in v0.20.0

func (e *Entity) Move(x, y, z float64, dir *lin.Q)

Move directly affects the location by the given translation amounts along the given direction. Physics bodies should use Body.Push which affects velocity.

Depends on transform.

func (*Entity) PlaySound added in v0.20.0

func (e *Entity) PlaySound(soundID uint32)

PlaySound plays the given sound at this entities location.

  • soundID : entity created with Eng.AddSound.

Depends on Entity.AddSound.

func (*Entity) Push added in v0.20.0

func (e *Entity) Push(x, y, z float64)

Push adds to the body's linear velocity. It is a wrapper for physics.Body.Push

Depends on AddToSimultation.

func (*Entity) Scale added in v0.20.0

func (e *Entity) Scale() (x, y, z float64)

Scale retrieves the local per-axis scale values at 3 separate XYZ values. World scale needs to incorporate any parents values.

Depends on transform. Returns 0,0,0 if there is no part component.

func (*Entity) SetAa added in v0.20.0

func (e *Entity) SetAa(x, y, z, angleInRadians float64) *Entity

SetAa sets the orientation using the given axis and angle information.

Depends on transform.

func (*Entity) SetAt added in v0.20.0

func (e *Entity) SetAt(x, y, z float64) *Entity

SetAt sets the local space location, ie: relative to its parent. This is world space if there is no parent location.

Depends on transform.

func (*Entity) SetColor added in v0.20.0

func (e *Entity) SetColor(r, g, b, a float64) *Entity

SetColor sets the solid color for this model - not the texture color information. This affects shaders like pbr0 and label that use model uniform "color" The color is passed per object instance in the shader push constants.

Depends on Entity.AddModel.

func (*Entity) SetInstanceData added in v0.20.0

func (e *Entity) SetInstanceData(eng *Engine, count uint32, data []load.Buffer) (me *Entity)

SetInstanceData sets the instance data for an instanced model.

func (*Entity) SetLayer added in v0.21.0

func (e *Entity) SetLayer(layer uint8) *Entity

SetLayer helps to order draws - normally 2D UI elements. Layer values are 0 (first) to 15 (last). Normally packets are drawn in the creation order, but this allows specific ordering.

Depends on Entity.AddModel.

func (*Entity) SetLight added in v0.20.0

func (e *Entity) SetLight(r, g, b, intensity float32) *Entity

SetLight assigns a color and intensity to the light. The lights color is combined with objects material color to produce a final color. The R,G,B light values are between 0 (no color), and 1 (full color).

Depends on Entity.AddLight.

func (*Entity) SetListener added in v0.20.0

func (e *Entity) SetListener()

SetListener sets the location of the sound listener to be this entity.

Depends on Entity.AddSound.

func (*Entity) SetMetallicRoughness added in v0.20.0

func (e *Entity) SetMetallicRoughness(metallic bool, roughness float64) *Entity

SetMetallicRoughness sets the PBR material attributes for this model, not the texture material information. This affects pbr0 or pbr1 shaders. The PBR material is passed per object instance in the shader push constants.

Depends on Entity.AddModel.

func (*Entity) SetModelUniform added in v0.21.0

func (e *Entity) SetModelUniform(uniform string, data interface{}) *Entity

SetModelUniform sets data for the given uniform. The uniform data is passed to the shader.

func (*Entity) SetScale added in v0.20.0

func (e *Entity) SetScale(x, y, z float64) *Entity

SetScale assigns the XYZ per-axis scale values. Scale default is 1, greater than 1 enlarges, a positive fraction shrinks.

Depends on transform.

func (*Entity) SetSpin added in v0.20.0

func (e *Entity) SetSpin(x, y, z float64) *Entity

SetSpin sets the rotation to 0 before spinning the entity like the Spin method.

Depends on transform.

func (*Entity) SetView added in v0.20.0

func (e *Entity) SetView(q *lin.Q) *Entity

SetView directly sets the parts orientation. Often used to align this part with the orientation of another. Orientation is relative to parent. World space if no parent orientation.

Depends on transform.

func (*Entity) Spin added in v0.20.0

func (e *Entity) Spin(x, y, z float64) *Entity

Spin rotates x,y,z degrees about the X,Y,Z axis. The spins are combined in XYZ order, but generally this is used to spin about a single axis at a time.

Depends on transform.

func (*Entity) UpdateTexture added in v0.21.0

func (e *Entity) UpdateTexture(eng *Engine, img *image.NRGBA) *Entity

UpdateTexture uploads the image to the updatable texture and then swaps the updatable texture with the render texture.

func (*Entity) View added in v0.20.0

func (e *Entity) View() (q *lin.Q)

View returns the orientation of the Part. Orientation is a rotation about a axis. Orientation is relative to any parent Parts. It is world space if there is no parent orientation. Direct updates to the rotation matrix must be done with SetView or SetAa.

Depends on transform.

func (*Entity) World added in v0.20.0

func (e *Entity) World() (wx, wy, wz float64)

World returns the world space coordinates for this entity. World space is recalculated immediately on any change.

Depends on transform.

func (*Entity) WorldRot added in v0.20.0

func (e *Entity) WorldRot() (q *lin.Q)

WorldRot returns the world rotation for this entity. WorldRot space is recalculated immediately on any change and returns nil if the entity does not have a part.

Depends on transform.

func (*Entity) WriteImageText added in v0.21.0

func (e *Entity) WriteImageText(fontID, s string, xoff, yoff int, dst *image.NRGBA) (me *Entity)

WriteImageText uses the font assets associated with this model to write a string to the given image. The starting string location is specified by indent is in pixels line number is based on the font size.

type Input

type Input device.Input

Input is used to communicate user input to the application.

User input is the current cursor location, current pressed keys, mouse buttons, and modifiers. These are sent to the game each Update() callback. Overall the keyboard is treated like a gamepad controller. Keys and buttons are pressed or not pressed.

func (*Input) Clone added in v0.20.0

func (in *Input) Clone(b *device.Input)

Clone the data from given Input structure into this one.

type Resizer added in v0.20.0

type Resizer interface {
	// Resize is called when the window is resized.
	Resize(windowLeft, windowTop int32, windowWidth, windowHeight uint32)
}

Resizer is responsible for updating an application when the window is resized. It is implemented by the user app and set on startup.

type SceneType added in v0.20.0

type SceneType uint32

SceneType corresponds to a render pass.

  • Scene3D for the normal world rendering.
  • Scene2D for the UI overlay rendering.
const (
	//	Scene3D for the normal world rendering.
	Scene3D SceneType = SceneType(render.Pass3D)
	//	Scene2D for the UI overlay rendering.
	Scene2D SceneType = SceneType(render.Pass2D)
)

type Updator added in v0.20.0

type Updator interface {
	// Update allows applications to change state prior to the next render.
	// Update is called each game loop update (many times a second) while the
	// game is running.
	//    eng : the game
	//    i   : user input refreshed prior to each call.
	Update(eng *Engine, i *Input, delta time.Duration)
}

Updator is responsible for updating application state each render frame. It is implemented by the user app and passed to eng.Run().

Directories

Path Synopsis
assets
shaders
Package shaders contains the builtin engine shaders.
Package shaders contains the builtin engine shaders.
Package audio plays sounds at 3D locations.
Package audio plays sounds at 3D locations.
Package eg is used to test and demo different aspects of the vu engine.
Package eg is used to test and demo different aspects of the vu engine.
internal
Package load fetches disk based 3D asset data.
Package load fetches disk based 3D asset data.
math
lin
Package lin provides a linear math library intended for games.
Package lin provides a linear math library intended for games.
Package physics is a real-time simulation of real-world physics.
Package physics is a real-time simulation of real-world physics.

Jump to

Keyboard shortcuts

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