shapes

package
v0.0.0-...-e996cf0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntersectionEqual

func IntersectionEqual(i1, i2 Intersection) bool

Types

type Basic

type Basic struct {
	Id               int64
	Transform        geom.Mat4x4
	Inverse          geom.Mat4x4
	InverseTranspose geom.Mat4x4
	Material         material.Material
}

type Cube

type Cube struct {
	Basic
	Label string

	CastShadow bool
	// contains filtered or unexported fields
}

func NewCube

func NewCube() *Cube

func (*Cube) CastsShadow

func (c *Cube) CastsShadow() bool

func (*Cube) GetInverse

func (c *Cube) GetInverse() geom.Mat4x4

func (*Cube) GetInverseTranspose

func (c *Cube) GetInverseTranspose() geom.Mat4x4

func (*Cube) GetLocalRay

func (c *Cube) GetLocalRay() geom.Ray

func (*Cube) GetMaterial

func (c *Cube) GetMaterial() material.Material

func (*Cube) GetParent

func (c *Cube) GetParent() Shape

func (*Cube) GetTransform

func (c *Cube) GetTransform() geom.Mat4x4

func (*Cube) ID

func (c *Cube) ID() int64

func (*Cube) Init

func (c *Cube) Init()

func (*Cube) IntersectLocal

func (c *Cube) IntersectLocal(ray geom.Ray, xs *Intersections)

func (*Cube) Name

func (c *Cube) Name() string

func (*Cube) NormalAtLocal

func (c *Cube) NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4

NormalAtLocal uses the fact that given a unit cube, the point of the surface axis X,Y or Z is always either 1.0 for positive XYZ and -1.0 for negative XYZ. I.e - if the point is 0.4, 1, -0.5, we know that the point is on the top Y surface and we can return a 0,1,0 normal

func (*Cube) SetMaterial

func (c *Cube) SetMaterial(material material.Material)

func (*Cube) SetParent

func (c *Cube) SetParent(shape Shape)

func (*Cube) SetTransform

func (c *Cube) SetTransform(transform geom.Mat4x4)

type Cylinder

type Cylinder struct {
	Basic

	MinY float64
	MaxY float64

	CastShadow bool
	// contains filtered or unexported fields
}

func NewCylinder

func NewCylinder() *Cylinder

func NewCylinderMM

func NewCylinderMM(min, max float64) *Cylinder

func NewCylinderMMC

func NewCylinderMMC(min, max float64, closed bool) *Cylinder

func (*Cylinder) CastsShadow

func (c *Cylinder) CastsShadow() bool

func (*Cylinder) GetInverse

func (c *Cylinder) GetInverse() geom.Mat4x4

func (*Cylinder) GetInverseTranspose

func (c *Cylinder) GetInverseTranspose() geom.Mat4x4

func (*Cylinder) GetLocalRay

func (c *Cylinder) GetLocalRay() geom.Ray

func (*Cylinder) GetMaterial

func (c *Cylinder) GetMaterial() material.Material

func (*Cylinder) GetParent

func (c *Cylinder) GetParent() Shape

func (*Cylinder) GetTransform

func (c *Cylinder) GetTransform() geom.Mat4x4

func (*Cylinder) ID

func (c *Cylinder) ID() int64

func (*Cylinder) Init

func (c *Cylinder) Init()

func (*Cylinder) IntersectLocal

func (c *Cylinder) IntersectLocal(ray geom.Ray, xs *Intersections)

func (*Cylinder) NormalAtLocal

func (c *Cylinder) NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4

func (*Cylinder) SetMaterial

func (c *Cylinder) SetMaterial(material material.Material)

func (*Cylinder) SetParent

func (c *Cylinder) SetParent(shape Shape)

func (*Cylinder) SetTransform

func (c *Cylinder) SetTransform(transform geom.Mat4x4)

type Intersection

type Intersection struct {
	T float64
	S Shape
	U float64
	V float64
}

func NewIntersection

func NewIntersection(t float64, s Shape) Intersection

