示例#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 streams import ConstantElement
from util import TimeOffset, GroupAggregator, TakeFirst
from frames import frameGenerator

from timing import timingProcessor, RatePrinter

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)