obj

package
v0.0.0-...-1fa7888 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, into []gpu.Model) error

Decode decodes the specified obj and associated mtl file and schedules return a reference to the model on the GPU.

Types

type Decoder

type Decoder struct {
	Objects   []Object             // decoded objects
	Matlib    string               // name of the material lib
	Materials map[string]*Material // maps material name to object
	Vertices  [][3]float32         // vertices positions array
	Normals   [][3]float32         // vertices normals
	Uvs       [][2]float32         // vertices texture coordinates
	Warnings  []string             // warning messages
	// contains filtered or unexported fields
}

Decoder contains all decoded data from the obj and mtl files

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    math32.Color // Ambient color reflectivity
	Diffuse    math32.Color // Diffuse color reflectivity
	Specular   math32.Color // Specular color reflectivity
	Emissive   math32.Color // Emissive color
	MapKd      string       // Texture file linked to diffuse color
}

Material contains all information about an object material

type Object

type Object struct {
	Name  string // Object name
	Faces []Face // Faces
	// contains filtered or unexported fields
}

Object contains all information about one decoded object

Jump to

Keyboard shortcuts

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