WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-10-2011, 05:11 AM
Saz Saz is offline
Member
 
Join Date: Nov 2008
Posts: 36
moving at different speeds

Hi,

I've got two rolling roads side by side but I want them to move at different speeds to each other as a type of comparison task, at the moment I can get them to go at the same speeds as each other but not to move independently;

Code:
import viz
#Import vizjoy module
import vizjoy  
import time
import math
import vizact
import vizinfo
import vizshape

viz.displaymode(1024, 512)
viz.go(viz.FULLSCREEN)
viz.mouse(viz.OFF)
vizact.ontimer(32,viz.quit) #runs file for 32 secs


subject = viz.input('What is the participant number?')

#define speed
MOVE_SPEEDl = 0.04459 #hard wired constant for speed gain (30mph)
MOVE_SPEEDr = 0.001

viz.clearcolor(0.5,0.5,0.5)
viz.MainView.setPosition(0,0.5,0)




#add the road texture
roadr = viz.add('roadld3.png')
roadl = viz.add('roadld3.png')
#create a texture quad1 to add the road texture to
#and place it over ground
quadr = viz.addTexQuad()
quadr.setScale(1,2,1)
quadr.setPosition(0,0.5,0)
quadr.setEuler(0,90,0)
quadr.texture(roadr)

roadr_position = 0.5
#groundr_position = 0

#create a texture quad left to add the road texture to
#and place it over ground
quadl = viz.addTexQuad()
quadl.setScale(1,2,1)
quadl.setPosition(0,-0.5,0)
quadl.setEuler(0,90,0)
quadl.texture(roadl)
roadl_position = 0

viz.link(viz.MainView, quadr)
viz.link(viz.MainView, quadl)



#add right road if getting near the end of road
def addRoadr():
	
	global roadr_position, roadl_position
	
	viewpointr_pos = viz.MainView.getPosition(quadr)
	#check to see how close the viewpoint is to the end of the road
	if roadr_position - viewpointr_pos[2] < 50:
		
		
		
		#add 50 meters of road
		for i in range(1,50):
			quadrcopy = quadr.copy()
			quadrcopy.setPosition([0.75,0,roadr_position])
			quadrcopy.setEuler(0,90,0)
			roadr_position +=1
			
	viz.MainView.move(0,0,MOVE_SPEEDr,viz.BODY_ORI)

addRoadr()
#call a timer every frame to check if road needs to be added
vizact.ontimer(0, addRoadr)

# add left road if getting near to the end of it
def addRoadl():
	
	global roadr_position, roadl_position
	
	viewpointl_pos = viz.MainView.getPosition(quadl)
	#check to see how close the viewpoint is to the end of the road
	if roadl_position - viewpointl_pos[2] < 50:
		
		
		
		#add 50 meters of road
		for i in range(1,50):
			quadlcopy = quadl.copy()
			quadlcopy.setPosition([-0.75,0,roadl_position])
			#changing the 1st parameter to -0.5 for left quad and
			#0.5 for right quad elimates the grey space between the lines
			#one solid black road
			quadlcopy.setEuler(0,90,0)
			roadl_position +=1
			
	viz.MainView.move(0,0,MOVE_SPEEDl,viz.BODY_ORI)

addRoadl()
#call a timer every frame to check if road needs to be added
vizact.ontimer(0, addRoadl)
I'm guessing that it's something to do with the viz.MainView.move command? So I tried linking it to the two objects that I want moving but no luck. Is there a easy way of achieving this that even a programming simpleton like me can understand?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
rotate around moving axis moneim230 Vizard 1 07-14-2010 10:04 AM
Stop moving after few seconds?? Chrissy2009 Vizard 8 05-10-2009 03:47 PM
Moving avatars lips with sound dan12345 Vizard 5 01-29-2008 08:32 PM
Moving view with object Xliben Vizard 2 07-25-2005 06:36 PM
moving viewpoint vs. translating Head_pos bailenson Vizard 5 02-01-2005 02:51 PM


All times are GMT -7. The time now is 04:42 PM.


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