Documentation ¶
Overview ¶
Package obj is used to parse the Wavefront OBJ file format (*.obj), including associated materials (*.mtl). Not all features of the OBJ format are supported. Basic format info: https://en.wikipedia.org/wiki/Wavefront_.obj_file
Index ¶
- type Decoder
- func (dec *Decoder) Decode(rs []io.Reader) error
- func (dec *Decoder) Desc() string
- func (dec *Decoder) Destroy()
- func (dec *Decoder) HasScene() bool
- func (dec *Decoder) New() xyz.Decoder
- func (dec *Decoder) SetFileFS(fsys fs.FS, fname string) ([]string, error)
- func (dec *Decoder) SetGroup(sc *xyz.Scene, gp *xyz.Group)
- func (dec *Decoder) SetMat(sc *xyz.Scene, sld *xyz.Solid, matnm string)
- func (dec *Decoder) SetObject(sc *xyz.Scene, objgp *xyz.Group, ob *Object)
- func (dec *Decoder) SetScene(sc *xyz.Scene)
- type Face
- type Material
- type Object
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct { FSys fs.FS // filesystem, used for all loading Objfile string // .obj filename within FSys Objects []Object // decoded objects Matlib string // name of the material lib Materials map[string]*Material // maps material name to object Vertices mat32.ArrayF32 // vertices positions array Normals mat32.ArrayF32 // vertices normals Uvs mat32.ArrayF32 // vertices texture coordinates Warnings []string // warning messages // contains filtered or unexported fields }
Decoder contains all decoded data from the obj and mtl files. It also implements the xyz.Decoder interface and an instance is registered to handle .obj files.
func (*Decoder) Decode ¶
Decode reads the given data and decodes into Decoder tmp vars. if 2 args are passed, first is .obj and second is .mtl
func (*Decoder) SetGroup ¶
SetGroup sets group with with all the decoded objects. calls Destroy after to free memory
type Face ¶
type Face struct { Vertices []int // Indices to the face vertices Uvs []int // Indices to the face UV coordinates Normals []int // Indices to the face normals Material string // Material name Smooth bool // Smooth face }
Face contains all information about an object face
type Material ¶
type Material struct { Name string // Material name Illum int // Illumination model Opacity float32 // Opacity factor Refraction float32 // Refraction factor Shininess float32 // Shininess (specular exponent) Ambient color.RGBA // Ambient color reflectivity Diffuse color.RGBA // Diffuse color reflectivity Specular color.RGBA // Specular color reflectivity Emissive color.RGBA // Emissive color MapKd string // Texture file linked to diffuse color Tiling xyz.Tiling // Tiling parameters: repeat and offset }
Material contains all information about an object material