コード例 #1
0
ファイル: square.py プロジェクト: shans/togra
    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()
コード例 #2
0
ファイル: sphere.py プロジェクト: shans/togra
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()