WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-16-2013, 10:47 AM
fordprefect fordprefect is offline
Member
 
Join Date: Oct 2012
Location: Vienna, Austria, Europe
Posts: 39
understanding vizact.moveTo

Hello,

it seems I have problems understanding this moveTo. What I'd like to achieve is to have two actions that move a node one unit (meter) along it's Y axis up or down. That way I can use them on different nodes in the object, regardless of the original position of the node. So I created
Code:
_ceilDist = 1
_ceilMode = viz.REL_LOCAL

_actYplus = vizact.moveTo( [0,_ceilDist,0], time=4, mode=_ceilMode, interpolate=vizact.easeInOut)
_actYmin = vizact.moveTo( [0,-_ceilDist,0], time=4, mode=_ceilMode, interpolate=vizact.easeInOut)

def cmdOpenCeil(parName):
	car.getChild(parName).runAction(_actYplus)

def cmdCloseCeil(parName):
	car.getChild(parName).runAction(_actYmin)
My problems are:
  1. When used as shown above, the distance the part is moved is more that one (meter) by far!
  2. When used as shown above, the interpolation is starting gradually, but at the end the motion is cut off, without slowing down. Same with (examples) vizact.easeInOutCircular, .easeInOutExp, .easeInOutSine, .cubic(0.1,0.6), .easeOut, .backOut
  3. When used with different time values (e.g. 6 seconds for plus direction) then the speed is not changed, but the distance is increased

Same effect when using addAction instead.

What point am I missing here, and is there a better (working) approach?

BR Walter
__________________
21 is only half the truth.
Reply With Quote
  #2  
Old 07-16-2013, 06:34 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Does the following work for you?
Code:
import viz
import vizact
viz.go()

viz.add('dojo.osgb')

ball = viz.addChild('beachball.osgb',pos=[0,1,4])

moveUp = vizact.move(0,1,0,1)
moveDown = vizact.move(0,-1,0,1)

vizact.onkeydown('1',ball.addAction,moveUp)
vizact.onkeydown('2',ball.addAction,moveDown)
Reply With Quote
  #3  
Old 07-17-2013, 03:06 AM
fordprefect fordprefect is offline
Member
 
Join Date: Oct 2012
Location: Vienna, Austria, Europe
Posts: 39
Hi Jeff,

that code works ok as it is. Also, when I adopt it to my script, it does the trick and moves the node by 1 meter. So thank you for the workaround.

But
  • .move is not as convenient because it is working with speed instead of distance. So I have to calculate the speed myself instead of using the conveniently designed interface of .moveTo.
  • .move does not allow for gradually picking up the speed
  • would there be rounding issues with .move when moving back and forth a part several timesusing different timings (when fractions occur)?

Therefore I'd like to repeat: what am I missing to understand how .moveTo works?

When I use your script as a basis and try out .moveTo again
Code:
import viz
import vizact
viz.go()

viz.add('dojo.osgb')

ball = viz.addChild('beachball.osgb',pos=[0,1,4])

_ceilDist = 1
_ceilMode = viz.REL_LOCAL
_actYplus = vizact.moveTo( [0,_ceilDist,0], time=1, mode=_ceilMode, interpolate=vizact.easeInOut)
_actYmin = vizact.moveTo( [0,-_ceilDist,0], time=1, mode=_ceilMode, interpolate=vizact.easeInOut)

vizact.onkeydown('3', ball.addAction, _actYplus)
vizact.onkeydown('4', ball.addAction, _actYmin)

def debugPos():
	print 'posi:', ball.getPosition()
vizact.ontimer(3.3, debugPos)
then the position of the ball after moving seems to depend on the interpolation used. it is (truncated to 2 decimals)
  • 11.54 .easeInStrong
  • 14.44 .easeInCircular
  • 21.53 .easeIn
  • 31.52 .easeInOut .easeInOutStrong .easeInOutCircular .cubic .linear
  • 41.51 .easeOut
  • 48.59 .easeOutCircular
  • 51.50 .easeOutStrong

Giving time=2 does not lower the speed but extends the distance, e.g. 61.55 for .easeInOut

Using parameter speed=1 instead of time=1 in the code above yields same result, BUT using speed=.1 results in y=301.75 while speed=10 yields y=4.50

even more confused the more I try,
Walter
__________________
21 is only half the truth.
Reply With Quote
Reply

Tags
action, moveto, positioning, subnode

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 10:53 AM.


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