translate

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RexToObj added in v0.4.0

func RexToObj(header *rexfile.Header, content *rexfile.File, writer *bufio.Writer) error

func RexToWavefront added in v0.4.1

func RexToWavefront(header *rexfile.Header, content *rexfile.File, path, name string) error

RexToWavefront is a high-level function which generates OBJ/MTL/texture files based on the REXfile content. dir ... directory for the output, needs to exist name ... the name of the files being generation (e.g. name="sphere" would output sphere.obj and sphere.mtl)

Example
package main

import (
	"bufio"
	"fmt"
	"os"

	"github.com/roboticeyes/gorexfile/encoding/rexfile"
)

const (
	item = "e39718-b33b-4d2f-b30e-493264d55de3"
)

var (
	rexFile = "./" + item + ".rex"
	outDir  = "./" + item
)

func main() {

	file, err := os.Open(rexFile)
	if err != nil {
		fmt.Println("Cannot open input file", rexFile)
	}
	defer file.Close()
	r := bufio.NewReader(file)
	d := rexfile.NewDecoder(r)
	rexHeader, rexContent, err := d.Decode()
	if err != nil && err.Error() != "unexpected EOF" {
		fmt.Println(err)
	}

	err = RexToWavefront(rexHeader, rexContent, outDir, item)
	if err != nil {
		fmt.Println(err)
	}
}
Output:

Types

type ObjToRex

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

ObjToRex container

func NewObjToRexTranslator

func NewObjToRexTranslator(inputFileName string, verbose bool) (*ObjToRex, error)

NewObjToRexTranslator returns a new translator for converting OBJ files to REX files. It tries to open up the files and creates the according reader

func (*ObjToRex) Translate

func (o *ObjToRex) Translate() (rexfile.File, error)

Translate implements the translator interface

type Translator

type Translator interface {
	Translate() (rexfile.File, error)
}

Translator interface is a generic interface which converts anything to a rex file

Jump to

Keyboard shortcuts

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