scene

package
v0.0.0-...-9c88ebf Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Camera

type Camera struct {
	d3.Pt
	Rot *d3.T
	// Angle of the lens relative to the Width.
	Angle angle.Rad
	Size  grid.Pt
}

Camera can be placed in a scene when rendering.

func NewCamera

func NewCamera(pt d3.Pt, a angle.Rad) *Camera

NewCamera creates a camera, it is intended to be setup with chained calls.

func (*Camera) ByAspect

func (c *Camera) ByAspect(w int, a grid.Aspect) *Camera

ByAspect sets the size from a width and aspect.

func (*Camera) Fullscreen

func (c *Camera) Fullscreen(w int) *Camera

Fullscreen aspect ratio and the provided width to set the size.

func (*Camera) SetRot

func (c *Camera) SetRot(r d3.TGen) *Camera

SetRot on the camera from a transform generator. If the generator has a Normalize method, that will be called.

func (*Camera) SetSize

func (c *Camera) SetSize(w, h int) *Camera

SetSize by width and height.

func (*Camera) Square

func (c *Camera) Square(w int) *Camera

Square aspect ratio and the provided width to set the size.

func (*Camera) Widescreen

func (c *Camera) Widescreen(w int) *Camera

Widescreen aspect ratio and the provided width to set the size.

type CameraFactory

type CameraFactory interface {
	Camera(frameIdx int) *Camera
}

CameraFactory produces a camera per frame.

type Frame

type Frame struct {
	Camera *Camera
	Meshes []*FrameMesh
}

Frame holds the camera to produce the frame and the meshes to render.

func (*Frame) AddMesh

func (f *Frame) AddMesh(original *mesh.TriangleMesh, t *d3.T, shader interface{})

AddMesh to a sceneframe. The transform will be applied to all the points in the original mesh.

func (*Frame) TriangleCount

func (f *Frame) TriangleCount() int

TriangleCount is the total number of triangles in the frame.

type FrameMesh

type FrameMesh struct {
	Original *mesh.TriangleMesh
	Shader   interface{}
	Space    []d3.Pt
}

FrameMesh represents a mesh transformed for a specific frame. The Space slice holds the points of the mesh on the specific frame.

type Mesh

type Mesh struct {
	Original *mesh.TriangleMesh
	TransformFactory
	Shader interface{}
}

Mesh is used to generate a FrameMesh.

func (*Mesh) Frame

func (m *Mesh) Frame(idx int) *FrameMesh

Frame generates the FrameMesh for a specific frame.

type Scene

type Scene struct {
	CameraFactory
	Meshes     []*Mesh
	FrameCount int
	ImgSize    grid.Pt
}

Scene is used to generate the camera and meshest for a sequence of frames. Size will populate the size on the camera if the CameraFactory does not set the size.

func NewScene

func NewScene(camera CameraFactory, meshes int) *Scene

NewScene creates Scene and allocates the Mesh slice.

func (*Scene) AddMesh

func (s *Scene) AddMesh(original *mesh.TriangleMesh, tf TransformFactory, shader interface{})

AddMesh appends a Mesh to the scene.

func (*Scene) Frame

func (s *Scene) Frame(frameIdx int) *Frame

Frame generates a specific SceneFrame.

func (*Scene) Frames

func (s *Scene) Frames() int

Frames is the length of the scene and fullfils Framer.

func (*Scene) Size

func (s *Scene) Size() grid.Pt

Size returns the scene size and fulfills Sizer.

type TransformFactory

type TransformFactory interface {
	T(frameIdx int) *d3.T
}

TransformFactory produces a transform per frame index.

type TriangleIndex

type TriangleIndex struct {
	MeshIdx     int
	PolygonIdx  int
	TriangleIdx int
}

TriangleIndex provides an index to a specific triangle in a SceneFrame.

Jump to

Keyboard shortcuts

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