def __del__(self): self.output_engine.setOutputInitialized(False) # Turn on the hardware safety interlock self.exiting = True self.wait() # Shut down OpenLase ol.shutdown()
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()
def __del__(self): self.output_engine.setOutputInitialized( False) # Turn on the hardware safety interlock self.exiting = True self.wait() # Shut down OpenLase ol.shutdown()
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()
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()
def run(self): ol.init() params = ol.RenderParams() params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE ol.setRenderParams(params) while not self.die: ol.loadIdentity() for x,y in self.dots: ol.dot((x,y), 30, ol.C_WHITE) ol.renderFrame(100) ol.shutdown()
def run(self): ol.init() params = ol.RenderParams() params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE ol.setRenderParams(params) while not self.die: ol.loadIdentity() for x, y in self.dots: ol.dot((x, y), 30, ol.C_WHITE) ol.renderFrame(100) ol.shutdown()
def run(self): if ol.init(10) < 0: return params = ol.RenderParams() params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE params.on_speed = 2 / 120.0 params.off_speed = 2 / 30.0 params.flatness = 0.000001 ol.setRenderParams(params) ol.setPixelShader(self.shade) time = 0 frames = 0 cur_tweets = self.tweets xpos = 0 idx = 0 startpos = 1.3 while not self.die: ol.loadIdentity3() ol.loadIdentity() if cur_tweets is None and self.tweets is not None: cur_tweets = self.tweets idx = 0 xpos = startpos w = 0 #print cur_tweets if cur_tweets is not None: font = ol.getDefaultFont() w = ol.getStringWidth(font, 0.4, cur_tweets[idx]) col = ol.C_WHITE #print "Render %f %s 0x%x"%(xpos, cur_tweets[idx], col) ol.drawString(font, (xpos, 0.1), 0.4, col, cur_tweets[idx]) #print "render" ftime = ol.renderFrame(60) #print "done" xpos -= 0.6 * ftime if xpos < (-w - 1) and cur_tweets is not None: xpos = startpos idx += 1 idx %= len(cur_tweets) if self.tweets != cur_tweets: idx = 0 cur_tweets = self.tweets print("Reset and update") print("Finished, new idx: %d" % idx) frames += 1 time += ftime ol.shutdown()
def run(self): if ol.init(10) < 0: return params = ol.RenderParams() params.render_flags = ol.RENDER_NOREORDER | ol.RENDER_GRAYSCALE params.on_speed = 2/120.0 params.off_speed = 2/30.0 params.flatness = 0.000001 ol.setRenderParams(params) ol.setPixelShader(self.shade) time = 0 frames = 0 cur_tweets = self.tweets xpos = 0 idx = 0 startpos = 1.3 while not self.die: ol.loadIdentity3() ol.loadIdentity() if cur_tweets is None and self.tweets is not None: cur_tweets = self.tweets idx = 0 xpos = startpos w = 0 #print cur_tweets if cur_tweets is not None: font = ol.getDefaultFont() w = ol.getStringWidth(font, 0.4, cur_tweets[idx]) col = ol.C_WHITE #print "Render %f %s 0x%x"%(xpos, cur_tweets[idx], col) ol.drawString(font, (xpos,0.1), 0.4, col, cur_tweets[idx]) #print "render" ftime = ol.renderFrame(60) #print "done" xpos -= 0.6*ftime if xpos < (-w-1) and cur_tweets is not None: xpos = startpos idx += 1 idx %= len(cur_tweets) if self.tweets != cur_tweets: idx = 0 cur_tweets = self.tweets print("Reset and update") print("Finished, new idx: %d"%idx) frames += 1 time += ftime ol.shutdown()
ol.vertex3((-1, 1, -1)) ol.vertex3((-1, -1, -1)) ol.vertex3((-1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP); ol.vertex3(( 1, 1, 1)) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, -1, 1)) ol.vertex3(( 1, -1, 1)) ol.vertex3(( 1, 1, 1)) ol.vertex3(( 1, 1, -1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3(( 1, -1, -1)) ol.vertex3(( 1, -1, 1)) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((-1, 1, 1)) ol.vertex3((-1, 1, -1)) ol.end() ftime = ol.renderFrame(60) # Takes max_fps as argument frames += 1 time += ftime print "Frame time: %f, FPS:%f"%(ftime, frames/time) ol.shutdown()
ol.vertex3((-1, 1, -1), ol.C_WHITE) ol.vertex3((-1, -1, -1), ol.C_WHITE) ol.vertex3((-1, -1, 1), ol.C_WHITE) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((1, 1, 1), ol.C_WHITE) ol.vertex3((-1, 1, 1), ol.C_WHITE) ol.vertex3((-1, -1, 1), ol.C_WHITE) ol.vertex3((1, -1, 1), ol.C_WHITE) ol.vertex3((1, 1, 1), ol.C_WHITE) ol.vertex3((1, 1, -1), ol.C_WHITE) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((1, -1, -1), ol.C_WHITE) ol.vertex3((1, -1, 1), ol.C_WHITE) ol.end() ol.begin(ol.LINESTRIP) ol.vertex3((-1, 1, 1), ol.C_WHITE) ol.vertex3((-1, 1, -1), ol.C_WHITE) ol.end() ftime = ol.renderFrame(60) frames += 1 time += ftime print "Frame time: %f, FPS:%f" % (ftime, frames / time) ol.shutdown()