obj

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadMesh added in v0.23.0

func LoadMesh(objPath string) (*modeling.Mesh, error)

func Save

func Save(objPath string, scene Scene) error

Save writes all provided meshes to the path specified in OBJ format, optionally writing an additional MTL file with all materials that are found across all meshes.

func SaveMesh added in v0.23.0

func SaveMesh(objPath string, meshToSave modeling.Mesh) error

SaveMesh writes the mesh to the path specified in OBJ format, optionally writing an additional MTL file with all materials that are found within the modeling.

func Write added in v0.23.0

func Write(scene Scene, materialFile string, out io.Writer) error

func WriteMaterials

func WriteMaterials(scene Scene, out io.Writer) error

func WriteMesh

func WriteMesh(m modeling.Mesh, materialFile string, out io.Writer) error

Types

type Artifact added in v0.23.0

type Artifact struct {
	Scene        Scene
	MaterialFile string
}

func (Artifact) Mime added in v0.23.0

func (Artifact) Mime() string

func (Artifact) Write added in v0.23.0

func (sa Artifact) Write(w io.Writer) error

type Entry added in v0.23.0

type Entry struct {
	Mesh     modeling.Mesh
	Material *Material
}

type EntryNode added in v0.23.0

type EntryNode struct {
	Mesh     nodes.Output[modeling.Mesh]
	Material nodes.Output[Material]
}

func (EntryNode) Out added in v0.32.1

func (pn EntryNode) Out(out *nodes.StructOutput[Entry])

type Keyword added in v0.23.0

type Keyword string
const (
	Vertex            Keyword = "v"
	TextureCoordinate Keyword = "vt"
	Normal            Keyword = "vn"
	Face              Keyword = "f"
	Group             Keyword = "g"
	ObjectName        Keyword = "o"
	MaterialUsage     Keyword = "usemtl"
	MaterialLibrary   Keyword = "mtllib"
	SmoothingGroup    Keyword = "s"
	Comment           Keyword = "#"
)

type ManifestNode added in v0.25.0

type ManifestNode struct {
	Scene        nodes.Output[Scene]
	MaterialFile nodes.Output[string]
}

func (ManifestNode) Out added in v0.32.1

type Material added in v0.23.0

type Material struct {
	Name string

	// Account for light that is scattered about the entire scene
	AmbientColor color.Color

	// The main color
	DiffuseColor color.Color

	// Color seen where the surface is shiny and mirror like
	SpecularColor color.Color

	// Typically between 0 - 1000, with a high value resulting in a tight,
	// concentrated highlight
	//
	// Defines the focus of the specular highlight
	SpecularHighlight float64

	// Index of refraction, between 0.001 to 10, 1.0 means light does not bend
	// as it passes through the object
	OpticalDensity float64

	// Specifies how much this material dissolves into the background. A factor
	// of 0.0 is fully opaque. A factor of 1.0 is completely transparent.
	Transparency float64

	ColorTextureURI *string

	NormalTextureURI *string

	SpecularTextureURI *string
}

Material is just a clone of obj's MTL format at the moment cause man this problem scares me.

func DefaultColorMaterial added in v0.23.0

func DefaultColorMaterial(c color.Color) Material

func DefaultMaterial added in v0.23.0

func DefaultMaterial() Material

func ReadMaterials

func ReadMaterials(in io.Reader) ([]Material, error)

type MaterialNode added in v0.23.0

type MaterialNode struct {
	Name              nodes.Output[string]
	AmbientColor      nodes.Output[coloring.WebColor]
	DiffuseColor      nodes.Output[coloring.WebColor]
	SpecularColor     nodes.Output[coloring.WebColor]
	SpecularHighlight nodes.Output[float64]
	OpticalDensity    nodes.Output[float64]
	Transparency      nodes.Output[float64]
}

func (MaterialNode) Out added in v0.32.1

func (pn MaterialNode) Out(out *nodes.StructOutput[Material])

type Object added in v0.23.0

type Object struct {
	Name    string
	Entries []Entry
}

func (Object) ToMesh added in v0.23.0

func (o Object) ToMesh() modeling.Mesh

type ObjectNode added in v0.23.0

type ObjectNode struct {
	Name   nodes.Output[string]
	Entrys []nodes.Output[Entry]
}

func (ObjectNode) Out added in v0.32.1

func (pn ObjectNode) Out(out *nodes.StructOutput[Object])

type ReadNode added in v0.23.0

type ReadNode struct {
	In nodes.Output[[]byte]
}

func (ReadNode) Out added in v0.32.1

func (pn ReadNode) Out(out *nodes.StructOutput[modeling.Mesh])

type Scene added in v0.23.0

type Scene struct {
	Objects []Object
}

func Load

func Load(objPath string) (*Scene, error)

Load reads an obj file from the path specified, and optionally loads all associated metadata files the obj file might reference.

func ReadMesh

func ReadMesh(in io.Reader) (*Scene, []string, error)

func (Scene) ToMesh added in v0.23.0

func (s Scene) ToMesh() modeling.Mesh

type SceneNode added in v0.23.0

type SceneNode struct {
	Objects []nodes.Output[Object]
}

func (SceneNode) Out added in v0.32.1

func (pn SceneNode) Out(out *nodes.StructOutput[Scene])

Jump to

Keyboard shortcuts

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