Documentation ¶
Overview ¶
Package wavefront implements functions to parse Wavefront OBJ files and transform the data. This is not meant to be a fully compliant parser but rather something good enough that allows for easy use of triangle meshes.
Index ¶
- Variables
- type Face
- type Group
- type Material
- type ObjFaceType
- type ParseOption
- type VertexIndices
- type WavefrontObj
- func (wo *WavefrontObj) GroupToHitablesWithCustomMaterial(index int, mat material.Material) ([]hitable.Hitable, error)
- func (wo *WavefrontObj) GroupToHitablesWithCustomMaterialAndDisplacement(index int, mat material.Material, displacementMap texture.Texture, ...) ([]hitable.Hitable, error)
- func (wo *WavefrontObj) NumGroups() int
- func (wo *WavefrontObj) Scale(scale *vec3.Vec3Impl)
- func (wo *WavefrontObj) Translate(translate *vec3.Vec3Impl)
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedPolygonType = errors.New("unsupported polygon type") ErrInvalidFaceData = errors.New("invalid face data") )
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct { Name string FaceType ObjFaceType Material string Faces []*Face }
Group represents a single group.
type Material ¶
type Material struct { Name string Kd []float64 Ka []float64 Ks []float64 Ns float64 Ni float64 Sharpness int64 D float64 Illum int64 }
Material represents a material defined in a .mtl file.
type ObjFaceType ¶
type ObjFaceType int
const ( OBJ_FACE_TYPE_INVALID ObjFaceType = iota OBJ_FACE_TYPE_POLYGON )
type ParseOption ¶
type ParseOption int
const ( INVALID_OPTION ParseOption = iota IGNORE_NORMALS IGNORE_MATERIALS IGNORE_TEXTURES )
type VertexIndices ¶
VertexIndices represents the indices used by a vertex.
type WavefrontObj ¶
type WavefrontObj struct { IgnoreMaterials bool IgnoreNormals bool IgnoreTextures bool HasNormals bool HasUV bool Centre *vec3.Vec3Impl ObjectName string Vertices []*vec3.Vec3Impl VertexNormals []*vec3.Vec3Impl VertexUV []*texture.UV MtlLib map[string]*Material Groups []*Group }
WavefrontObj represents the data contained in a Wavefront OBJ file.
func NewObjFromReader ¶
func NewObjFromReader(r io.Reader, containerDirectory string, opts ...ParseOption) (*WavefrontObj, error)
NewObjFromReader returns WavefrontObj with the geometry contained in a Wavefront .obj file.
func (*WavefrontObj) GroupToHitablesWithCustomMaterial ¶
func (wo *WavefrontObj) GroupToHitablesWithCustomMaterial(index int, mat material.Material) ([]hitable.Hitable, error)
GroupToHitablesWithCustomMaterial returns a slice of hitables with the supplied material.
func (*WavefrontObj) GroupToHitablesWithCustomMaterialAndDisplacement ¶
func (wo *WavefrontObj) GroupToHitablesWithCustomMaterialAndDisplacement(index int, mat material.Material, displacementMap texture.Texture, min, max float64) ([]hitable.Hitable, error)
GroupToHitablesWithCustomMaterialAndDisplacement returns a slice of displaced hitables with the supplied material.
func (*WavefrontObj) NumGroups ¶
func (wo *WavefrontObj) NumGroups() int
func (*WavefrontObj) Scale ¶
func (wo *WavefrontObj) Scale(scale *vec3.Vec3Impl)
Scale scales all the vertices in this object by the specified amount.
func (*WavefrontObj) Translate ¶
func (wo *WavefrontObj) Translate(translate *vec3.Vec3Impl)
Translate translates all the vertices in this object by the specified amount.