fileformats

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MTLFile

type MTLFile struct {
	Materials []*MTLFileMaterial
}

MTLFile represents the contents of a Wavefront mtl file, which is a companion of an obj file.

func (*MTLFile) Write

func (m *MTLFile) Write(w io.Writer) error

type MTLFileMaterial

type MTLFileMaterial struct {
	Name             string
	Ambient          [3]float32
	Diffuse          [3]float32
	Specular         [3]float32
	SpecularExponent float32

	// Texture maps
	AmbientMap   *MTLFileTextureMap
	DiffuseMap   *MTLFileTextureMap
	SpecularMap  *MTLFileTextureMap
	HighlightMap *MTLFileTextureMap
}

MTLFileMaterial is a single material in an MTLFile.

func (*MTLFileMaterial) Write

func (m *MTLFileMaterial) Write(w io.Writer) error

Write encodes m to a writer w.

type MTLFileTextureMap

type MTLFileTextureMap struct {
	Filename string

	// May be nil.
	Options map[string]string
}

MTLFileTextureMap is a configured texture map for an MTLFileMaterial.

type OBJFile

type OBJFile struct {
	MaterialFiles []string

	Vertices   [][3]float64
	UVs        [][2]float64
	Normals    [][3]float64
	FaceGroups []*OBJFileFaceGroup
}

An OBJFile represents the contents of a Wavefront obj file.

func (*OBJFile) Write

func (o *OBJFile) Write(w io.Writer) error

Write encodes the file to w and returns the first write error encountered.

type OBJFileFaceGroup

type OBJFileFaceGroup struct {
	// Material is the material name, or "" by default.
	Material string

	// Each face has three vertices, which itself has a
	// vertex, texture, and normal index.
	// If a texture or normal index is 0, it is omitted.
	Faces [][3][3]int
}

An OBJFileFaceGroup is a group of faces with one material in a Wavefront obj file.

type OFFReader

type OFFReader struct {
	// contains filtered or unexported fields
}

An OFFReader reads an OFF file.

For info on the OFF format, see http://segeval.cs.princeton.edu/public/off_format.html.

func NewOFFReader

func NewOFFReader(r io.Reader) (o *OFFReader, err error)

NewOFFReader reads the header from an OFF file and returns the new reader, if successful.

func (*OFFReader) NumFaces

func (o *OFFReader) NumFaces() int

NumFaces returns the total number of faces.

func (*OFFReader) ReadFace

func (o *OFFReader) ReadFace() (faces [][3]float64, err error)

ReadFace reads the next face. If vertices have not been read, they will be loaded first.

If no more faces exist to be read, io.EOF is returned as the error.

type PLYWriter

type PLYWriter struct {
	// contains filtered or unexported fields
}

A PLYWriter encodes a PLY writable stream.

This may use buffering as it writes the file, but the full file will always be flushed by the time the last triangle is written.

func NewPLYWriter

func NewPLYWriter(w io.Writer, numCoords, numTris int) (*PLYWriter, error)

NewPLYWriter creates a new PLYWriter and writes the file header.

func (*PLYWriter) WriteCoord

func (p *PLYWriter) WriteCoord(c [3]float64, color [3]uint8) (err error)

WriteCoord writes the next coordinate to the file.

This should be called exactly numCoords times.

func (*PLYWriter) WriteTriangle

func (p *PLYWriter) WriteTriangle(coords [3]int) (err error)

WriteTriangle writes the next triangle to the file.

This should be called exactly numTris times.

type STLReader

type STLReader struct {
	// contains filtered or unexported fields
}

An STLReader reads STL files.

func NewSTLReader

func NewSTLReader(r io.Reader) (*STLReader, error)

NewSTLReader creates an STL reader by reading the header of an STL file.

func (*STLReader) NumTriangles

func (s *STLReader) NumTriangles() uint32

NumTriangles gets the total number of triangles in the file as reported by the header.

func (*STLReader) ReadTriangle

func (s *STLReader) ReadTriangle() (normal [3]float32, vertices [3][3]float32, err error)

ReadTriangle reads the next triangle from the file.

type STLWriter

type STLWriter struct {
	// contains filtered or unexported fields
}

An STLWriter writes a triangle mesh in the STL format.

func NewSTLWriter

func NewSTLWriter(w io.Writer, numTris uint32) (*STLWriter, error)

NewSTLWriter creates an STLWriter and writes a header, which requires knowledge of the total number of triangles being written.

func (*STLWriter) WriteTriangle

func (s *STLWriter) WriteTriangle(normal [3]float32, faces [3][3]float32) error

WriteTriangle writes a triangle to the file.

This should be called exactly the number of times passed to NewSTLWriter.

type SVGWriter added in v0.2.23

type SVGWriter struct {
	// contains filtered or unexported fields
}

An SVGWriter encodes paths to SVG files.

func NewSVGWriter added in v0.2.23

func NewSVGWriter(w io.Writer, viewbox [4]float64) (*SVGWriter, error)

NewSVGWriter creates writes an SVG header and returns a new SVGWriter.

The viewbox argument specifies the bounding box of the image as [minX, minY, width, height].

func (*SVGWriter) WriteEnd added in v0.2.23

func (s *SVGWriter) WriteEnd() error

WriteEnd writes any necessary footer information.

func (*SVGWriter) WritePoly added in v0.2.23

func (s *SVGWriter) WritePoly(points [][2]float64, attrs map[string]string) error

WritePoly writes a polygon or a polyline depending on whether the final point matches up with the first.

Jump to

Keyboard shortcuts

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