Documentation ¶
Index ¶
- Variables
- func NormalAt(xs Intersection, worldPoint ray.Vector) ray.Vector
- type BasicObject
- type Group
- func (g *Group) AddChild(children ...Object)
- func (g Group) LocalIntersect(r ray.Ray) (xs Intersections)
- func (g Group) LocalNormalAt(worldPoint ray.Vector, _ Intersection) ray.Vector
- func (o Group) Material() Material
- func (o Group) NormalToWorld(normaVector ray.Vector) (resultVector ray.Vector)
- func (g Group) Object() Object
- func (o Group) Parent() Object
- func (o *Group) SetMaterial(m Material)
- func (o *Group) SetParent(obj Object)
- func (o *Group) SetTransform(t ray.Matrix) error
- func (o Group) Transform() ray.Matrix
- func (o Group) TransformInverse() ray.Matrix
- func (o Group) WorldToObject(worldPoint ray.Vector) (point ray.Vector)
- type Intersection
- type Intersections
- type Material
- type Object
- func DefaultCone() Object
- func DefaultCylinder() Object
- func DefaultGlassSphere() Object
- func DefaultMetalSphere() Object
- func DefaultSphere(opts ...Option) Object
- func NewCone(minimum, maximum float64, closed bool) Object
- func NewCube() Object
- func NewCylinder(minimum, maximum float64, closed bool) Object
- func NewGlassSphere(center ray.Vector, radius float64, opts ...Option) (s Object)
- func NewHexagon(opts ...Option) (hex Object)
- func NewMetalSphere(center ray.Vector, radius float64, opts ...Option) (s Object)
- func NewPlane(opts ...Option) Object
- func NewSmoothTriangle(p1, p2, p3, n1, n2, n3 ray.Vector, opts ...Option) Object
- func NewSphere(center ray.Vector, radius float64, opts ...Option) Object
- func NewTestShape(opts ...Option) Object
- func NewTriangle(p1, p2, p3 ray.Vector, opts ...Option) Object
- type Option
- type OptionFunc
- type Pattern
- type PointLight
- type RGB
- type StripePattern
- type WavefrontObj
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Black = NewColor(0, 0, 0) White = NewColor(1, 1, 1) Red = NewColor(1, 0, 0) Green = NewColor(0, 1, 0) Blue = NewColor(0, 0, 1) )
View Source
var NoHit = Intersection{}
Functions ¶
Types ¶
type BasicObject ¶
type Group ¶
type Group struct { Children []Object // contains filtered or unexported fields }
func (Group) LocalIntersect ¶
func (g Group) LocalIntersect(r ray.Ray) (xs Intersections)
func (Group) LocalNormalAt ¶
func (Group) NormalToWorld ¶
func (*Group) SetMaterial ¶
func (o *Group) SetMaterial(m Material)
func (*Group) SetTransform ¶
func (Group) TransformInverse ¶
type Intersection ¶
type Intersection struct { T float64 // Intersection value Obj Object // Intersected object U, V float64 // UV value between 0 - 1 }
func Hit ¶
func Hit(intersections Intersections) Intersection
type Intersections ¶
type Intersections []Intersection
type Material ¶
type Material struct { Color RGB Pattern Pattern Ambient, Diffuse, Specular, Shininess, Reflective, Transparency, RefractiveIndex float64 }
func DefaultMaterial ¶
func DefaultMaterial() Material
func NewMaterial ¶
type Object ¶
type Object interface { LocalIntersect(ray ray.Ray) Intersections LocalNormalAt(worldPoint ray.Vector, hit Intersection) ray.Vector Transform() ray.Matrix TransformInverse() ray.Matrix SetTransform(t ray.Matrix) error Material() (m Material) SetMaterial(m Material) Parent() Object SetParent(obj Object) WorldToObject(worldPoint ray.Vector) (point ray.Vector) NormalToWorld(normalVector ray.Vector) (vector ray.Vector) }
func DefaultCone ¶
func DefaultCone() Object
func DefaultCylinder ¶
func DefaultCylinder() Object
func DefaultGlassSphere ¶
func DefaultGlassSphere() Object
func DefaultMetalSphere ¶
func DefaultMetalSphere() Object
func DefaultSphere ¶
func NewCylinder ¶
func NewGlassSphere ¶
func NewHexagon ¶
func NewMetalSphere ¶
func NewSmoothTriangle ¶
func NewTestShape ¶
type Option ¶
type Option interface {
Apply(object Object)
}
func WithChildren ¶
func WithMaterial ¶
func WithNormals ¶
func WithTransform ¶
type OptionFunc ¶
type OptionFunc func(object Object)
func (OptionFunc) Apply ¶
func (of OptionFunc) Apply(o Object)
type Pattern ¶
type Pattern struct { Transform ray.Matrix TransformInverse ray.Matrix At func(point ray.Vector) RGB IsNotEmpty bool }
func EmptyPattern ¶
func EmptyPattern() Pattern
func NewCheckerPattern ¶
func NewGradientPattern ¶
func NewRingPattern ¶
func NewStripePattern ¶
func NewTestPattern ¶
func NewTestPattern() (p Pattern)
type PointLight ¶
func NewPointLight ¶
func NewPointLight(position ray.Vector, intensity RGB) PointLight
type RGB ¶
type RGB struct {
R, G, B float64
}
func (RGB) MultiplyBy ¶
type StripePattern ¶
type WavefrontObj ¶
func NewWavefrontObj ¶
func NewWavefrontObj(reader io.Reader, opts ...Option) (wv WavefrontObj, err error)
func (*WavefrontObj) Object ¶
func (w *WavefrontObj) Object() Object
Click to show internal directories.
Click to hide internal directories.