WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-15-2014, 04:33 AM
fordprefect fordprefect is offline
Member
 
Join Date: Oct 2012
Location: Vienna, Austria, Europe
Posts: 39
Arrow 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)
__________________
21 is only half the truth.
Reply With Quote
  #2  
Old 12-15-2014, 12:37 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Thanks for the example script showing the issue. I'll ask a developer about this.
Reply With Quote
Reply

Tags
debug, parent, vizproximity

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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


All times are GMT -7. The time now is 04:44 PM.


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