WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 04-17-2013, 04:16 AM
uncleseano uncleseano is offline
Join Date: Apr 2013
Posts: 1
Collision Help

Heya I need help trying to get a ball to collide properly with a box and print out a generic statement. Need help badly thanks

boxes = []
balls = []

for i in range(GRID_WIDTH):
for j in range(GRID_HEIGHT):
#Add a box model
box = viz.add('box.wrl',cache=viz.CACHE_CLONE)
#Use the boxes bounding box for collisions
#Add the box to the list

for x in range(MAX_BALLS):
#Add a ball model
ball = viz.add('ball.wrl',scale=(3,3,3),cache=viz.CACHE_C LONE)
#The balls collision will be represented by the bounding sphere of the ball
ball.enable( viz.COLLIDE_NOTIFY )
#Add the body to the list

#Create a generator this will loop through the balls
nextBall = viz.cycle(balls)

breakerBox = viz.add('box.wrl')

greenBox = viz.add('boxee.wrl')
#greenBox.enable( viz.COLLIDE_NOTIFY )

#This function is called when a collision occurs
def ballBoxCollision(e):
if ball.intersect == greenBox.intersect:
print 'collision'
#if e.ball in balls == ground:

viz.callback( viz.COLLIDE_BEGIN_EVENT, ballBoxCollision )
Reply With Quote
Old 04-18-2013, 10:37 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,466
Please post code using the code tags to preserve the indentation. You can find out which Vizard nodes collided from the event object e passed to the collision callback function. Take a look at the Event Reference page for more information.

If viz.COLLIDE_NOTIFY is enabled on the balls you can check to see if e.obj2 is the greenBox and you'll know a ball collided with it.
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
Physics: Ball Bounces Unexpectly Based Upon Size + Ring Collision Shape mhead10 Vizard 3 11-02-2012 01:44 PM
Main view collision problem AtomicRaiden Vizard 4 10-06-2011 11:48 AM
Collision Exception jassel41 Vizard 2 11-09-2010 05:08 PM
Collision and avatar animation shahramy Vizard 2 10-26-2010 11:47 PM
Collision with child nodes rubberpimple Vizard 4 09-17-2008 04:27 PM

All times are GMT -7. The time now is 03:00 PM.

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