WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   vizproximity hint - debug 2D areas related to a source only after adding a target! (https://forum.worldviz.com/showthread.php?t=5248)

fordprefect 12-15-2014 04:33 AM

vizproximity hint - debug 2D areas related to a source only after adding a target!
 
Hello @ll,

FYI I'll post a problem (with root cause and -if you want to say so- a workaround) that cost me quite some time to track down:

Conditions
  • create a proximity manager and set it to debug mode
  • sensor: use a 2D proximity area..
  • ..connected to a source
  • for the moment, do not add a target
Problem
The outcome is that world coordinates will be used to position the area, instead of the parent's coordinate system. And when the source is moved, the area is not affected.

Workaround/Solution
It will work ok only after a target was added to the manager.

Question to WorldViz
Is that intended behaviour, or an issue that could be fixed in the future?

Example
I have modified the example code for proximity areas to show the effect
Code:

"""
Demonstrates that area shapes from the vizproximity module are indicated
on their correct position only after a target is added to the manager.
The cone should be enclosed by the rectangle which should move together with the cone
but will do so only while a target is added to the manager.
Use x/X to move the cone
Use t to add and T to remove a target from the manager.
Use the WASD keys to move the axes and trigger the sensors (when target active).
"""
import viz
import vizact                # +
import vizcam
import vizshape
import vizproximity
viz.go()
viz.fov(60)

import vizinfo
vizinfo.InfoPanel()

# Add axes controlled by keyboard
axis = vizshape.addAxes(length=0.5)
tracker = vizcam.addKeyboardPos()
viz.link(tracker,axis)

# Create manager tracked axes
manager = vizproximity.Manager()
manager.setDebug(True)
target = vizproximity.Target(tracker)

# Sensor callbacks
def onEnterSensor(e):
        print 'Entered',e.sensor.name

def onExitSensor(e):
        print 'Exited',e.sensor.name

manager.onEnter(None, onEnterSensor)
manager.onExit(None, onExitSensor)

def AddSensor(shape,name, source=None):                # !
        sensor = vizproximity.Sensor(shape,source)        # !
        sensor.name = name
        manager.addSensor(sensor)

# Add circle area
shape = vizproximity.CircleArea(0.5,center=[0,2])
AddSensor(shape,'Circle')

# Add rectangle area
# connect it to a source object (BUT IT IS NOT!!)          +
node = vizshape.addCone(pos=[3,0,2])                # +
shape = vizproximity.RectangleArea([1.8,1.2],center=[0,0])
AddSensor(shape,'Rectangle',node)                        # !

# + shift the node
xDist = 1.0
xTime = 1.0
vizact.onkeychar('x', node.addAction, vizact.move(-xDist, 0, 0, xTime))
vizact.onkeychar('X', node.addAction, vizact.move(+xDist, 0, 0, xTime))

# Setup environment
vizshape.addGrid(color=viz.GRAY,pos=(0,-0.01,0))
viz.clearcolor(viz.SLATE)

# Setup pivot navigation
import vizcam
cam = vizcam.PivotNavigate(distance=10,center=(0,0,3))
cam.rotateUp(60)
viz.cam.setHandler(cam)

# + add/remove target on demand
vizact.onkeychar('t', manager.addTarget, target)
vizact.onkeychar('T', manager.removeTarget, target)


Jeff 12-15-2014 12:37 PM

Thanks for the example script showing the issue. I'll ask a developer about this.


All times are GMT -7. The time now is 01:17 AM.

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