func NewIntersectionUV

func NewIntersectionUV(t float64, s Shape, u, v float64) Intersection

type Intersections

type Intersections []Intersection

func (Intersections) Len

func (xs Intersections) Len() int

func (Intersections) Less

func (xs Intersections) Less(i, j int) bool

func (Intersections) Swap

func (xs Intersections) Swap(i, j int)

type Plane

type Plane struct {
	Basic

	CastShadow bool
	// contains filtered or unexported fields
}

func NewPlane

func NewPlane() *Plane

func (*Plane) CastsShadow

func (p *Plane) CastsShadow() bool

func (*Plane) GetInverse

func (p *Plane) GetInverse() geom.Mat4x4

func (*Plane) GetInverseTranspose

func (p *Plane) GetInverseTranspose() geom.Mat4x4

func (*Plane) GetLocalRay

func (p *Plane) GetLocalRay() geom.Ray

func (*Plane) GetMaterial

func (p *Plane) GetMaterial() material.Material

func (*Plane) GetParent

func (p *Plane) GetParent() Shape

func (*Plane) GetTransform

func (p *Plane) GetTransform() geom.Mat4x4

func (*Plane) ID

func (p *Plane) ID() int64

func (*Plane) IntersectLocal

func (p *Plane) IntersectLocal(ray geom.Ray, xs *Intersections)

func (*Plane) NormalAtLocal

func (p *Plane) NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4

func (*Plane) SetMaterial

func (p *Plane) SetMaterial(m material.Material)

SetMaterial passes a pointer to the Plane on which to set the material

func (*Plane) SetParent

func (p *Plane) SetParent(shape Shape)

func (*Plane) SetTransform

func (p *Plane) SetTransform(translation geom.Mat4x4)

SetTransform passes a pointer to the Plane on which to apply the translation matrix

type Shape

type Shape interface {
	ID() int64
	GetTransform() geom.Mat4x4
	GetInverse() geom.Mat4x4
	GetInverseTranspose() geom.Mat4x4
	SetTransform(transform geom.Mat4x4)
	GetMaterial() material.Material
	SetMaterial(material material.Material)
	IntersectLocal(ray geom.Ray, xs *Intersections)
	NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4
	GetLocalRay() geom.Ray
	GetParent() Shape
	SetParent(shape Shape)
	CastsShadow() bool
}

type Sphere

type Sphere struct {
	Basic

	CastShadow bool
	// contains filtered or unexported fields
}

func NewSphere

func NewSphere() *Sphere

func (*Sphere) CastsShadow

func (s *Sphere) CastsShadow() bool

func (*Sphere) GetInverse

func (s *Sphere) GetInverse() geom.Mat4x4

func (*Sphere) GetInverseTranspose

func (s *Sphere) GetInverseTranspose() geom.Mat4x4

func (*Sphere) GetLocalRay

func (s *Sphere) GetLocalRay() geom.Ray

func (*Sphere) GetMaterial

func (s *Sphere) GetMaterial() material.Material

func (*Sphere) GetParent

func (s *Sphere) GetParent() Shape

func (*Sphere) GetTransform

func (s *Sphere) GetTransform() geom.Mat4x4

func (*Sphere) ID

func (s *Sphere) ID() int64

func (*Sphere) IntersectLocal

func (s *Sphere) IntersectLocal(ray geom.Ray, xs *Intersections)

IntersectLocal implements Sphere-ray intersection

func (*Sphere) NormalAtLocal

func (s *Sphere) NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4

func (*Sphere) SetMaterial

func (s *Sphere) SetMaterial(m material.Material)

SetMaterial passes a pointer to the Sphere on which to set the material

func (*Sphere) SetParent

func (s *Sphere) SetParent(shape Shape)

func (*Sphere) SetTransform

func (s *Sphere) SetTransform(translation geom.Mat4x4)

SetTransform passes a pointer to the Sphere on which to apply the translation matrix

Jump to

Keyboard shortcuts

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