diff --git a/LJ.conf b/LJ.conf index a493d66..c65d41d 100644 --- a/LJ.conf +++ b/LJ.conf @@ -2,7 +2,7 @@ set = 5 curve = 0 lasernumber = 1 -debug = 0 +debug = 2 ljayserverip = 127.0.0.1 nozoscip = 127.0.0.1 bhoroscip = 127.0.0.1 @@ -11,14 +11,14 @@ bhoroscip = 127.0.0.1 color = -1 ip = 127.0.0.1 kpps = 25000 -centerx = -695 -centery = -1486 -zoomx = 32.2 -zoomy = 29.0 +centerx = -1610 +centery = 0 +zoomx = 26.0 +zoomy = 38.0 sizex = 31450 sizey = 32000 -finangle = 17.0 -swapx = -1 +finangle = 0.0 +swapx = 1 swapy = -1 lsteps = [ (1.0, 8),(0.25, 3), (0.75, 3), (1.0, 10)] warpdest = [[-1500., 1500.], @@ -30,10 +30,10 @@ warpdest = [[-1500., 1500.], color = -1 ip = 192.168.1.5 kpps = 25000 -centerx = -506 -centery = -413 -zoomx = 81.5 -zoomy = 50.1 +centerx = 506 +centery = 413 +zoomx = 30 +zoomy = 30 sizex = 32000 sizey = 32000 finangle = 0.0 diff --git a/clients/laserglyph.py b/clients/laserglyph.py new file mode 100644 index 0000000..51685ae --- /dev/null +++ b/clients/laserglyph.py @@ -0,0 +1,209 @@ +# coding=UTF-8 + +''' +Anaglyphed cube + +LICENCE : CC +''' + +import redis +import framy +import math +import time + +# IP defined in /etd/redis/redis.conf +redisIP = '127.0.0.1' +r = redis.StrictRedis(host=redisIP, port=6379, db=0) + + +width = 800 +height = 600 +centerX = width / 2 +centerY = height / 2 + +fov = 256 +viewer_distance = 2.2 + +eye_spacing = 100 +nadir = 0.5 +observer_altitude = 30000 +# elevation = z coordinate + +# 0.0 or -2000 pop out) +map_plane_altitude = 0.0 + +vertices = [ + (- 1.0, 1.0,- 1.0), + ( 1.0, 1.0,- 1.0), + ( 1.0,- 1.0,- 1.0), + (- 1.0,- 1.0,- 1.0), + (- 1.0, 1.0, 1.0), + ( 1.0, 1.0, 1.0), + ( 1.0,- 1.0, 1.0), + (- 1.0,- 1.0, 1.0) + ] + +# Define the vertices that compose each of the 6 faces. These numbers are +# indices to the vertices list defined above. +#faces = [(0,1,2,3),(1,5,6,2),(5,4,7,6),(4,0,3,7),(0,4,5,1),(3,2,6,7)] +faces = [(0,1,2,3),(1,5,6,2),(5,4,7,6),(4,0,3,7),(0,4,5,1),(3,2,6,7)] + +def LeftShift(elevation): + + diff = elevation - map_plane_altitude + return nadir * eye_spacing * diff / (observer_altitude - elevation) + +def RightShift(elevation): + + diff = map_plane_altitude - elevation + return (1 - nadir) * eye_spacing * diff / (observer_altitude - elevation) + +# If you want to use rgb for color : +def rgb2int(r,g,b): + return int('0x%02x%02x%02x' % (r,g,b),0) + + +def Proj(x,y,z,angleX,angleY,angleZ): + + rad = angleX * math.pi / 180 + cosa = math.cos(rad) + sina = math.sin(rad) + y2 = y + y = y2 * cosa - z * sina + z = y2 * sina + z * cosa + + rad = angleY * math.pi / 180 + cosa = math.cos(rad) + sina = math.sin(rad) + z2 = z + z = z2 * cosa - x * sina + x = z2 * sina + x * cosa + + rad = angleZ * math.pi / 180 + cosa = math.cos(rad) + sina = math.sin(rad) + x2 = x + x = x2 * cosa - y * sina + y = x2 * sina + y * cosa + + + """ Transforms this 3D point to 2D using a perspective projection. """ + factor = fov / (viewer_distance + z) + x = x * factor + centerX + y = - y * factor + centerY + return (x,y) + + + +def Draw3PL(): + + Shape = [] + Left = [] + Right = [] + counter =0 + + while 1: + + for fa in faces: + #print "" + #print "face",fa + + for point in fa: + #print "" + #print "point ", point + x = vertices[point][0] + y = vertices[point][1] + z = vertices[point][2] + #print x,y,z + #print "left",x+LeftShift(z*25),y,z, Proj(x+LeftShift(z*25),y,z) + #print "right",x+RightShift(z*25),y,z, Proj(x+RightShift(z*25),y,z) + + + Shape.append(Proj(x,y,z,0,0,counter)) + Left.append( Proj(x+LeftShift(z*5),y,z,0,0,counter)) + Right.append(Proj(x+RightShift(z*5),y,z,0,0,counter)) + + framy.PolyLineOneColor(Shape, c = white, PL = 0, closed = False) + framy.PolyLineOneColor(Left, c = red, PL = 1, closed = False) + framy.PolyLineOneColor(Right, c = green, PL = 2, closed = False) + ''' + framy.rPolyLineOneColor(Shape, c = white, PL = 0, closed = False, xpos = 200, ypos = 250, resize = 1, rotx =0, roty =0 , rotz=0) + framy.rPolyLineOneColor(Left, c = red, PL = 1, closed = False, xpos = 200, ypos = 250, resize = 1, rotx =0, roty =0 , rotz=0) + framy.rPolyLineOneColor(Right, c = blue, PL = 2, closed = False, xpos = 200, ypos = 250, resize = 1, rotx =0, roty =0 , rotz=0) + ''' + #print framy.LinesPL(0) + #print framy.LinesPL(1) + #print framy.LinesPL(2) + + #counter -= 1 + #if counter >360: + # counter =0 + + +def Draw1PL(): + + Shape = [] + Left = [] + Right = [] + counter =0 + + while 1: + Shape = [] + Left = [] + Right = [] + for fa in faces: + #print "" + #print "face",fa + + for point in fa: + #print "" + #print "point ", point + x = vertices[point][0] + y = vertices[point][1] + z = vertices[point][2] + #print x,y,z + #print "left",x+LeftShift(z*25),y,z, Proj(x+LeftShift(z*25),y,z) + #print "right",x+RightShift(z*25),y,z, Proj(x+RightShift(z*25),y,z) + + + Shape.append(Proj(x,y,z,0,0,counter)) + Left.append( Proj(x+LeftShift(z*25),y,z,0,0,counter)) + Right.append(Proj(x+RightShift(z*25),y,z,0,0,counter)) + + #framy.PolyLineOneColor(Shape, c = white, PL = 0, closed = False) + framy.PolyLineOneColor(Left, c = rgb2int(0,155,0), PL = 0, closed = False) + framy.PolyLineOneColor(Right, c = rgb2int(0,0,155), PL = 0, closed = False) + ''' + framy.rPolyLineOneColor(Shape, c = white, PL = 0, closed = False, xpos = 200, ypos = 250, resize = 1, rotx =0, roty =0 , rotz=0) + framy.rPolyLineOneColor(Left, c = red, PL = 1, closed = False, xpos = 200, ypos = 250, resize = 1, rotx =0, roty =0 , rotz=0) + framy.rPolyLineOneColor(Right, c = blue, PL = 2, closed = False, xpos = 200, ypos = 250, resize = 1, rotx =0, roty =0 , rotz=0) + ''' + framy.LinesPL(0) + time.sleep(0.1) + counter -= 1 + if counter >360: + counter =0 + +white = rgb2int(255,255,255) +red = rgb2int(255,0,0) +blue = rgb2int(0,0,255) +green = rgb2int(0,255,0) + + +Draw1PL() + #r.set('/pl/0/0', str(pl0)) +# S = (e / 2) (d - p) / (a - d) + + +''' +# /pl/clientnumber/lasernumber pointlist + +# Consider you're client 0 +# Send to laser 0 (see mainy.conf) +r.set('/pl/0/0', str(pl0)) + +# Send to laser 1 (see mainy.conf) +r.set('/pl/0/1', str(pl1)) +# Send to laser 2 (see mainy.conf) +r.set('/pl/0/2', str(pl1)) +''' diff --git a/clients/nodeclient.js b/clients/nodeclient.js index 9cecabd..105b094 100644 --- a/clients/nodeclient.js +++ b/clients/nodeclient.js @@ -38,10 +38,10 @@ function GenPoints() { var pt = {}; - // direct colors, i.e red + // direct colors, i.e white pt.r = 255; - pt.g = 0; - pt.b = 0; + pt.g = 255; + pt.b = 255; // named colors var white = rgb2int(255, 255, 255); diff --git a/clients/pyclient.py b/clients/pyclient.py index 49f7e60..b9481f8 100644 --- a/clients/pyclient.py +++ b/clients/pyclient.py @@ -15,7 +15,7 @@ r = redis.StrictRedis(host=redisIP, port=6379, db=0) # (x,y,color in integer) 65280 is color #00FF00 # Green rectangular shape : -pl0 = [(100,300,65280),(200,300,65280),(200,200,65280),(100,200,65280)] +pl0 = [(100,300,65280),(200,300,65280),(200,200,65280),(100,200,65280),(100,300,65280)] # If you want to use rgb for color : @@ -23,7 +23,7 @@ def rgb2int(r,g,b): return int('0x%02x%02x%02x' % (r,g,b),0) # White rectangular shape -pl1 = [(100,300,rgb2int(255,255,255)),(200,300,rgb2int(255,255,255)),(200,200,rgb2int(255,255,255)),(100,200,rgb2int(255,255,255))] +pl1 = [(100,300,rgb2int(255,255,255)),(200,300,rgb2int(255,255,255)),(200,200,rgb2int(255,255,255)),(100,200,rgb2int(255,255,255)),(100,300,rgb2int(255,255,255))] # /pl/clientnumber/lasernumber pointlist diff --git a/commands.py b/commands.py index 33f5334..639a3c4 100644 --- a/commands.py +++ b/commands.py @@ -14,11 +14,8 @@ from /team/laser import types, time import gstt - -#import colorify import homographyp import settings -#import alignp import redis @@ -30,11 +27,6 @@ def UserOn(laser): print "User for laser ", laser r.set('/order/'+str(laser), 0) - # Laser bit 0 = 0 and bit 1 = 0 : USER PL - #order = r.get('/order') - #neworder = order & ~(1<< laser*2) - #neworder = neworder & ~(1<< 1+ laser*2) - #r.set('/order', str(neworder)) def NewEDH(laser): @@ -45,33 +37,17 @@ def NewEDH(laser): print "Settings saving swapY ", gstt.swapY[laser] homographyp.newEDH(laser) - - #r.set('/order/'+str(laser), 1) - # Laser bit 0 = 0 and bit 1 = 1 : New EDH - #order = r.get('/order') - #neworder = order & ~(1<< laser*2) - #neworder = neworder | (1<< 1+laser*2) - #r.set('/order', str(neworder)) def BlackOn(laser): print "Black for laser ", laser r.set('/order/'+str(laser), 2) - # Black PL is Laser bit 0 = 1 and bit 1 = 0 : - #order = r.get('/order') - #neworder = order | (1< 0: + gstt.zoomX[laser] += int(args[0]) + print "scale/X laser", laser , "modified to", gstt.zoomX[laser] + NewEDH(laser) # /scale/Y/lasernumber value if oscpath[1] == "scale" and oscpath[2] == "Y": - print "scale/Y laser", laser, "modified to", args[0] - gstt.zoomY[laser] += int(args[0]) - NewEDH(laser) + if gstt.zoomY[laser] + int(args[0]) > 0: + gstt.zoomY[laser] += int(args[0]) + print "scale/Y laser", laser, "modified to", gstt.zoomY[laser] + NewEDH(laser) ''' For reference values of EDH modifier if assign to keyboard keys (was alignp) @@ -279,4 +256,30 @@ For reference values of EDH modifier if assign to keyboard keys (was alignp) gstt.finANGLE[gstt.Laser] -= 0.001 gstt.finANGLE[gstt.Laser] += 0.001 + +Code for bit analysis 2 bits / laser to encode order. + + # Grid PL is Laser bit 0 = 1 and bit 1 = 1 + #order = r.get('/order') + #neworder = order | (1< led is not lit @@ -381,6 +381,11 @@ try: server.set_fn_new_client(new_client) server.set_fn_client_left(client_left) server.set_fn_message_received(message_received) + print "" + print "Resetting all Homographies.." + for laserid in range(0,gstt.LaserNumber): + homographyp.newEDH(laserid) + print "" print "ws server running forver..." server.run_forever() diff --git a/tracer.py b/tracer.py index ca828fc..0577024 100644 --- a/tracer.py +++ b/tracer.py @@ -346,12 +346,12 @@ class DAC(object): order = int(r.get('/order/'+str(self.mylaser))) - #print "laser", self.mylaser, "order : ",type(order) + #print "laser", self.mylaser, "order : ",order if order == 0: # USER point list self.pl = ast.literal_eval(r.get(self.clientkey+str(self.mylaser))) - #print "laser", self.mylaser, "pl : ",length(self.pl) + #print "laser", self.mylaser, " order 0 : pl : ",len(self.pl) else: @@ -376,7 +376,7 @@ class DAC(object): # Resampler Change if order == 4: self.resampler = ast.literal_eval(r.get('/resampler/'+str(self.mylaser))) - print "newdacp resetting lsteps for", self.mylaser, ":",self.resampler + print "tracer resetting lsteps for", self.mylaser, ":",self.resampler gstt.stepshortline = self.resampler[0] gstt.stepslongline[0] = self.resampler[1] gstt.stepslongline[1] = self.resampler[2] diff --git a/visualiserdarwin b/visualiserdarwin new file mode 100755 index 0000000..c1bec5f Binary files /dev/null and b/visualiserdarwin differ