gwob

package module
v0.0.0-...-eaf1cac Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: MIT Imports: 8 Imported by: 0

README

license GoDoc Go Report Card

gwob

gwob - Pure Go Golang parser for Wavefront .OBJ 3D geometry file format

Usage

Get the package:

$ go get github.com/udhos/gwob

Import the package in your Go program:

import "github.com/udhos/gwob" 

See the GoDoc documentation.

Documentation

Index

Constants

View Source
const FATAL = true
View Source
const NON_FATAL = false

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	Name       string
	Smooth     int
	Usemtl     string
	IndexBegin int
	IndexCount int
}

type Material

type Material struct {
	Name       string
	Map_Kd     string
	Kd, Ks, Ke [3]float64
	D          float64
	Refr       float64
	Ns         float64
}

type MaterialLib

type MaterialLib struct {
	Lib map[string]*Material
}

func NewMaterialLib

func NewMaterialLib() MaterialLib

func ReadMaterialLibFromBuf

func ReadMaterialLibFromBuf(buf []byte, options *ObjParserOptions) (MaterialLib, error)

func ReadMaterialLibFromReader

func ReadMaterialLibFromReader(rd *bufio.Reader, options *ObjParserOptions) (MaterialLib, error)

type Obj

type Obj struct {
	Indices []int
	Coord   []float64 // vertex data pos=(x,y,z) tex=(tx,ty) norm=(nx,ny,nz)
	Mtllib  string
	Groups  []*Group

	BigIndexFound  bool // index larger than 65535
	TextCoordFound bool // texture coord
	NormCoordFound bool // normal coord

	StrideSize           int // (px,py,pz),(tu,tv),(nx,ny,nz) = 8 x 4-byte floats = 32 bytes max
	StrideOffsetPosition int // 0
	StrideOffsetTexture  int // 3 x 4-byte floats
	StrideOffsetNormal   int // 5 x 4-byte floats
}

func NewObjFromBuf

func NewObjFromBuf(objName string, buf []byte, options *ObjParserOptions) (*Obj, error)

func NewObjFromReader

func NewObjFromReader(objName string, rd *bufio.Reader, options *ObjParserOptions) (*Obj, error)

func NewObjFromVertex

func NewObjFromVertex(objName string, coord []float64, indices []int) (*Obj, error)

func (*Obj) Coord64

func (o *Obj) Coord64(i int) float64

func (*Obj) NormCoordinates

func (o *Obj) NormCoordinates(stride int) (float64, float64, float64)

func (*Obj) NumberOfElements

func (o *Obj) NumberOfElements() int

func (*Obj) TextCoordinates

func (o *Obj) TextCoordinates(stride int) (float64, float64)

func (*Obj) VertexCoordinates

func (o *Obj) VertexCoordinates(stride int) (float64, float64, float64)

type ObjParserOptions

type ObjParserOptions struct {
	LogStats      bool
	Logger        func(string)
	IgnoreNormals bool
}

Jump to

Keyboard shortcuts

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