View Single Post
  #2  
Old 09-14-2016, 07:57 AM
M@rcello M@rcello is offline
Member
 
Join Date: May 2016
Posts: 11
Question

This is the code:
Code:
import viz
import hd
import vizact
import vizshape
import vizact
import vizmat

viz.go()

viz.MainView.setPosition(0,0,-40)
viz.clearcolor(viz.GRAY)

pen=viz.add('art/pencil.obj')
pen.setPosition([0,0,-2])
pen.setScale([0.05,0.05,0.05])

cube=viz.add('art/box.wrl')
cube.color(0,0,0)
cube.setScale([35,20,0.1])

cube1=viz.add('art/box.wrl')
cube1.setPosition([-17.5,0,0])
cube1.setScale([1,21,0.2])
cube1.color(0,255,0)

cube2=viz.add('art/box.wrl')
cube2.color(0,255,0)
cube2.setPosition([17.5,0,0])
cube2.setScale([1,21,0.2])

cube3=viz.add('art/box.wrl')
cube3.color(0,255,0)
cube3.setPosition([0,10,0])
cube3.setScale([35,1,0.2])

cube4=viz.add('art/box.wrl')
cube4.color(0,255,0)
cube4.setPosition([0,-10,0])
cube4.setScale([35,1,0.2])

pos0=[]
pos1=[]

def UpdateModel():
	line = viz.MainWindow.screenToWorld(hd.get(hd.POSITION))
	pen.setPosition(line.endFromDistance(40))	
vizact.ontimer(0,UpdateModel)

def write(button):
	if button == hd.BUTTON1:
		global pos0
		pos0 = hd.get(hd.POSITION)

def Stop(button):
	if button == hd.BUTTON1:
		global pos1
		pos1=hd.get(hd.POSITION)
		viz.startLayer(viz.LINE_STRIP)
		viz.vertexColor(viz.WHITE)
		viz.vertex(pos0[0],pos0[1],0)
		viz.vertex(pos1[0],pos1[1],0)
		line=viz.endLayer(parent=viz.SCREEN)
	
hd.callback(hd.BUTTONDOWN_EVENT,write)
hd.callback(hd.BUTTONUP_EVENT,Stop)
The problem is that this function take a start point when the button1 is pushed down and a final point when the button is again up. If i hold the button1 nothing changes. I need to take all the points and draw the lines when the button1 holded1.
The effect should be the on of a digital sign!
Reply With Quote