WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 12-15-2014, 04:33 AM
fordprefect fordprefect is offline
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:

  • 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
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.

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?

I have modified the example code for proximity areas to show the effect
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

import vizinfo

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

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

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

def onExitSensor(e):
	print 'Exited',

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

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

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

# 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

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

# + 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
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

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 07:35 AM.

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