Viewpoint with collision buffer issue
Hi. I'm having a problem with a viewpoint offset implemented with
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) |
Instead of using viz.collisionbuffer, calculate the distance between hand and ball every frame using vizmat.Distance to detect the touch. If you have Vizard 4, I would recommend using the vizproximity library.
|
Hi Jeff. Thanks for you reply. Actually, I have already done this and it works, but not as smoothly as the built-in API - when you collide with the ball using the built-in collision detection, it slides smoothly around the object. Besides, surely this kind of thing is why users would want to use a development environment like Vizard; to have an armoury of useful pre-written functions to do jobs just like this to save development time. I'm trying a number of different approaches to solve this, but my main goal is to do this with the API. If anyone as some possible solutions using Vizard functions, that would be really useful. In the meantime, I'll keep bashing away.
Thanks again for your help. |
I forgot to add that I don't have Vizard 4, so can't make use of the library mentioned. Thanks again.
Cheers, Kevin |
All times are GMT -7. The time now is 04:47 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC