#1
|
|||
|
|||
CompositeShape proximity sensor
I'm designing an environment where it's important to track whether or not the subject is on or off a particular path. The path is fairly simple, composed of a QUAD_STRIP. However, the proximity sensors just provide Box and Sphere.
I'm generally ok with the amount of slop introduced by rounding up each quad in the quad strip to be rectangular and a Box. Ideally, it seems like a CompositeShape sensor composed of a Box for each quad in the strip should work well. But the Box shape assumes axis alignment. Sensors attach fine to their parent's coordinate system, and then rotate accordingly - but Boxes themselves don't have parents, and a CompositeShape seems to therefore only be able to be made of boxes aligned to the same coordinate system. Suggestions? Am I missing something? |
#2
|
|||
|
|||
You can create a custom vizproximity.Shape class that applies an arbitrary transformation on the underlying shape. Here is an example:
Code:
import viz import vizcam import vizshape import vizproximity viz.go() viz.fov(60) # Create manager tracked axes manager = vizproximity.Manager() manager.setDebug(True) manager.addTarget(vizproximity.Target(viz.MainView)) class TransformedShape(vizproximity.Shape): def __init__(self, shape, transform): self._shape = shape self._transform = viz.Matrix(transform) self._inverseTransform = self._transform.inverse() def containsPoint(self,point): """Returns whether the point is inside the shape""" # Transform point into local reference frame point_local = self._inverseTransform.preMultVec(point) # Return whether point is inside shape return self._shape.containsPoint(point_local) def createDebugNode(self,data): """Create and return node object for visualizing proximity shape""" group = viz.addGroup() group.setMatrix(self._transform) s = self._shape.createDebugNode(data) s.setParent(group) return group # Sensor callbacks def onEnter(e): print 'Entered' def onExit(e): print 'Exited' shapes = [] shapes.append( vizproximity.Sphere(0.3,(0,1,0)) ) shapes.append( vizproximity.Box([0.4,1.0,0.2]) ) xform = viz.Matrix() xform.setPosition((0.5,0.6,0)) xform.setEuler((0,0,-45)) shapes.append( TransformedShape(vizproximity.Box([0.2,0.5,0.2]),xform)) xform = viz.Matrix() xform.setPosition((-0.5,0.6,0)) xform.setEuler((0,0,45)) shapes.append( TransformedShape(vizproximity.Box([0.2,0.5,0.2]),xform)) xform = viz.Matrix() xform.setPosition((-0.3,-1,0)) xform.setEuler((0,0,-20)) shapes.append( TransformedShape(vizproximity.Box([0.2,0.8,0.2]),xform)) xform = viz.Matrix() xform.setPosition((0.3,-1,0)) xform.setEuler((0,0,20)) shapes.append( TransformedShape(vizproximity.Box([0.2,0.8,0.2]),xform)) sensor = vizproximity.Sensor(vizproximity.CompositeShape(shapes),None) manager.addSensor(sensor) manager.onEnter(sensor,onEnter) manager.onExit(sensor,onExit) # Setup environment vizshape.addGrid(color=[0.2]*3,pos=(0,-0.01,0)) viz.clearcolor(viz.GRAY) # Setup pivot navigation import vizcam cam = vizcam.PivotNavigate(distance=10) cam.rotateUp(60) viz.cam.setHandler(cam) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating a Vizard Sensor Plugin | farshizzo | Plug-in development | 25 | 08-01-2019 12:24 AM |
Unusual tracker sensor setup with Vizard | Zhi | Vizard | 2 | 06-12-2012 09:52 AM |
sensor or not sensor? | nige777 | Vizard | 0 | 03-29-2011 04:03 AM |
wiimote and sensor bar | masaki | Vizard | 1 | 03-06-2008 03:07 PM |
Multiple Copies of same sensor plugin | RedSpikeyThing | Plug-in development | 2 | 02-12-2008 02:10 PM |