Documentation
¶
Index ¶
- Variables
- type Material
- type Matrix
- type Mesh
- type Ray
- type Scene
- type Texture
- type Triangle
- type Vector
- func (a Vector) Abs() Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) CompareVectors(b Vector, tolerance float64) bool
- func (a Vector) Cross(b Vector) Vector
- func (a Vector) Div(b float64) Vector
- func (a Vector) DivVec(b Vector) Vector
- func (a Vector) Dot(b Vector) float64
- func (a Vector) Equals(b Vector) bool
- func (a Vector) FloatToColor() color.NRGBA
- func (a Vector) Len() float64
- func (a Vector) Lerp(b Vector, n float64) Vector
- func (a Vector) Mul(n float64) Vector
- func (a Vector) MulVec(b Vector) Vector
- func (a Vector) Negate() Vector
- func (a Vector) Normalize() Vector
- func (a Vector) Square() Vector
- func (a Vector) String() string
- func (a Vector) Sub(b Vector) Vector
- type Vertex
Constants ¶
This section is empty.
Variables ¶
var ( Zero = Vector{0, 0, 0} One = Vector{1, 1, 1} Forward = Vector{0, 1, 0} Back = Vector{0, -1, 0} Left = Vector{-1, 0, 0} Right = Vector{1, 0, 0} Up = Vector{0, 0, 1} Down = Vector{0, 0, -1} )
Unit Vectors
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
Matrix represents a 3x3 matrix
func (Matrix) MulDirection ¶
MulDirection multiplies Matrix 'a' by a Vector 'b' It returns a normalized Vector
type Mesh ¶
Mesh describes a 3D object
func (*Mesh) ReadOBJ ¶
ReadOBJ return Mesh object read from the OBJ file, based on pathToFile It needs a Material slice in order to add material to each triangle in the mesh
func (*Mesh) ReadPLY ¶
ReadPLY adds to Mesh object vertex color values read from the PLY file, based on pathToFile
func (*Mesh) ReadTexturesToMaterials ¶ added in v1.1.0
ReadTexturesToMaterials read textures data into each material Texture names are based on material name
type Ray ¶
type Ray struct {
Origin, Direction Vector
Distance float64
MaxFrontalDistance float64
MaxRearDistance float64
}
Ray describes a 3-dimensional ray with an origin and a direction Vector It also contains two distance values, used to checks intersection with multiple surfaces
func (Ray) HitPosition ¶
HitPosition return 3D coordinates of a ray intersetion
type Scene ¶
type Scene struct {
Lowpoly Mesh
Highpoly Mesh
BakedDiffuse *Texture
//BakedNormal *Texture
//BakedObjectNormal *Texture
BakedID *Texture
OutputSize int
ReadID bool
MaxFrontalDistance float64
MaxRearDistance float64
}
Scene represents an object in which baking process is being handled It cointais a lowpoly and highpoly meshes and output textures with their final size
func (*Scene) Bake ¶
Bake processes each pixel of an output texture it computes each texture in one process\
func (*Scene) ReadTexturesForHighpoly ¶ added in v1.1.0
ReadTexturesForHighpoly read textures into highpoly model
type Texture ¶
Texture defines image texture
func LoadTexture ¶
LoadTexture loads texture object from png or jpg file with name 'n'
func (*Texture) SamplePixel ¶
SamplePixel return color of a pixel in u and v coordinates on image
type Triangle ¶
type Triangle struct {
V0, V1, V2 Vertex // Each triangle vertex
Tangent Vector
Bitangent Vector
Normal Vector
Bar Vector // Baricentric coordinates from intersection with a ray
Material *Material
Distance float64
// contains filtered or unexported fields
}
Triangle describes single triangle of a 3D mesh
func (Triangle) Barycentric ¶
Barycentric return barycentric coorditnates based on UV position of a triangle.
type Vector ¶
type Vector struct {
X, Y, Z float64
}
Vector defines 3 point or axis with X,Y,Z values
func Barycentric ¶
Barycentric performs a barycentric interpolation between 3 Vectors 'a', 'b' and 'c' based on values of a Vector 'l'.
func ColorToFloat ¶
ColorToFloat converts uint8 values into 0.0-1.0 number in Vector format.
func ParseVector ¶
ParseVector parses 3 string values into a Vector.
func ParseVectorFromString ¶
ParseVectorFromString parses string values seperated with comma into a Vector.
func (Vector) CompareVectors ¶
CompareVectors compares 2 vectors values with given tolerance
func (Vector) FloatToColor ¶
FloatToColor converts 0.0-1.0 number into color.NRGBA format.