WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-15-2006, 10:49 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Avatar walk

I was wondering if you could help me with this problem. I think it's more of a mathematical problem but I think it applies to programming. I need for avatars to appear from all directions instead of just in front of the person participating in the experiment. I can't seem to figure out how to set up my x,y,z to have this occur. We want avatars to appear from all directions and have the user actually have to look around to see where they are coming from.

Here is what I have so far:

Code:
for i in range(NUM_AVATARS):
	newX = -math.cos(-2*i+15) * 2
	newZ = math.sin(45*i) * 10
	male = viz.add('male.cfg')
	male.translate(newX,-10,newZ)
	male.rotate(180,0,0)
	avatars.append(male) #Save avatar in list
The interval that they appear is set by a timer. Here is that portion of the code.

Code:
def mytimer(num):
	global avatars
	if num == ANIMATION:
		
		#Calculate elapsed time since last update
		elapsed = viz.elapsed()
		
		#Update each active ball
		for bullet in bullets:
			if bullet.active:
				#Move the ball and check if it has collided with any objects
				MoveBullet(bullet,elapsed)
		
	elif num == START_AVATAR:
		global nextAvatar
		#Get the next available avatar and start it
		avatar = avatars[nextAvatar]
		#favatar = favatars[nextAvatar]
		walkAvatar(avatar)
		#walkAvatar(favatar)
		nextAvatar = (nextAvatar + 1) % NUM_AVATARS
		viz.starttimer(START_AVATAR,TIME_BETWEEN_AVATARS)


#Restore next available avatar
vizact.onkeydown(' ',RestoreAvatar)

#Shoot a ball whenever left mousebutton is clicked
vizact.onmousedown(viz.MOUSEBUTTON_LEFT,shootBullet)

#Create callbacks for timer events
viz.callback(viz.TIMER_EVENT,mytimer)

Last edited by betancourtb82; 03-15-2006 at 11:06 AM.
Reply With Quote
  #2  
Old 03-15-2006, 02:01 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Can you be more specific on where you want them to appear. Can you just select random coordinates within a certain range?
Reply With Quote
  #3  
Old 03-19-2006, 01:56 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
I would like for them to appear within a radius of the subject. I want them to appear in front, to the left and right and behind the subject and certain intervals. They don't have to be random to the programmer, but appear random to the user. In other words, the order they appear is not important. So, basically, what I need to do is have them appear around the user coming in from all directions.
Reply With Quote
  #4  
Old 03-20-2006, 02:10 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

The following code will compute a random position within a certain radius.
Code:
#Get random direction
angle = viz.radians(vizmat.GetRandom(0,360))
	
#Get random radius between 5 and 10
radius = vizmat.GetRandom(5,10)
	
#Compute position
x = math.sin(angle) * radius
z = math.cos(angle) * radius
Reply With Quote
  #5  
Old 03-21-2006, 09:06 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Talking

Thanks! That really
Reply With Quote
  #6  
Old 03-21-2006, 09:14 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Talking

Thanks! That really helped out
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:50 AM.


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