gorgeutil

package
v0.0.0-...-6aa7f09 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Overview

Package gorgeutil provides certain things like premade lights, camera entity structs

Index

Constants

View Source
const (
	MaterialMetallicRoughness = iota
	MaterialUnlit
)

Material types

Variables

This section is empty.

Functions

func AddUI

func AddUI(a Contexter) *gorgeui.UI

func KeyDirection

func KeyDirection(
	g *gorge.Context,
	boost, top, right, bottom, left input.Key,
) func(gorge.EventUpdate) gm.Vec2

KeyDirection returns a vec2 based on the direction of the key - Boost - Top, Right, Bottom, Left

func KeyDirectionV

func KeyDirectionV(g *gorge.Context) func(gorge.EventUpdate) gm.Vec2

func NewUI

func NewUI() *gorgeui.UI

func Wrapper

func Wrapper(fns ...func(*Context)) gorge.InitFunc

Types

type Basic

type Basic struct {
	gorge.Container

	PointLight *Light
	DirLight   *Light
	CamRig     *CameraRig
	// contains filtered or unexported fields
}

Basic default scene handler. TODO: {lpf} it should be moved to gorgeutil.

func AddBasic

func AddBasic(g gorge.Contexter) *Basic

AddBasic adds a basic scene to the given gorge context.

func NewBasic

func NewBasic(g gorge.Contexter) *Basic

NewBasic creates a default scene.

func (*Basic) HandleEvent

func (b *Basic) HandleEvent(v event.Event)

HandleEvent on basic scene

type Camera

type Camera struct {
	Name string
	gorge.TransformComponent
	gorge.CameraComponent
}

Camera basic camera entity.

func AddCamera

func AddCamera(a Contexter, fov, near, far float32) *Camera

func AddOrthoCamera

func AddOrthoCamera(a Contexter, size, near, far float32) *Camera

func AddPerspectiveCamera

func AddPerspectiveCamera(a Contexter, fov, near, far float32) *Camera

func AddUICamera

func AddUICamera(a entityAdder) *Camera

func NewCamera

func NewCamera() *Camera

NewCamera returns a camera entity with transform and camera components.

func NewOrthoCamera

func NewOrthoCamera(size, near, far float32) *Camera

NewOrthoCamera returns a camera defaulted to ortho projection.

func NewPerspectiveCamera

func NewPerspectiveCamera(fov, near, far float32) *Camera

NewPerspectiveCamera returns a default perspective camera.

func NewUICamera

func NewUICamera() *Camera

NewUICamera returns an ortho camera with a specific CullMask 1<<17 for UI.

func (*Camera) SetName

func (c *Camera) SetName(n string)

SetName sets the camera name for debugging purposes.

func (*Camera) String

func (c *Camera) String() string

type CameraRig

type CameraRig struct {
	*gorge.TransformComponent
	Vert   *gorge.TransformComponent
	Camera cameraEntity
	// contains filtered or unexported fields
}

CameraRig thing

func AddTrackballCamera

func AddTrackballCamera(a Contexter) *CameraRig

func NewTrackballCamera

func NewTrackballCamera(c cameraEntity) *CameraRig

NewTrackballCamera attaches events and all to make a trackball

func (*CameraRig) GetEntities

func (r *CameraRig) GetEntities() []gorge.Entity

GetEntities returns the underlying camera entities.

func (*CameraRig) HandleEvent

func (r *CameraRig) HandleEvent(e event.Event)

HandleEvent implements the event handler interface.

func (*CameraRig) String

func (s *CameraRig) String() string

type Context

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

Context extends gorge context with default entity instantiators.

func FromContext

func FromContext(g *gorge.Context) *Context

FromContext returns a gorgeutil context

func (Context) Camera

func (c Context) Camera() *Camera

Camera creates and adds a default camera to a gorge context.

func (Context) Cube

func (c Context) Cube() *Entity

Cube creates and adds a cube.

func (Context) DirectionalLight

func (c Context) DirectionalLight() *Light

DirectionalLight creates and adds a directional light to a gorge context.

func (Context) Light

func (c Context) Light() *Light

Light creates and adds a light to a gorge context.

func (Context) OrthoCamera

func (c Context) OrthoCamera(size, near, far float32) *Camera

OrthoCamera creates and adds a camera with default ortho projection options to a gorge context.

func (Context) PerspectiveCamera

func (c Context) PerspectiveCamera(fov, near, far float32) *Camera

PerspectiveCamera creates and adds a camera with default perspective options to a gorge context.

func (Context) Plane

func (c Context) Plane(dir primitive.PlaneDir) *Entity

Plane creates and adds a plane.

