WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 09-01-2014, 04:31 PM
Notch Notch is offline
Join Date: Jan 2014
Posts: 15
Detecting collision with on-the-fly object

I have generated on-the-fly cylinders using vizshape.addCylinder(). I would like to detect collisions with a specific cylinder.

I am able to detect collisions with objects using viz.callback(viz.COLLISION_EVENT,onCollision). I can get the name of the object collided with by using the following code:

def onCollision(info):
	print('Collided with object',info.object)
Although this returns something like "Collided with object viz.VizPrimitive(9)", but I have way knowing what 'VizPrimitive(9)' is. I have several objects in the scene, and ideally would like to add names to the objects at the time they are created, so that I can then work out what I'm colliding with later on.

How do I name on-the-fly objects, and how do I then get the name of the object when a collision occurs?
Reply With Quote
Old 09-08-2014, 03:51 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,471
You can check to see if info.object matches the name assigned to the cylinder:

import viz
import vizshape


dojo = viz.addChild('dojo.osgb')
cylinder = vizshape.addCylinder(pos=[0,1.8,4])

def onCollision(info):
	if info.object == cylinder:
		print 'Collided with cylinder'

Reply With Quote
Old 09-09-2014, 05:41 AM
Notch Notch is offline
Join Date: Jan 2014
Posts: 15
Thanks very much. It looks like what I hadn't appreciated is that it is not possible to explicitly name objects (with a string), but instead I needed to follow the handle to the object.

Got it all working now
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
Real time collision and object navigation sunil.nair Vizard 11 10-04-2013 09:10 PM
Find collision point of line and arbitrary object asdf Vizard 2 01-28-2013 11:04 AM
retrieve Object names Geoffrey Vizard 11 12-11-2009 05:26 AM
linked object collision pgagolf Vizard 1 04-19-2007 02:27 PM
when collision mode is on, can i "turn it off" for an individual object? Vdoug Vizard 1 09-22-2005 01:14 PM

All times are GMT -7. The time now is 11:37 AM.

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