meshview

package module
v0.0.0-...-1de7f8b Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 16 Imported by: 0

README

meshview

Performant 3D mesh viewer written in Go.

Prerequisites

First, install Go, set your GOPATH, and make sure $GOPATH/bin is on your PATH.

brew install go # if using homebrew

# put these in .bash_profile or .zshrc
export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin"

You may need to install prerequisites for the glfw library.

Installation
go get -u github.com/fogleman/meshview/cmd/meshview
Usage
meshview model.stl

Screenshot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindInteractor

func BindInteractor(window *glfw.Window, interactor Interactor)

func Run

func Run(path string)

Types

type Arcball

type Arcball struct {
	Sensitivity float64
	Start       fauxgl.Vector
	Current     fauxgl.Vector
	Rotation    fauxgl.Matrix
	Translation fauxgl.Vector
	Scroll      float64
	Rotate      bool
	Pan         bool
}

func (*Arcball) CursorPositionCallback

func (a *Arcball) CursorPositionCallback(window *glfw.Window, x, y float64)

func (*Arcball) KeyCallback

func (a *Arcball) KeyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey)

func (*Arcball) Matrix

func (a *Arcball) Matrix(window *glfw.Window) fauxgl.Matrix

func (*Arcball) MouseButtonCallback

func (a *Arcball) MouseButtonCallback(window *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)

func (*Arcball) ScrollCallback

func (a *Arcball) ScrollCallback(window *glfw.Window, dx, dy float64)

type Interactor

type Interactor interface {
	Matrix(window *glfw.Window) fauxgl.Matrix
	CursorPositionCallback(window *glfw.Window, x, y float64)
	MouseButtonCallback(window *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)
	KeyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey)
	ScrollCallback(window *glfw.Window, dx, dy float64)
}

func NewArcball

func NewArcball() Interactor

func NewWASD

func NewWASD(window *glfw.Window) Interactor

type Mesh

type Mesh struct {
	Transform    fauxgl.Matrix
	VertexBuffer uint32
	VertexCount  int32
}

func NewMesh

func NewMesh(data *MeshData) *Mesh

func (*Mesh) Destroy

func (mesh *Mesh) Destroy()

func (*Mesh) Draw

func (mesh *Mesh) Draw(positionAttrib uint32)

type MeshData

type MeshData struct {
	Buffer []float32
	Box    fauxgl.Box
}

func LoadMesh

func LoadMesh(path string) (*MeshData, error)

func LoadOBJ

func LoadOBJ(path string) (*MeshData, error)

func LoadSTL

func LoadSTL(path string) (*MeshData, error)

type SwitchableInteractor

type SwitchableInteractor struct {
	Interactors []Interactor
	Index       int
}

func NewSwitchableInteractor

func NewSwitchableInteractor(interactors []Interactor) *SwitchableInteractor

func (*SwitchableInteractor) CursorPositionCallback

func (si *SwitchableInteractor) CursorPositionCallback(window *glfw.Window, x, y float64)

func (*SwitchableInteractor) KeyCallback

func (si *SwitchableInteractor) KeyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey)

func (*SwitchableInteractor) Matrix

func (si *SwitchableInteractor) Matrix(window *glfw.Window) fauxgl.Matrix

func (*SwitchableInteractor) MouseButtonCallback

func (si *SwitchableInteractor) MouseButtonCallback(window *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)

func (*SwitchableInteractor) ScrollCallback

func (si *SwitchableInteractor) ScrollCallback(window *glfw.Window, dx, dy float64)

func (*SwitchableInteractor) Switch

func (si *SwitchableInteractor) Switch()

type WASD

type WASD struct {
	// contains filtered or unexported fields
}

func (*WASD) CursorPositionCallback

func (wasd *WASD) CursorPositionCallback(window *glfw.Window, x, y float64)

func (*WASD) KeyCallback

func (wasd *WASD) KeyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey)

func (*WASD) Matrix

func (wasd *WASD) Matrix(window *glfw.Window) fauxgl.Matrix

func (*WASD) MouseButtonCallback

func (wasd *WASD) MouseButtonCallback(window *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)

func (*WASD) ScrollCallback

func (wasd *WASD) ScrollCallback(window *glfw.Window, dx, dy float64)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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