WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-12-2005, 06:01 AM
sjroorda sjroorda is offline
Member
 
Join Date: Apr 2005
Posts: 13
Walking avatars --> collision detection?

Currently I am working on a scene in which I as viewer am surrounded by a lot of walking people (the default avatars).

However, the walkto-command sometimes lets an avatar walk through 'myself', resulting in a jump of the viewpoint (due to the collision detection). In what way is it possible to solve this problem (proposed it is possible!)? I can mess a little with the coordinates I send the character to, but as I can walk freely through the scene, this cannot be guaranteed.

Another problem is avatars walking through each other. Don't they have any collission detection?

And to ask my last question: is it possible to group avatar objects into an array? Take a look at my code below and you'll understand why .

See an example piece of code below:
PHP Code:
import viz
import whrandom

# Handles all timer events for the therapist machine
def mytimer(num) :
    if (
num == 1) :
        
view_pos view.get(viz.HEAD_POS);
        
a1.act(a1.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a2.act(a2.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a3.act(a3.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a4.act(a4.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a5.act(a5.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a6.act(a6.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a7.act(a7.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a8.act(a8.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));
        
a9.act(a9.walkto(view_pos[0] + whrandom.randint(-23), 0view_pos[2] + whrandom.randint(-23)));

viz.go(0);
view viz.get(viz.MAIN_VIEWPOINT);

# Create the room and make it a bit larger
myroom viz.add('../room/room.wrl');
myroom.scale(10310);

# Set background color
viz.clearcolor(000);

# Turn on collision detection
viz.collision(viz.ON);
viz.stepsize(0);

# Test moving avatars
a1 viz.add('female.cfg'); a1.translate(101);
a2 viz.add('female.cfg'); a2.translate(101);
a3 viz.add('female.cfg'); a3.translate(101);
a4 viz.add('female.cfg'); a4.translate(101);
a5 viz.add('female.cfg'); a5.translate(101);
a6 viz.add('male.cfg');   a6.translate(101);
a7 viz.add('male.cfg');   a7.translate(101);
a8 viz.add('male.cfg');   a8.translate(101);
a9 viz.add('male.cfg');   a9.translate(101);

viz.callback(viz.TIMER_EVENTmytimer);
viz.starttimer(11viz.FOREVER); 
Reply With Quote
  #2  
Old 09-12-2005, 10:16 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

There is no built-in way to prevent avatars colliding with each other or having them collide with the viewpoint. You will have to perform this collision check manually. You could create a timer that checks if two avatars are a certain distance from each other and stop them if they are. You could do the same with the viewpoint too.

Here is some code to use arrays to create your avatars:
Code:
#Create the avatars
avatars = []
for x in range(9):
    a = viz.add('female.cfg')
    a.translate(1,0,1)
    avatars.append(a)

#Have all the avatars walk
for a in avatars:
    a.act(a.walkto(view_pos[0] + whrandom.randint(-2, 3), 0, view_pos[2] + whrandom.randint(-2, 3)))
Reply With Quote
  #3  
Old 09-15-2005, 06:06 PM
Veleno Veleno is offline
WorldViz Team Member
 
Join Date: Sep 2005
Posts: 148
A thought on this problem came to mind --

Since avatars do not detect collision with each other, how about giving them something to collide with?

It would seem to me that it could be possible to have each avatar (and the viewpoint) surrounded with invisible rectangular prisms (or octagonal for a more "round" fit) that follow them wherever they go.

If avatar A gets to close to avatar B, then avatar A will be stopped by the prism surrounding avatar B.
Reply With Quote
  #4  
Old 10-13-2005, 05:47 AM
Eunice Eunice is offline
Member
 
Join Date: Oct 2005
Posts: 21
This is called 'the bounding volume' method in collision dection.

Quote:
Originally posted by Veleno
It would seem to me that it could be possible to have each avatar (and the viewpoint) surrounded with invisible rectangular prisms (or octagonal for a more "round" fit) that follow them wherever they go.

If avatar A gets to close to avatar B, then avatar A will be stopped by the prism surrounding avatar B.
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 02:00 AM.


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