return amplitude.getNext() * math.sin(this.offset) class RectangleGenerator(ProcessingElement): def __init__(this): ProcessingElement.__init__(this, 2) def run(this, widthIn, heightIn): out = Frame() width = widthIn.getNext() height = heightIn.getNext() out.addValue((width/2.0, height/2.0, 0)) out.addValue((width/2.0, -height/2.0, 0)) out.addValue((-width/2.0, -height/2.0, 0)) out.addValue((-width/2.0, height/2.0, 0)) return out togra = Togra() rect = RectangleGenerator() rect.connectInput(ConstantElement(4), 0) sin = timingProcessor(SinGenerator, 1, "sin")() sin.connectInput(TimeOffset(), 0) sin.connectInput(TimeOffset(), 1) rect.connectInput(sin, 1) rectP = RatePrinter(1) print rectP rectP.connectInput(rect, 0) togra.setRenderTree(RenderFrame(rectP, GL_QUADS)) togra.run()
from togra import Togra, RenderFrame from shapes import CubeGenerator from transforms import Rotation from streams import ConstantElement from util import TimeOffset from OpenGL.GL import * rotation = Rotation() rotation.connectInput(ConstantElement([1.0, 0.0, 0.0]), 0) rotation.connectInput(TimeOffset(), 1) togra = Togra() togra.setRenderTree(RenderFrame(CubeGenerator(), GL_QUADS, rotation)) togra.run()
from OpenGL.GL import * SLICES = 100 PPS = 100 rotation = Rotation() rotation.connectInput(ConstantElement([1.0, 0.0, 0.0]), 0) rotation.connectInput(TimeOffset(), 1) genF = timingProcessor(ScalingExtrusionElement, 1, "extrusion")() genF.connectInput(timingProcessor(SphereLineGenerator, 1, "slg")(SLICES), 0) genF.connectInput(timingProcessor(SphereSliceSizeGenerator, 1, "sssg")(SLICES), 1) genF.connectInput(timingProcessor(CircleGenerator, 1, "cg")(PPS), 2) genQ = timingProcessor(PointsToQuadsElement, 1, "pointsToQuads")() genQ.connectInput(genF, 0) genG = timingProcessor(GroupAggregator, 1, "aggregator")(SLICES) genG.connectInput(genQ, 0) genC = TakeFirst() genC.connectInput(genG, 0) gen = RatePrinter(1) gen.connectInput(genC, 0) togra = Togra() togra.setRenderTree(RenderFrame(gen, GL_QUAD_STRIP, rotation)) togra.run()
from transforms import Rotation from streams import ProcessingElement, ConstantElement from util import TimeOffset from frames import Frame from OpenGL.GL import * rotation = Rotation() rotation.connectInput(ConstantElement([1.0, 0.0, 0.0]), 0) rotation.connectInput(TimeOffset(), 1) class Points(ProcessingElement): def __init__(this, points): ProcessingElement.__init__(this, 0) this.points = points def run(this): out = Frame() out.values = this.points return out bezier = Bezier(50) bezier.connectInput(Points([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [0.0, 0.0, 2.0], [2.0, 0.0, 1.0]]), 0) togra = Togra() togra.setRenderTree(RenderFrame(bezier, GL_LINE_STRIP, rotation)) togra.run()
from togra import Togra, RenderFrame from shapes import CircleGenerator from transforms import Rotation from streams import ConstantElement from util import TimeOffset from OpenGL.GL import * rotation = Rotation() rotation.connectInput(ConstantElement([1.0, 0.0, 0.0]), 0) rotation.connectInput(TimeOffset(), 1) togra = Togra() togra.setRenderTree(RenderFrame(CircleGenerator(50), GL_LINE_LOOP, rotation)) togra.run()