WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 08-14-2014, 04:10 AM
Majestic12 Majestic12 is offline
Join Date: Apr 2014
Posts: 10
VizTouch Help!


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:

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



I tried to do a similar thing with the gestures, but it turned out fairly clunky. I had to do flicks repeatedly and each time would move the view a fixed distance:

def gesturemethod(typen):
if (typen == 'left'):
elif (typen == 'right'):
elif (typen == 'up'):
elif (typen == 'down'):

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')
I would like to do a smooth solution with the touch one but I can't seem to figure out how to do it smoothly. I would be appreciative of any help I can get in this! How do I determine which way a touch is moving and then set the euler accordingly?

Reply With Quote
Old 08-14-2014, 05:39 AM
Majestic12 Majestic12 is offline
Join Date: Apr 2014
Posts: 10
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.
Reply With Quote
Old 08-15-2014, 02:02 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,465
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:

import viz
import vizshape
import viztouch


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)


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)

	def beginTouch(self, e):
		pos = e.pos.normalized
		#If begin touch intersects model enable movement
		if  viz.pick(pos=pos) == self.model:
			self.last_pos = pos
	def moveTouch(self,e):

		pos = e.pos.normalized
		if pos[0] > self.last_pos[0]:
		elif pos[0] < self.last_pos[0]:
		self.last_pos = pos
	def endTouch(self,e):
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 08:23 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC