scene

package
v0.0.0-...-da3de13 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const EPSILON = 0.001

Variables

This section is empty.

Functions

This section is empty.

Types

type AABB

type AABB struct {
	Min, Max vecmath.Vec3dA
}

Axis aligned bounding box

func MakeAABB

func MakeAABB(x, y, z, xm, ym, zm float32) AABB

func MakeAABBV

func MakeAABBV(v1, v2 vecmath.Vec3d) AABB

func (*AABB) Center

func (self *AABB) Center() vecmath.Vec3d

func (*AABB) Contains

func (self *AABB) Contains(other *AABB) bool

func (*AABB) Expand

func (self *AABB) Expand(other *AABB)

func (*AABB) Intersects

func (self *AABB) Intersects(ray *Ray, distanceRequired float32) bool

func (*AABB) IntersectsBasic

func (self *AABB) IntersectsBasic(ray *Ray) bool

func (*AABB) Overlaps

func (self *AABB) Overlaps(other *AABB) bool

type FloatColor

type FloatColor struct {
	R, G, B float32
}

Color whose components are represented as float value in the range [0; 1]

func MakeFloatColor

func MakeFloatColor(color color.RGBA) FloatColor

func (*FloatColor) Add

func (self *FloatColor) Add(other FloatColor)

func (*FloatColor) Added

func (self *FloatColor) Added(other FloatColor) FloatColor

func (*FloatColor) Blend

func (self *FloatColor) Blend(factor float32, otherColor FloatColor)

func (*FloatColor) Multiplied

func (self *FloatColor) Multiplied(other FloatColor) FloatColor

func (FloatColor) RGBA

func (self FloatColor) RGBA() (r, g, b, a uint32)

Satisfy color interface

func (*FloatColor) Scaled

func (self *FloatColor) Scaled(scalar float32) FloatColor

type LightSource

type LightSource struct {
	Position          vecmath.Vec3d
	Diffuse, Specular FloatColor
}

A point light source

func MakeColoredLight

func MakeColoredLight(position vecmath.Vec3d, color color.RGBA) LightSource

Create a simple colored light with default specularity

type Material

type Material struct {
	Ambient      FloatColor
	Diffuse      FloatColor
	Specular     FloatColor
	Specularity  float32
	Reflectivity float32
	Transparency float32

	RefractionIndex float32
}

func MakeSimpleMaterial

func MakeSimpleMaterial(color color.RGBA) Material

type Plane

type Plane struct {
	TraceableBase

	DistanceToOrigin float32
	PlaneNormal      vecmath.Vec3d

	// Due to the plane being infinite, it's impossible (or rather, it's
	// pointless) to determine its bounding box. So we allow specifying one
	// instead.
	AssignedBounds AABB
}

An infinite plane

func MakePlane

func MakePlane(distance float32, normal vecmath.Vec3d) *Plane

func (*Plane) Bounds

func (self *Plane) Bounds() AABB

func (*Plane) CheckIntersection

func (self *Plane) CheckIntersection(ray *Ray) (bool, float32)

func (*Plane) Normal

func (self *Plane) Normal(intersection *vecmath.Vec3d) vecmath.Vec3d

type Ray

type Ray struct {
	Origin    vecmath.Vec3d
	Direction vecmath.Vec3d
}

func (*Ray) PointAt

func (self *Ray) PointAt(distance float32) vecmath.Vec3d

type Sphere

type Sphere struct {
	TraceableBase

	SphereIntersectionInfo
}

func MakeSimpleSphere

func MakeSimpleSphere(pos vecmath.Vec3d, radius float32) *Sphere

func MakeSphere

func MakeSphere(pos vecmath.Vec3d, radius float32, material Material) *Sphere

func (*Sphere) Bounds

func (self *Sphere) Bounds() AABB

func (*Sphere) Normal

func (self *Sphere) Normal(intersection *vecmath.Vec3d) vecmath.Vec3d

type SphereIntersectionInfo

type SphereIntersectionInfo struct {
	Pos    vecmath.Vec3d
	Radius float32
}

"Hot" sphere data optimized for fast cache-friendly access

func (*SphereIntersectionInfo) CheckIntersection

func (self *SphereIntersectionInfo) CheckIntersection(ray *Ray) (bool, float32)

type Traceable

type Traceable interface {

	// Do we intersect ray? If so, return distance from ray origin to
	// point of intersection
	CheckIntersection(ray *Ray) (bool, float32)

	// Surface normal at given intersection point
	Normal(intersection *vecmath.Vec3d) vecmath.Vec3d

	Material() *Material

	Bounds() AABB
}

Thing that can be intersected with rays and thus rendered via ray tracing

type TraceableBase

type TraceableBase struct {
	ObjectMaterial Material
}

Base class for traceables

func (*TraceableBase) Material

func (self *TraceableBase) Material() *Material

Jump to

Keyboard shortcuts

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