コード例 #1
0
ファイル: kinect_shadows.py プロジェクト: nomad2012/openlase
	def run(self):
		while self.trace is None and not self.die:
			time.sleep(0.1)

		if self.die:
			return

		if ol.init(4) < 0:
			return
		print "OL Initialized"
		params = ol.RenderParams()
		params.render_flags = ol.RENDER_GRAYSCALE
		params.on_speed = 2/120.0
		params.off_speed = 2/30.0
		params.flatness = 0.000001
		params.max_framelen = 48000 / 25
		params.min_length = 30
		params.snap = 0.04
		ol.setRenderParams(params)
		ol.loadIdentity()
		ol.scale((2, -2))
		ol.translate((-0.5, -0.5))
		ol.scale((1/640.0, 1/640.0))
		ol.translate((0, (640-480)/2))

		while not self.die:
			#ol.rect((100, 100), (640-100, 480-100), ol.C_WHITE)
			objects = self.trace
			for o in objects:
				ol.begin(ol.POINTS)
				for point in o[::2]:
					ol.vertex(point, ol.C_WHITE)
				ol.end()
			ftime = ol.renderFrame(60)
		ol.shutdown()
コード例 #2
0
ファイル: ugoira_player.py プロジェクト: tawanjairew/openlase
def play_ugo(size, frames, meta):
    frame_pts = []
    total_time = 0
    for frame_meta in meta['frames']:
        frame_pts.append(total_time)
        total_time += frame_meta['delay'] / 1000.0

    if ol.init(3) < 0:
        return

    width, height = size

    params = ol.RenderParams()
    params.render_flags = ol.RENDER_GRAYSCALE
    params.on_speed = 2 / 60.0
    params.off_speed = 2 / 30.0
    params.flatness = 0.000001
    params.max_framelen = 48000 / 25
    params.min_length = 30
    params.snap = 0.04
    ol.setRenderParams(params)
    ol.loadIdentity()
    ol.scale((2, -2))
    ol.translate((-0.5, -0.5))
    mw = float(max(width, height))
    print width, height, mw
    ol.scale((1 / mw, 1 / mw))
    ol.translate(((mw - width) / 2, (mw - height) / 2))

    frame = 0
    time = 0

    DECIMATE = 2

    while True:
        while time > total_time:
            time -= total_time
            frame = 0

        while (frame + 1) < len(frames) and frame_pts[frame + 1] < time:
            frame += 1

        print "t=%.02f frame=%d" % (time, frame)

        objects = frames[frame]
        points = 0
        for o in objects:
            ol.begin(ol.POINTS)
            for point in o[::DECIMATE]:
                ol.vertex(point, ol.C_WHITE)
                points += 1
            ol.end()
        print "%d objects, %d points" % (len(objects), points)
        time += ol.renderFrame(60)

    ol.shutdown()
コード例 #3
0
def play_ugo(size, frames, meta):
    frame_pts = []
    total_time = 0
    for frame_meta in meta['frames']:
        frame_pts.append(total_time)
        total_time += frame_meta['delay'] / 1000.0

    if ol.init(3) < 0:
        return

    width, height = size

    params = ol.RenderParams()
    params.render_flags = ol.RENDER_GRAYSCALE
    params.on_speed = 2/60.0
    params.off_speed = 2/30.0
    params.flatness = 0.000001
    params.max_framelen = 48000 / 25
    params.min_length = 30
    params.snap = 0.04
    ol.setRenderParams(params)
    ol.loadIdentity()
    ol.scale((2, -2))
    ol.translate((-0.5, -0.5))
    mw = float(max(width, height))
    print width, height, mw
    ol.scale((1/mw, 1/mw))
    ol.translate(((mw-width)/2, (mw-height)/2))

    frame = 0
    time = 0

    DECIMATE = 2

    while True:
        while time > total_time:
            time -= total_time
            frame = 0

        while (frame+1) < len(frames) and frame_pts[frame+1] < time:
            frame += 1

        print "t=%.02f frame=%d" % (time, frame)

        objects = frames[frame]
        points = 0
        for o in objects:
            ol.begin(ol.POINTS)
            for point in o[::DECIMATE]:
                ol.vertex(point, ol.C_WHITE)
                points += 1
            ol.end()
        print "%d objects, %d points" % (len(objects), points)
        time += ol.renderFrame(60)

    ol.shutdown()
コード例 #4
0
ファイル: showsvg.py プロジェクト: marcan/openlase
import svg

image = svg.load_svg(sys.argv[1])

params = ol.RenderParams()
params.render_flags = 0
params.on_speed = 2/110.0
params.off_speed = 2/70.0
params.flatness = 0.0001
params.corner_dwell = 4
params.start_dwell = 3
params.end_dwell = 3
params.curve_dwell = 0
params.curve_angle = cos(30.0 * (pi / 180.0))
params.snap = 0.0001

ol.init()
ol.setRenderParams(params)

while True:
	ol.loadIdentity()
	ol.translate((-1,-1))
	ol.scale((1.99,1.99))
	xmin, ymin, xmax, ymax = image.bbox()
	w = xmax - xmin
	h = ymax - ymin
	ol.scale((1.0/max(w,h), 1.0/max(w,h)))
	ol.translate((-xmin, -ymin))
	image.draw()
	ol.renderFrame(60)
コード例 #5
0
ファイル: playtxt.py プロジェクト: jv4779/openlase-util
        if tokens[0] == "palette":
            render_frame()
            continue

        if tokens[0] == "frame":
            render_frame()

            currentFrame += 1
            if currentFrame >= startFrame:
                if endFrame > 0 and currentFrame > endFrame:
                    break
                renderFrame = True
                openPath = False
                ol.loadIdentity()
                ol.scale((1.0/32768, 1.0/32768))
                ol.translate((0, 0))
                if banner != "":
                    ol.drawString(font, (-w/2,yoff), fsize, ol.C_GREEN, banner)
            continue

        if is_number(tokens[0]):
            if renderFrame:
                x = float(tokens[0])
                y = float(tokens[1])
                palette_i = int(tokens[2])
    
                if not openPath:
                    ol.begin(0)
                    openPath = True
                elif palette_i < 0:
                    ol.end()
コード例 #6
0
ファイル: showsvg.py プロジェクト: sgnls/openlase
import svg

image = svg.load_svg(sys.argv[1])

params = ol.RenderParams()
params.render_flags = 0
params.on_speed = 2 / 110.0
params.off_speed = 2 / 70.0
params.flatness = 0.0001
params.corner_dwell = 4
params.start_dwell = 3
params.end_dwell = 3
params.curve_dwell = 0
params.curve_angle = cos(30.0 * (pi / 180.0))
params.snap = 0.0001

ol.init()
ol.setRenderParams(params)

while True:
    ol.loadIdentity()
    ol.translate((-1, -1))
    ol.scale((1.99, 1.99))
    xmin, ymin, xmax, ymax = image.bbox()
    w = xmax - xmin
    h = ymax - ymin
    ol.scale((1.0 / max(w, h), 1.0 / max(w, h)))
    ol.translate((-xmin, -ymin))
    image.draw()
    ol.renderFrame(60)