|
#1
|
|||
|
|||
sensor radius bug?
Hey there!
I am using the circleArea proximity sensor so one can "collect" objects. I want the difference between the radius of the object and the radius of the sensor to be constant. Therefore I pass the radius of the object plus my constant value to the circleArea sensor and then link the sensor to the object. Before you start the programm you can change the transformation of the object that will be "collected". Now here is my Problem: When I scale the object the sensor is much bigger (or smaller) as it should be. I think its because I linked the sensor and the object. But I need the link so I can easily let the object disappear, when someone "collects" it. To show my problem I wrote an example, where I just pass a constant to the sensor and it still gets much bigger as the one of the non-scaled object: Code:
import viz import vizshape import vizproximity viz.setMultiSample(4) viz.fov(60) viz.go() viz.MainView.setPosition(0,5,-4) viz.MainView.setEuler(0,45,0) manager = vizproximity.Manager() #to see the circleArea manager.setDebug(viz.ON) purpleCylinder = vizshape.addCylinder(height=2.0,radius=0.3,topRadius=None,bottomRadius=None,yAlign=vizshape.ALIGN_MIN,slices=20,bottom=True,top=True) purpleCylinder.color(viz.PURPLE) purpleCylinder.setPosition(-2.5,0,0) #non-scaled purple cylinder purpleSensor = vizproximity.CircleArea(radius=0.7) #link sensor to the object linkedPurpleSensor = vizproximity.Sensor(purpleSensor, purpleCylinder) manager.addSensor(linkedPurpleSensor) print 'purple: ', linkedPurpleSensor redCylinder = vizshape.addCylinder(height=2.0,radius=0.3,topRadius=None,bottomRadius=None,yAlign=vizshape.ALIGN_MIN,slices=20,bottom=True,top=True) redCylinder.color(viz.RED) redCylinder.setPosition(1,0,0) #scale the second red cylinder up redCylinder.setScale(4,4,4) redSensor = vizproximity.CircleArea(radius=0.7) #link sensor to the object linkedRedSensor = vizproximity.Sensor(redSensor, redCylinder) manager.addSensor(linkedRedSensor) print 'red: ', linkedRedSensor purple: Sensor(shape=CircleArea(radius=0.7, center=(0.0, 0.0)), source=NodeSource(node=viz.VizPrimitive(2), flag=4, name='')) red: Sensor(shape=CircleArea(radius=0.7, center=(0.0, 0.0)), source=NodeSource(node=viz.VizPrimitive(4), flag=4, name='')) Can someone tell me what happened? Am I doing something wrong or is it a bug? |
#2
|
|||
|
|||
One solution would be to avoid linking the sensor and the 3d node.
When you create a sensor, you can specify a 3d node as its source. This way, you can make the 3d node disappear by calling the source of the activated sensor and let it disappear Below is a small example: Code:
# create ball and sensor ball = vizshape.addSphere(radius = 10) ballSensor = vizproximity.Sensor(vizproximity.CircleArea(10),source=ball) # wait for sensor to be activated, can be a list of sensors enteredSensor = yield vizproximity.waitEnter(ballSensor) # get 3d node of ball and let it disappear ball = enteredSensor.sensor.getSource() ball._node.visible(viz.OFF) Last edited by mape2k; 07-29-2015 at 04:44 AM. |
#3
|
|||
|
|||
I thought that was exactly what I've done? I just wrote the sources name instead of writing source=sourceName. Am I missing something?
However, it comes to the same result: The sensors have different sizes, although the passed radius is the same. |
#4
|
|||
|
|||
True! Sorry, I did not try out your code and replied only to the text you wrote.
With normal linking, you can specify a mask to only link position, orientation, etc. With sensor linking, that does not seem to be possible. Maybe one of the devs could shed some light into this? |
#5
|
|||
|
|||
Thanks for the example script that reproduces the issue. I'll ask a developer to take a look.
|
#6
|
|||
|
|||
Thank you!
Could you please let me know what the developer said? I really got to get this working because we would like to use it for a study |
#7
|
|||
|
|||
As a workaround, would the following work for you? This sets a group node to be the sensor's source object. The red cylinder is linked to the group node and scaling the cylinder does not affect the area shape:
Code:
import viz import vizshape import vizproximity viz.setMultiSample(4) viz.fov(60) viz.go() import vizcam cam = vizcam.PivotNavigate(center=[1,0,0],distance=5) cam.rotateUp(30) manager = vizproximity.Manager() #to see the circleArea manager.setDebug(viz.ON) redCylinder = vizshape.addCylinder(height=2.0,radius=0.3,topRadius=None,bottomRadius=None,yAlign=vizshape.ALIGN_MIN,slices=20,bottom=True,top=True) redCylinder.color(viz.RED) group = viz.addGroup(pos=[1,0,0]) viz.link(group,redCylinder) #scale the second red cylinder up redCylinder.setScale(2,2,2) redSensor = vizproximity.CircleArea(radius=0.7) #link sensor to the object linkedRedSensor = vizproximity.Sensor(redSensor, group) manager.addSensor(linkedRedSensor) |
#8
|
|||
|
|||
Hey Jeff!
I guess this workaround wouldn't work for me, because there is a various number of cylinders placed in my setting and every cylinder has its own proximitysensor. I don't know how I could get the right cylinder to an activated sensor with that kind of linking. Maybe you have an idea to this? Anyway, I've got a solution that is not very performant but it works well enough for me: The sensores are placed at the same position like the cylinders. When setting the sensors the source is NONE, so that the sensores will not be affected by the scaling of the cylinders. Next I just set up a list of tuples with the sensor as the first part of the tuple and the object as the second, so when a sensor is activated I can find it in that list with the right object and delete the object and the sensor. Could you still let me know what the developer said to the bug or when it is going to work? Thank you for your help |
Thread Tools | |
Display Modes | Rate This Thread |
|
|