func (Context) PointLight

func (c Context) PointLight() *Light

PointLight creates and adds a light to gorge context.

func (Context) Renderable

func (c Context) Renderable(mesh gorge.Mesher, mat gorge.Materialer) *Entity

Renderable creates and adds a renderable to gorge context.

func (Context) Sphere

func (c Context) Sphere(sector, stack int) *Entity

Sphere Creates and adds a sphere renderable.

func (Context) SpotLight

func (c Context) SpotLight() *Light

SpotLight creates and adds a new spot light to gorge context.

func (Context) TrackballCamera

func (c Context) TrackballCamera() *CameraRig

TrackballCamera returns a trackball camera controlled from pointer events.

func (Context) UI

func (c Context) UI(cam cameraEntity) *gorgeui.UI

UI returns a gorgeui.New(gorge.Context) with the injected context.

func (Context) UICamera

func (c Context) UICamera() *Camera

UICamera creates an ortho camera and adds to context.

type Contexter

type Contexter interface {
	G() *gorge.Context
	Add(...gorge.Entity)
	event.Handler
}

type Entity

Entity entity.

func AddCube

func AddCube(g gorge.Contexter) *Entity

AddCube to entityAdder.

func AddPlane

func AddPlane(a Contexter, dir primitive.PlaneDir) *Entity

AddPlane to entityAdder.

func AddSphere

func AddSphere(a entityAdder, sector, stack int) *Entity

AddSphere to entityAdder.

func NewCube

func NewCube() *Entity

NewCube returns a new renderable cube.

func NewPlane

func NewPlane(dir primitive.PlaneDir) *Entity

NewPlane returns a new plane.

func NewRenderable

func NewRenderable(mesh gorge.Mesher, mat gorge.Materialer) *Entity

NewRenderable returns a new renderable.

func NewSphere

func NewSphere(sector, stack int) *Entity

NewSphere returns a new renderable sphere.

func (*Entity) SetName

func (r *Entity) SetName(n string)

SetName sets renderable name.

type Geom

type Geom struct {
	*gorge.TransformComponent
	*gorge.Material

	gorge.Container
	// contains filtered or unexported fields
}

Geom helper to draw per frame debug information.

func NewGeom

func NewGeom() *Geom

NewGeom returns a Geom entity.

func (*Geom) AddLine

func (dg *Geom) AddLine(p1 gm.Vec3, p2 gm.Vec3)

AddLine adds a line using the current color.

func (*Geom) AddPoint

func (dg *Geom) AddPoint(p gm.Vec3)

AddPoint adds a single point with the current color..

func (*Geom) AddRect

func (dg *Geom) AddRect(p1, p2, p3, p4 gm.Vec3)

AddRect adds a rect based on 4 points and the current color.

func (*Geom) AddRect3

func (dg *Geom) AddRect3(p1, p2, p3 gm.Vec3)

AddRect3 adds a rect based on 3 points and the current color.

func (*Geom) Clear

func (dg *Geom) Clear()

Clear clear the debug information.

func (*Geom) SetColor

func (dg *Geom) SetColor(r, g, b, a float32)

SetColor set the current color state.

func (*Geom) SetCullMask

func (dg *Geom) SetCullMask(m gorge.CullMaskFlags)

SetCullMask sets the cull mask for the debug renderables.

type GeomEntity

type GeomEntity struct {
	gorge.TransformComponent
	gorge.RenderableComponent
}

GeomEntity generic renderable entity.

type Gimbal

type Gimbal struct {
	Entities []gorge.Entity
	*gorge.TransformComponent
}

Gimbal Compost object

func NewGimbal

func NewGimbal() *Gimbal

NewGimbal creates entities on manager

func (Gimbal) GetEntities

func (g Gimbal) GetEntities() []gorge.Entity

GetEntities implement the gorge entity container.

func (Gimbal) String

func (g Gimbal) String() string

type Light

type Light struct {
	Name string
	gorge.TransformComponent
	gorge.LightComponent
}

Light is a light entity which can be used directly on gorge.

func AddDirectionalLight

func AddDirectionalLight(a Contexter) *Light

func AddLight

func AddLight(a Contexter) *Light

func AddPointLight

func AddPointLight(a Contexter) *Light

func AddSpotLight

func AddSpotLight(a Contexter) *Light

func NewDirectionalLight

func NewDirectionalLight() *Light

NewDirectionalLight returns a directional light.

func NewLight

func NewLight() *Light

NewLight returns a new default light.

func NewPointLight

func NewPointLight() *Light

NewPointLight returns a new PointLight.

func NewSpotLight

func NewSpotLight() *Light

NewSpotLight returns a spot light.

