#1
|
|||
|
|||
VizTouch Help!
Hello!
First of all I would like to say thank you for a wonderful software. I have had hours of fun creating various virtual environments. I have just recently purchased a touch-screen and started exploring the VizTouch module and I have a little issue, maybe you can help! I have a cube that I want to look around using setEuler. I disabled the regular mouse navigation but I can't seem to figure out how to determine which way I want to rotate. In terms of touch I want this: Code:
def begin(e): #Begin touch def move(e): #On move, determine which direction it is moving and rotate the around the cube appropriately. As long as the touch persists, keep rotating slowly. def end(e): #End touch viztouch.onTouchDown(begin) viztouch.onTouchMove(move) viztouch.onTouchUp(end) Code:
def gesturemethod(typen): if (typen == 'left'): #cube.setEuler... elif (typen == 'right'): #cube.setEuler... elif (typen == 'up'): #cube.serEuler... elif (typen == 'down'): #cube.setEuler... viztouch.onGestureFlick(viztouch.FLICK_UP,gesturemethod, 'up') viztouch.onGestureFlick(viztouch.FLICK_DOWN,gesturemethod, 'down') viztouch.onGestureFlick(viztouch.FLICK_RIGHT,gesturemethod, 'right') viztouch.onGestureFlick(viztouch.FLICK_LEFT,gesturemethod, 'left') Thanks!! M12 |
#2
|
|||
|
|||
Oh, and to add, Flicks Up or Down don't seem to trigger for me. I only got them to trigger twice (I used prints to test this). Left and Right work just fine.
|
#3
|
|||
|
|||
The following example rotates different cubes using viztouch move events. In order to activate move on a cube the first touch event must intersect with it's geometry:
Code:
import viz import vizshape import viztouch viz.go() dojo = viz.addChild('dojo.osgb') redCube = vizshape.addCube(pos=[-1,1.8,6],color=viz.RED) blueCube = vizshape.addCube(pos=[1,1.8,6],color=viz.BLUE) viztouch.setMode(viztouch.MODE_TOUCH) class ShapeSpinner(object): def __init__(self, model): self.model = model self.last_pos = [] self.touchDown_event = viztouch.onTouchDown(self.beginTouch) self.touchMove_event = viztouch.onTouchMove(self.moveTouch) self.touchUp_event = viztouch.onTouchUp(self.endTouch) self.touchMove_event.setEnabled(viz.OFF) def beginTouch(self, e): pos = e.pos.normalized #If begin touch intersects model enable movement if viz.pick(pos=pos) == self.model: self.touchMove_event.setEnabled(viz.ON) self.last_pos = pos def moveTouch(self,e): pos = e.pos.normalized if pos[0] > self.last_pos[0]: self.model.setEuler([-0.4,0.0,0],viz.REL_LOCAL) elif pos[0] < self.last_pos[0]: self.model.setEuler([0.4,0.0,0],viz.REL_LOCAL) self.last_pos = pos def endTouch(self,e): self.touchMove_event.setEnabled(viz.OFF) ShapeSpinner(redCube) ShapeSpinner(blueCube) viz.mouse(viz.OFF) |
|
|