objectfile

package
v0.0.0-...-a2f5cd9 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Declaration

type Declaration struct {
	Vertex int
	UV     int
	Normal int

	// Pointers to actual geometry values.
	// When serialized to string, the index is read from ref
	// if available. This enables easy geometry rewrites.
	RefVertex, RefUV, RefNormal *GeometryValue
}

zero value means it was not declared, should not be written @note exception: if sibling declares it, must be written eg. 1//2

func (*Declaration) Equals

func (d *Declaration) Equals(other *Declaration) bool

func (*Declaration) Index

func (d *Declaration) Index(t Type) int

Use this getter when possible index rewrites has occurred. Will first return index from geometry value pointers, if available.

type Geometry

type Geometry struct {
	Vertices []*GeometryValue // v    x y z [w]
	Normals  []*GeometryValue // vn   i j k
	UVs      []*GeometryValue // vt   u [v [w]]
	Params   []*GeometryValue // vp   u v [w]
}

func NewGeometry

func NewGeometry() *Geometry

func (*Geometry) Get

func (g *Geometry) Get(t Type) []*GeometryValue

func (*Geometry) ReadValue

func (g *Geometry) ReadValue(t Type, value string, strict bool) (*GeometryValue, error)

func (*Geometry) Set

func (g *Geometry) Set(t Type, values []*GeometryValue)

func (*Geometry) Stats

func (g *Geometry) Stats() GeometryStats

type GeometryStats

type GeometryStats struct {
	Vertices, Normals, UVs, Params int
}

func (GeometryStats) IsEmpty

func (gs GeometryStats) IsEmpty() bool

func (GeometryStats) Num

func (gs GeometryStats) Num(t Type) int

type GeometryValue

type GeometryValue struct {
	Index      int
	Discard    bool
	X, Y, Z, W float64
}

func (*GeometryValue) Distance

func (gv *GeometryValue) Distance(to *GeometryValue) float64

func (*GeometryValue) Equals

func (gv *GeometryValue) Equals(other *GeometryValue, epsilon float64) bool

func (*GeometryValue) String

func (gv *GeometryValue) String(t Type) (out string)

type Material

type Material struct {
	Mtllib string
	Name   string
}

type OBJ

type OBJ struct {
	Geometry          *Geometry
	MaterialLibraries []string

	Objects  []*Object
	Comments []string
}

func NewOBJ

func NewOBJ() *OBJ

func (*OBJ) CreateObject

func (o *OBJ) CreateObject(t Type, name, material string) *Object

func (*OBJ) ObjectWithType

func (o *OBJ) ObjectWithType(t Type) (objects []*Object)

func (*OBJ) Stats

func (o *OBJ) Stats() ObjStats

type ObjStats

type ObjStats struct {
	Objects  int
	Groups   int
	Faces    int
	Lines    int
	Points   int
	Geometry GeometryStats
}

type Object

type Object struct {
	Type       Type
	Name       string
	Material   string
	VertexData []*VertexData
	Comments   []string
	// contains filtered or unexported fields
}

func (*Object) ReadVertexData

func (o *Object) ReadVertexData(t Type, value string, strict bool) (*VertexData, error)

Reads a vertex data line eg. f and l into this object.

If parent OBJ is non nil, additionally converts negative index references into absolute indexes and check out of bounds errors.

type Type

type Type int
const (
	Unkown Type = iota

	Comment        // #
	MtlLib         // mtllib
	MtlUse         // usemtl
	ChildGroup     // g
	ChildObject    // o
	SmoothingGroup // s
	Vertex         // v
	Normal         // vn
	UV             // vt
	Param          // vp
	Face           // f
	Line           // l
	Point          // p
	Curve          // curv
	Curve2         // curv2
	Surface        // surf
)

func TypeFromString

func TypeFromString(str string) Type

func (Type) Name

func (ot Type) Name() string

func (Type) String

func (ot Type) String() string

type VertexData

type VertexData struct {
	Type         Type
	Declarations []*Declaration
	// contains filtered or unexported fields
}

VertexData @todo Make face, line etc. separate objects with VertexData being an interface

func ParseFaceVertexData

func ParseFaceVertexData(str string, strict bool) (vt *VertexData, err error)

func ParseListVertexData

func ParseListVertexData(t Type, str string, strict bool) (*VertexData, error)

func (*VertexData) Index

func (f *VertexData) Index(index int) *Declaration

func (*VertexData) Meta

func (f *VertexData) Meta(t Type) string

func (*VertexData) SetMeta

func (f *VertexData) SetMeta(t Type, value string)

func (*VertexData) String

func (vt *VertexData) String() (out string)

Jump to

Keyboard shortcuts

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