func (*Light) SetName

func (l *Light) SetName(n string)

SetName sets the light name for debugging purposes.

func (*Light) String

func (l *Light) String() string

type MaterialType

type MaterialType int

MaterialType type of the material (within shader)

type MeshEntity

MeshEntity thing

func (MeshEntity) String

func (e MeshEntity) String() string

type PBRMaterial

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

PBRMaterial returns a material controller based on gltf default shader.

func NewPBRMaterial

func NewPBRMaterial() *PBRMaterial

NewPBRMaterial returns a new PBRMaterial with MetallicRoughness type.

func NewUnlitMaterial

func NewUnlitMaterial() *PBRMaterial

NewUnlitMaterial returns a pbr material with unlit defined.

func (*PBRMaterial) Material

func (m *PBRMaterial) Material() *gorge.Material

Material implements gorge materialer

func (*PBRMaterial) SetBaseColor

func (m *PBRMaterial) SetBaseColor(v gm.Vec4)

SetBaseColor sets the base color factor.

func (*PBRMaterial) SetBaseColorMap

func (m *PBRMaterial) SetBaseColorMap(tex *gorge.Texture)

SetBaseColorMap sets the base texture.

func (*PBRMaterial) SetBaseUVTransform

func (m *PBRMaterial) SetBaseUVTransform(v gm.Mat3)

SetBaseUVTransform sets the UV transform matrix.

func (*PBRMaterial) SetHDR

func (m *PBRMaterial) SetHDR(b bool)

SetHDR enables hdr lighting on the shader.

func (*PBRMaterial) SetIBL

func (m *PBRMaterial) SetIBL(b bool)

SetIBL sets image based lighting.

func (*PBRMaterial) SetMetallicFactor

func (m *PBRMaterial) SetMetallicFactor(v float32)

SetMetallicFactor sets the metallic factor.

func (*PBRMaterial) SetMetallicMap

func (m *PBRMaterial) SetMetallicMap(tex *gorge.Texture)

SetMetallicMap separate metallic sampler.

func (*PBRMaterial) SetMetallicRoughnessMap

func (m *PBRMaterial) SetMetallicRoughnessMap(tex *gorge.Texture)

SetMetallicRoughnessMap sets the combined texture of metallic and roughness.

func (*PBRMaterial) SetNormalMap

func (m *PBRMaterial) SetNormalMap(tex *gorge.Texture)

SetNormalMap sets the normal map.

func (*PBRMaterial) SetNormalScale

func (m *PBRMaterial) SetNormalScale(v float32)

SetNormalScale sets the normal scale.

func (*PBRMaterial) SetOcclusionMap

func (m *PBRMaterial) SetOcclusionMap(tex *gorge.Texture)

SetOcclusionMap sets the normal map.

func (*PBRMaterial) SetOcclusionStrength

func (m *PBRMaterial) SetOcclusionStrength(v float32)

SetOcclusionStrength sets the occlusion strength.

func (*PBRMaterial) SetRoughnessFactor

func (m *PBRMaterial) SetRoughnessFactor(v float32)

SetRoughnessFactor sets the metallic factor.

func (*PBRMaterial) SetRoughnessMap

func (m *PBRMaterial) SetRoughnessMap(tex *gorge.Texture)

SetRoughnessMap separate roughness sampler.

func (*PBRMaterial) SetType

func (m *PBRMaterial) SetType(t MaterialType)

SetType sets the material mode.

type ParticleEmitter

type ParticleEmitter struct {
	gorge.TransformComponent
	particle.EmitterComponent

	Life     float32
	Friction float32
	Gravity  gm.Vec3
	Spread   float32
	SpeedMul float32
	Rotation float32
	Color    *anim.Channel[gm.Vec4]
	Scale    *anim.Channel[gm.Vec3]
	// contains filtered or unexported fields
}

ParticleEmitter is a particle emitter and a controller.

func AddParticleEmitter

func AddParticleEmitter(a entityAdder) *ParticleEmitter

func NewParticleEmitter

func NewParticleEmitter() *ParticleEmitter

func (*ParticleEmitter) InitParticle

func (c *ParticleEmitter) InitParticle(p *ParticleEntity)

func (*ParticleEmitter) UpdateParticle

func (c *ParticleEmitter) UpdateParticle(p *ParticleEntity, dt float32)

type ParticleEntity

type ParticleEntity struct {
	gorge.TransformComponent
	gorge.ColorableComponent
	particle.Component

	ColorAnim *anim.Channel[gm.Vec4]
	ScaleAnim *anim.Channel[gm.Vec3]
	// contains filtered or unexported fields
}

ParticleEntity is a particle entity.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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