Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

sf1/go3dm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go3dm

Go packages for importing and converting 3D models.

Status

Rudimentary support for loading and converting Wavefront OBJ files (including materials). Only triangluar faces are supported.

Installation

Package:

go get github.com/sf1/go3dm

OBJ to Go code converter:

go get github.com/sf1/go3dm/obj2go

Usage

Load OBJ into an indexed triangle mesh:

mesh, materials, err := go3dm.LoadOBJ("al.obj", true)
if err != nil { panic(err) }

// Print vertex and normal slices
fmt.Println(mesh.Vertices)
fmt.Println(mesh.Normals}
fmt.Println(mesh.VertexIndex}

// Iterate through named objects / polygon groups
for _, obj := range mesh.Objects {
    fmt.Println(obj.Name)
    // ...
    // Get material, if any
    if obj.MaterialRef != "" {
        mat := materials[obj.MaterialRef]
        fmt.Println(mat)
    }
}

About

Go packages for loading 3D models.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages