#1
|
|||
|
|||
Collision
Hi, This code is trying to not allow the avatar to walk through the court’s wall and balloon.
May my collision statement for avatar is wrong, but this what I have found in tutorials. HTML Code:
import viz viz.go() viz.phys.enable() court= viz.add( 'court.ive' ) court.setPosition(0,0,15) viz.collision() balloon=viz.add('balloon.ive') balloon.setScale(7,7,7) balloon.setPosition(0,0,8) avatar=viz.add('vcc_female.cfg') walk_Forward = vizact.walkTo([0,0,20]) avatar.addAction(walk_Forward) avatar.collideBox(viz.COLLIDE_NOTIFY) avatar.disable(viz.DYNAMICS) Thanks, |
#2
|
|||
|
|||
If you want a collision with the balloon to occur you will need to add a collision shape to it and enable dynamics on the avatar. You could manually check to see if the avatar is near a wall and if it is end the walking action
|
#3
|
|||
|
|||
Jeff I tried with many ways; below is my modification but does not work
HTML Code:
import viz viz.go() viz.phys.enable() court= viz.add( 'court.ive' ) court.setPosition(0,0,15) viz.collision() balloon=viz.add('balloon.ive') balloon.setScale(7,7,7) balloon.setPosition(0,0,8) avatar=viz.add('vcc_female.cfg') walk_Forward = vizact.walkTo([0,0,20]) avatar.addAction(walk_Forward) balloon.collideMesh() avatar.disable(viz.DYNAMICS) balloon.disable(viz.DYNAMICS) |
#4
|
|||
|
|||
If you want the balloon to react to the collision you can not use the collideMesh, you'll have to use a different collide shape. Collide meshes do not react to forces. Also you have dynamics disabled on both the avatar and balloon. So you can remove these lines.
Code:
avatar.disable(viz.DYNAMICS) balloon.disable(viz.DYNAMICS) |
#5
|
|||
|
|||
well, JEFF, I have tried to follow the gallery example in tutorial as well as your advices. the collision works around main-view and all stuff react including avatar. but the avatar responses as an object(like the balloon).(avatar still walking through the wall and balloon)
any help would be appreciated HTML Code:
import viz viz.go() #viz.phys.enable() court= viz.add( 'court.ive' ) court.setPosition(0,0,15) viz.collision() avatar=viz.add('vcc_female.cfg') #view=viz.MainView #link=viz.link(view,avatar) #link.preTrans([0,-1.5,4]) #viz.MainView.collision() balloons=[] for i in range (0,4,3): balloon=viz.add('balloon.ive') balloon.setScale(7,7,7) balloon.setPosition(0,0,i+5) balloons.append(balloon) walk_Forward = vizact.walkTo([5,0,15]) avatar.addAction(walk_Forward) balloon.collideSphere() #avatar.disable(viz.COLLISION) |
#6
|
|||
|
|||
Here's an example with an avatar and a ball. You need to have collision shapes for both objects to have a collision. Your code did not have a collision shape for the avatar.
Code:
import viz viz.go() viz.phys.enable() court = viz.add('court.ive') court.collidePlane() avatar=viz.add('vcc_male.cfg', pos = [0,0,3]) shape = avatar.collideBox() shape.setDensity(10) ball = viz.add('ball.wrl', pos = [0,0,7]) ball.collideSphere() walk = vizact.walkTo([0,0,10]) vizact.onkeydown(' ', avatar.addAction, walk) Code:
viz.collision(viz.ON) If you want to stop the avatar from walking through the wall you could end the walkto action when the avatar is near the edge of the room |
#7
|
|||
|
|||
HI Jeff ,Thank you very much for your help.
I cannot understand the collision in vizard although it looks very easy! I have struggled to detect the collision event by more than one way but all them did not work . I followed Farshizzo’s example on this link http://forum.worldviz.com/showthread.php?p=5599 but did not work with my code HTML Code:
def oncollide(e): if e.obj1 in ball: print 'colllision' viz.callback(viz.COLLIDE_BEGIN_EVENT,oncollide) Any suggestion would be appreciated! |
#8
|
|||
|
|||
obj1 is the node that generated the event and obj2 is the node that obj1 collided with
|
#9
|
|||
|
|||
it works fine. but i am trying to use the following lines to see the score
HTML Code:
data = viz.Data() yield viztask.waitEvent( viz.COLLISION_EVENT, data ) HTML Code:
def onCollideBegin(e): if e.obj1 == rHandBox: if e.obj2 == box: box.color(colors.next()) viz.callback(viz.COLLIDE_BEGIN_EVENT,onCollideBegin) |
#10
|
|||
|
|||
WHat do you mean by see the score, how many collisions have occured?
I'm not sure how you are using your task function with this. |
#11
|
|||
|
|||
Well, I have attached with this thread a sample of what I am trying to use. Indeed, I am using exactly the tasks example in vizard teacher book.
In this code you will see 2 main faults which are the collision and score (I tried many ways with the score and at then I decided to use the example, however, all ways I tried did not work) Any help would be appreciated Thanks, |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Collision detection with specific models | just alex | Vizard | 1 | 02-06-2009 11:02 AM |
Collision Detection and Nearest Point to Probe | xabbu | Vizard | 2 | 01-06-2009 03:01 AM |
Collision with child nodes | rubberpimple | Vizard | 4 | 09-17-2008 04:27 PM |
Collision detection with haptic pen | mjabon | Vizard | 3 | 01-17-2008 06:35 PM |
collision events trigger | Eunice | Vizard | 1 | 01-03-2006 10:39 AM |