WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-28-2006, 11:27 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Multidimensional Arrays

I was wondering if anyone could help me with a multidimensional array. I need to make an array that satisfies 3 conditions. There will be 3 different avatars, each having to hold 3 different items(gun, camera, cell phone). There has to be 10 of each of these conditions (shown in attachment). Any ideas? Thanks. I'm thinking it would be a multidimensional 3x3 array that I can call 10 times. Another idea I had was just make a 30x30 array but I think that would take too long to load. Please help.
Attached Files
File Type: txt chart.txt (184 Bytes, 560 views)
Reply With Quote
  #2  
Old 04-28-2006, 04:50 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I don't understand what you are asking for. How many avatars do you need at any given time? What exactly do you need to do with these avatars?
Reply With Quote
  #3  
Old 04-30-2006, 11:44 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
I need 3 separate avatars, a mexican-american, a white-american, and the experimenter. Each of these avatars will hold one of three items, a camera, a cell phone or a gun. Technically I have to have 90 different avatars, but I think I can use the same three avatars and just do different "link" commands. They will be coming toward the subject relatively quickly and the subject will have to decide whether or not they feel threatened and if they are threatened, shoot the person coming at them. The avatars should come at the subject at a randomized fashion, but at the end of the study, the following conditions must be met:

Mex-american - 10 cameras, 10 cell phones, 10 guns
wht-american - 10 cameras, 10 cell phones, 10 guns
experimenter - 10 cameras, 10 cell phones, 10 guns

Each avatar must hold one of the three items 10 different times. To the subject it should appear as if 90 avatars are coming at them (not necessarily all at once). I hope that's a little more clear. If not, please let me know.

Thanks
Reply With Quote
  #4  
Old 05-01-2006, 03:31 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

If you are only viewing each avatar one at a time, then you only need to add 3 avatars. When you are starting an avatar link the appropriate object to it. When you are done with the avatar unlink the object from it.
Reply With Quote
  #5  
Old 05-02-2006, 08:15 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
The only problem with that is that I would need more than 3 avatars to come out at once. The experimenter wants a continous flow of avatars. Would I be able to do this w/only an array of 3 avatars and the link and unlink?
Reply With Quote
  #6  
Old 05-02-2006, 09:49 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

You need to create at least the same number of avatars that you want to be visible at the same time. So if you only need 6 avatars to be visible at a time, then you need at least 6 avatars.
Reply With Quote
  #7  
Old 05-04-2006, 10:25 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Thanks that helped a lot. I have the program functioning as I wanted it to. My next step is to "tag each avatar". When I call the avatars using:
Code:
#Create all the avatars and add them to the waiting list
for x in range(0,3):
 if x == 0:
  male = viz.add(people[0]) 
  male.scale(.1,.1,.1)
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[0])
  myphone.scale(.0005,.0005,.0005)
  male.linkbone(link,'skel_HandR')
 elif x == 1:
  male = viz.add(people[1])
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[1])
  myphone.scale(.0005,.0005,.0005)
  myphone.translate(0,-.25,.17)
  myphone.rotate(180)
  male.linkbone(link,'skel_Neck')
 elif x ==2:
  male = viz.add(people[2])
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[2])
  myphone.scale(.0008,.0008,.0008)
  myphone.rotate(66.51,151.49,86.01)
  myphone.translate(-0.02,0.04,0.02)
  male.linkbone(link,'skel_HandRF')
 male.translate(3*x,-10,10)
 male.rotate(180)
 #Add the avatar to the waiting and lemming list
 waitlist.append(male)
 characters.append(male)
Once they get shot they go through a RemoveAvatar function and a RestoreAvatar function as shown below:

Code:
def RestoreAvatar():
 global keyindex
 if len(dead_list):
  print "avatar restored"
  avatar = waitlist.pop() #Ressurrect dead avatar
  avatar.visible(1) #Make it visible
  characters.append(avatar) #Add it to avatar list
 # walkAvatar(avatar)
 print 'avatar restored'
def RemoveAvatar(avatar):
 avatar.visible(0) #Hide avatar
 #avatar._face_.visible(0) #Hide face
 avatar.speed(1) #Restore speed
 characters.remove(avatar) #Remove from list
 dead_list.append(avatar) #Add to dead list
There are a couple things I have to do that I'm not sure how to do. First of all, I have to say which avatar (e.g. avatar 1 with object 1, avatar 1 w/object 2...etc.) I was thinking of having a variable that increments whenever each avatar gets shot, however the problem I'm having is I don't know how to have the program tell which avatar got shot. Once they get shot, I have to unlink their object and link them back to another object for the next time they appear. FYI here is the code for what happens when they get shot:

Code:
 if info.intersected:
  autospawn = not autospawn
  print 'intersect point is',info.intersectPoint
  if info.object in waitlist:
   print "in waitlist"
  if info.object in dead_list:
   print "in dead_list"
  if info.object in characters:
   print "in characters"
   avatarsHit = avatarsHit + 1
   viz.playsound('arrgh.wav')
   print 'Avatars hit: ', avatarsHit
   WaitThenFreeze = vizact.sequence( vizact.waittime(info.object.getduration(7)+.001), vizact.speed_node(0) )
   info.object.execute(7)
   info.object.clear(viz.ALL)
   info.object.clear(viz.CURRENT_ACTION)
   info.object.add(WaitThenFreeze) #Add the action to the avatar
   RemoveAvatarAction = vizact.call(RemoveAvatar,info.object)
   info.object.add(RemoveAvatarAction) #Add action to remove avatar
Please help
Reply With Quote
  #8  
Old 05-04-2006, 10:48 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I'm not sure exactly what you are asking here. You just need a way to identify each avatar when they get shot? Just add some tag to each avatar when you create/restore it.
Code:
male.tag = 'avatar 1 with object 2'
Then when they get shot just look up the tag:
Code:
print info.object.tag,'got shot'
Reply With Quote
  #9  
Old 05-04-2006, 11:00 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Talking

PERFECT! Thanks for the help. Can I do the same thing with the object they are holding? Since the object is a different array that's merely linked to this one, how do I identify the object in hand? Basically if it's a gun or a cell phone I just need to specify that it's "non-threatening". If it's a gun then i have to specify that it's "threatening".

Thanks again!
Reply With Quote
  #10  
Old 05-04-2006, 11:07 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

In python, you can add as many attributes to an object as you wish. So to determine if an object is "threatening" simply give it an attribute which says so.
Code:
donut = viz.add('donut.wrl')
donut.isThreatening = False
donut.isDelicious = True

gun = viz.add('gun.wrl')
gun.isThreatening = True
gun.isDelicious = False
Reply With Quote
  #11  
Old 05-04-2006, 12:35 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Ok, I understand that part, but my problem is how do I let the program know that the avatar is holding that object. In the MoveBullet function shown above, I identify the avatar "attribute" as info.object.tag, but how do I do that with the object they are holding. Can I do something like info.object.tag.linkbone to identify each object of each avatar?

Code:
for x in range(0,3):
 if x == 0:
  male = viz.add(people[0]) 
  male.scale(.1,.1,.1)
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[0])
  myphone.scale(.0005,.0005,.0005)
  male.linkbone(link,'skel_HandR')
  male.tag = 0
  myphone.threatening = TRUE
  
 elif x == 1:
  male = viz.add(people[1])
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[1])
  myphone.scale(.0005,.0005,.0005)
  myphone.translate(0,-.25,.17)
  myphone.rotate(180)
  male.linkbone(link,'skel_Neck')
  male.tag = 1
  myphone.threatening = FALSE
 elif x ==2:
  male = viz.add(people[2])
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[2])
  myphone.scale(.0008,.0008,.0008)
  myphone.rotate(66.51,151.49,86.01)
  myphone.translate(-0.02,0.04,0.02)
  male.linkbone(link,'skel_HandRF')
  male.tag = 2
  myphone.threatening = FALSE
 male.translate(3*x,-10,10)
 male.rotate(180)
 #Add the avatar to the waiting and lemming list
 waitlist.append(male)
 characters.append(male)
Reply With Quote
  #12  
Old 05-04-2006, 12:55 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

As I already mentioned, you can add any attribute to an object. So just add an attribute to each avatar which contains a list of the objects it is holding.
Code:
male.holding = [gun,phone,bowlingBall]
.
.
.

print 'Avatar is holding',info.object.holding
Reply With Quote
  #13  
Old 05-04-2006, 02:13 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Thank you, worked GREAT
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 07:58 PM.


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