WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-16-2012, 07:13 AM
Kevin1270 Kevin1270 is offline
Member
 
Join Date: Sep 2012
Posts: 3
Viewpoint with collision buffer issue

Hi. I'm having a problem with a viewpoint offset implemented with <viz>.collisionbuffer. I'm using this to detect when a hand fixed to the viewpoint touches a ball on a pole. If the ball is approached so that the view is moving straight ahead, collision will be detected, but if the ball is approached from the side, collison is only being detected at a point behind the viewpoint, as if the offset set by collisionbuffer had flipped 180 degrees around the viewpoint. The code Im referring to is below - any help would be much appreciated.

import viz
import hand

viewHeight = 1.82
handViewOffset = [0.0, -0.2, 0.5]

class startProgram:
def __init__ (self, handViewOffset, viewHeight):
self.handViewOffset = handViewOffset
self.viewHeight = viewHeight
self.environmentFile = 'court.ive'
self.xScale = 1.0
self.yScale = 0.6
self.environment_handle = viz.add (self.environmentFile) # load environment
self.environment_handle.setScale (self.xScale * 1.5, 1.0, self.yScale * 0.75) # width, height, length
self.glove = hand.add (None)
self.glove.setGesture (hand.GESTURE_FLAT_HAND, False, 1.0)
self.closeHand ()
self.viewHandle = viz.MainView.setEuler (180.0, 0.0, 0.0)
viz.MainView.setPosition (0.0, self.viewHeight, 5.0)
viz.MainView.collisionbuffer (float (self.handViewOffset [2]) + 0.2)
viewLink = viz.link (viz.MainView, self.glove, enabled=True)
viewLink.setMask (viz.LINK_POS | viz.LINK_ORI)
viewLink.preTrans (handViewOffset)
viewLink.preEuler ([0.0, -45.0, 0.0])
viz.collision (viz.ON)
viz.callback (viz.COLLISION_EVENT, self.collisionCallback)
self.poleconfig = 'G' # TEMPORARY
self.addPoles ()
def collisionCallback (self, event):
print 'Collision Occurred'
def closeHand (self):
self.glove.getJointBone (hand.THUMB_1).setEuler (0.0, 0.0, -20.0)
self.glove.getJointBone (hand.THUMB_2).setEuler (0.0, 50.0, -40.0)
self.glove.getJointBone (hand.THUMB_3).setEuler (0.0, -20.0, -20.0)
self.glove.getJointBone (hand.PINKY_1).setEuler (0.0, -10.0, 20.0)
self.glove.getJointBone (hand.PINKY_2).setEuler (0.0, 0.0, 0.0)
self.glove.getJointBone (hand.RING_1).setEuler (0.0, 0.0, 10.0)
self.glove.getJointBone (hand.RING_2).setEuler (0.0, 0.0, 0.0)
self.glove.getJointBone (hand.INDEX_1).setEuler (0.0, 0.0, -20.0)
self.glove.getJointBone (hand.INDEX_2).setEuler (0.0, 0.0, 0.0)
def addPoles (self):
pole = viz.add ('pole.wrl')
poleDims = pole.getBoundingBox ()
poleScaleFactor = (self.viewHeight + float (self.handViewOffset [1])) / poleDims [1]
ballScaleFactor = poleDims [1] / self.viewHeight
pole.setScale (3 * [poleScaleFactor])
ballOnPole = viz.addChild ('white_ball.wrl', parent = pole)
ballOnPole.setScale (3 * [ballScaleFactor])
ballOnPole.setPosition (0, ballScaleFactor * viewHeight, 0)

viz.go ()
x = startProgram (handViewOffset, viewHeight)
Reply With Quote
 

Tags
collision


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
Issue Getting Quad Buffer Working nabrahamson Vizard 2 08-30-2012 10:43 AM
Vizard Collision (ON) issue kovitch Vizard 2 08-09-2011 02:40 AM
Collision problem Dave Vizard 2 09-16-2010 05:25 AM
Collision with child nodes rubberpimple Vizard 4 09-17-2008 05:27 PM
Avatar w/ hat cannot look at viewpoint TrashcanPatrol Vizard 5 08-19-2008 09:26 AM


All times are GMT -7. The time now is 06:17 PM.


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