WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 10-17-2008, 12:06 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I modified your script to work with the built-in relative transform modes. Hopefully this should work better:
Code:
import viz
viz.go()
viz.clearcolor(0.1,0.1,1)
ground = viz.add('tut_ground.wrl')
ANCHOR_POS= (0.5,1.8005,6)
bar2 = viz.add('bar.obj',pos=ANCHOR_POS)
bar = bar2.add('bar.obj')

MOVE_SPEED = 60 # degrees/sec

def UpdateBars():

	if viz.iskeydown('t'):
		bar.setEuler([0,MOVE_SPEED*viz.elapsed(),0],viz.REL_LOCAL)
		
	if viz.iskeydown('b'):
		bar.setEuler([0,-MOVE_SPEED*viz.elapsed(),0],viz.REL_LOCAL)
		
	if viz.iskeydown('f'):
		bar2.setEuler([MOVE_SPEED*viz.elapsed(),0,0],viz.REL_PARENT)
		
	if viz.iskeydown('h'):
		bar2.setEuler([-MOVE_SPEED*viz.elapsed(),0,0],viz.REL_PARENT)

vizact.ontimer(0,UpdateBars)
Reply With Quote
  #2  
Old 10-21-2008, 05:01 AM
Sandro Holzer Sandro Holzer is offline
Member
 
Join Date: Jul 2008
Posts: 19
Hi

Thanks for answers.

The relative transform mode is a bit a problem with my application, but I tryed to do it ABS with the transform-matrix and it looks very good.

The code is the following, and it seems to work also in my big script.

Sandro



Code:
import viz
viz.go()
 
viz.clearcolor(0.1,0.1,1)
ground = viz.add('tut_ground.wrl')
ANCHOR_POS= (0.5,1.8005,6)
bar2 = viz.add('bar.obj',pos=ANCHOR_POS)
bar = bar2.add('bar.obj')

a = 0
b = 0

def mytimer(num):
	global a,b
	if viz.iskeydown('t'):
		a = a + 1
		move()
	if viz.iskeydown('b'):
		a = a - 1
		move()
		
	if viz.iskeydown('f'):
		b = b + 1
		move()
	if viz.iskeydown('h'):
		b = b - 1
		move()

def move():

	X = bar.getMatrix(viz.ABS_PARENT)
	X.setAxisAngle(1,0,0,a)
	bar.update(X)
	
	
	X = bar2.getMatrix(viz.ABS_GLOBAL)
	X.setAxisAngle(0,1,0,b)
	bar2.update(X)
	
	

viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.02,viz.FOREVER)
Reply With Quote
Reply

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 01:10 AM.


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