rigo

package module
v0.0.0-...-0df34db Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2016 License: BSD-3-Clause Imports: 19 Imported by: 0

README

#RiGO2 version

Implementation of the RenderMan Interface for the Go programming language. This is currently based on Pixar's RenderMan Specification version 3.2.1 (November 2005). This implementation is still under active development, so expect holes and bugs.

The current interface mimics RenderManProServer 21.2

Online Documentation

Install with:

go get github.com/mae-global/rigo2

Example usage:


import (
  . "github.com/mae-global/rigo2/ri/core"
  . "github.com/mae-global/rigo2/ri"
  "github.com/mae-global/rigo2"
)

/* create a context to work with */
ri := rigo.New(nil)

ri.Begin("unitcube.rib")
ri.AttributeBegin()
	ri.Attribute("identifier", RtToken("name"), RtToken("unitcube"))
	ri.Bound(RtBound{-.5, .5, -.5, .5, -.5, .5})
	ri.TransformBegin()

		points := RtFloatArray{.5, .5, .5, -.5, .5, .5, -.5, -.5, .5, .5, -.5, .5}

		ri.ArchiveRecord(COMMENT,"far face")
		ri.Polygon(4, P, points)
		ri.Rotate(90, 0, 1, 0)

		ri.ArchiveRecord(COMMENT,"right face")
		ri.Polygon(4, P, points)
		ri.Rotate(90, 0, 1, 0)

		ri.ArchiveRecord(COMMENT,"near face")
		ri.Polygon(4, P, points)
		ri.Rotate(90, 0, 1, 0)

		ri.ArchiveRecord(COMMENT,"left face")
		ri.Polygon(4, P, points)

	ri.TransformEnd()
	ri.TransformBegin()

		ri.ArchiveRecord(COMMENT,"bottom face")
		ri.Rotate(90, 1, 0, 0)
		ri.Polygon(4, P, points)

		ri.TransformEnd()
		ri.TransformBegin()

		ri.ArchiveRecord(COMMENT,"top face")
		ri.Rotate(-90, 1, 0, 0)
		ri.Polygon(4, P, points)

	ri.TransformEnd()
ri.AttributeEnd()
ri.End()	

RIB output of unitcube.rib is thus :-

##RenderMan RIB
AttributeBegin 
	Attribute "identifier" "name" "unitcube"
	Bound [-.5 .5 -.5 .5 -.5 .5]
	TransformBegin 
		# far face
		Polygon "P" [.5 .5 .5 -.5 .5 .5 -.5 -.5 .5 .5 -.5 .5]
		Rotate 90. 0 1. 0
		# right face
		Polygon "P" [.5 .5 .5 -.5 .5 .5 -.5 -.5 .5 .5 -.5 .5]
		Rotate 90. 0 1. 0
		# near face
		Polygon "P" [.5 .5 .5 -.5 .5 .5 -.5 -.5 .5 .5 -.5 .5]
		Rotate 90. 0 1. 0
		# left face
		Polygon "P" [.5 .5 .5 -.5 .5 .5 -.5 -.5 .5 .5 -.5 .5]
	TransformEnd 
	TransformBegin 
		# bottom face
		Rotate 90. 1. 0 0
		Polygon "P" [.5 .5 .5 -.5 .5 .5 -.5 -.5 .5 .5 -.5 .5]
	TransformEnd 
	TransformBegin 
		# top face
		Rotate -90. 1. 0 0
		Polygon "P" [.5 .5 .5 -.5 .5 .5 -.5 -.5 .5 .5 -.5 .5]
	TransformEnd 
AttributeEnd 

###Information

RenderMan Interface Specification is Copyright © 2005-2016 Pixar. RenderMan © is a registered trademark of Pixar.

Documentation

Index

Constants

View Source
const (
	DefaultBlockFile = "out.rib.block"
)

TODO: MOVE to blockdriver

View Source
const RenderManProVersion = RtInt(21)

Variables

This section is empty.

Functions

func AbortErrorHandler

func AbortErrorHandler(code, severity int, msg string) error

func AddDriver

func AddDriver(name string, builder drivers.Builder) error

func DefaultHandleGeneratorHandler

func DefaultHandleGeneratorHandler(name, typeof string) (string, error)

func FindDriver

func FindDriver(name string) (drivers.Builder, error)

func New

func New(config *Configuration) *RiContext

func PrintErrorHandler

func PrintErrorHandler(code, severity int, msg string) error

func RemoveDriver

func RemoveDriver(name string) error

Types

type Block

type Block struct {
	Info *BlockInfo

	Parent   *Block /* if nil then root */
	Children []*Block
}

type BlockInfo

type BlockInfo struct {
	Type         string
	Annotation   string
	Statements   int
	Tokens       int
	InlineTokens int
	Assets       []string /* lights, shaders etc */
}

func (*BlockInfo) String

func (info *BlockInfo) String() string

type Configuration

type Configuration struct {
	Errorf    ErrorHandler /* Error Handler function */
	Handlef   HandleGeneratorHandler
	Logger    *log.Logger
	Callbacks map[string]CustomCallbackHandler
}

Configuration

func NewConfiguration

func NewConfiguration() *Configuration

type Context

type Context struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Context

func NewContext

func NewContext(config *Configuration) *Context

NewContext

func (*Context) GenHandle

func (ctx *Context) GenHandle(name, typeof string) (string, error)

func (*Context) Get

func (ctx *Context) Get(name string) string

Get

func (*Context) GetLastRIB

func (ctx *Context) GetLastRIB() string

func (*Context) GetProgress

func (ctx *Context) GetProgress() RtInt

func (*Context) Handle

func (ctx *Context) Handle(list []RtPointer)

Handle

func (*Context) HandleError

func (ctx *Context) HandleError(err *RtError) *RtError

HandleError

func (*Context) HandleV

func (ctx *Context) HandleV(name RtString, args []RtPointer, tokens []RtPointer, values []RtPointer)

func (*Context) PeelStatistics

func (ctx *Context) PeelStatistics() *Statistics

peel a copy of the statistics

func (*Context) Set

func (ctx *Context) Set(name, declaration string) RtToken

Set

type CustomCallbackHandler

type CustomCallbackHandler func(name RtString, args, tokens, values []RtPointer) bool

Custom callback Handler

type ErrorHandler

type ErrorHandler func(code, severity int, msg string) error

type HandleGeneratorHandler

type HandleGeneratorHandler func(name, typeof string) (string, error)

HandleGeneratorHandler -- generate handles, RtLightHandle, ...

type OptionBlock

type OptionBlock map[RtToken]RtPointer

all options defined before RiBegin is called

type Statistics

type Statistics struct {
	sync.RWMutex

	Tokens  map[RtToken]int /* usage of tokens (by name only) */
	Root    *Block
	Current *Block
}

Statistics -- run per begin/end statements TODO: move to utilities and standardise

func (*Statistics) AddAsset

func (s *Statistics) AddAsset(token RtToken, value RtPointer)

func (*Statistics) AnnotateLabel

func (s *Statistics) AnnotateLabel(token RtToken, value RtPointer)

func (*Statistics) Begin

func (s *Statistics) Begin(name string)

func (*Statistics) CurrentBlock

func (s *Statistics) CurrentBlock() string

func (*Statistics) End

func (s *Statistics) End()

func (*Statistics) IncrementStatements

func (s *Statistics) IncrementStatements()

func (*Statistics) IncrementToken

func (s *Statistics) IncrementToken(name RtToken)

func (*Statistics) IncrementTokens

func (s *Statistics) IncrementTokens(n, inline int)

func (*Statistics) PrettyPrint

func (s *Statistics) PrettyPrint() string

currently prettyprint to string

Directories

Path Synopsis
RIB
ri
core
rigo/core/definitions.go Package core is a generated protocol buffer package.
rigo/core/definitions.go Package core is a generated protocol buffer package.
rigo2/rib/parser.go
rigo2/rib/parser.go
ris
rma
tools

Jump to

Keyboard shortcuts

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