WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-24-2014, 08:49 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
Question about postScale while linking two objects

Hello all,

here is what I want to achieve:

Link an object (destination) to the viewpoint (source), so that it moves with the viewpoint BUT at a different speed. E.g. if the viewpoint moves 10m, the linked object should only move 2m.

I managed to do that with the postScale command. However, the scaling is also applied to the inital offset of the destination object. This is a problem, because I want to destination object to start out at a certain offset, independent of the speed scaling.

I tried to manually set a transformation matrix but failed so far. I included a small sample script. Here, the pigeon starts out at an offset of [3,0,3] from the viewport. I want it to move with the viewport, but at a different speed.
If I apply a postScale, the pigeon will NOT start out at an offset of [3,0,3], but at the offset multiplied by the scale.

Code:
import viz

model = viz.add('pit.osgb')

pigeon = viz.addAvatar('pigeon.cfg')
pigeon.setScale(3,3,3)


# with linking
pigeonlink = viz.link(viz.MainView, pigeon, offset = [3,0,3], mask = viz.LINK_POS)

postScale = pigeonlink.postScale([0.8,0,0.8], target = viz.LINK_POS_OP)

viz.setMultiSample(8)
viz.fov(90)
viz.go()
Thanks for your help in advance!
Reply With Quote
  #2  
Old 10-24-2014, 08:58 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I think you need to apply the offset after the scale. Try the following:
Code:
pigeonlink = viz.link(viz.MainView, pigeon, mask = viz.LINK_POS)
pigeonlink.postScale([0.8,0,0.8], target = viz.LINK_POS_OP)
pigeonlink.postTrans([3,0,3], target = viz.LINK_POS_OP)
Reply With Quote
  #3  
Old 10-24-2014, 09:20 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
That worked wonderfully, thanks!

I the meantime, I also managed to fix it by manually correcting the offset by the scaling factor * initial offset.

Your solution is much more elegant, thanks again!
Reply With Quote
  #4  
Old 10-24-2014, 09:38 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
EDIT: fixed.
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking Objects new_horizon Vizard 1 04-20-2012 06:07 AM
"reverting" between animations & linking objects to bones Lithium Vizard 3 08-08-2011 11:01 AM
sensor linking question smith11235 Vizard 6 05-31-2011 04:58 PM
Linking and Intersense Question durf Vizard 1 07-23-2009 10:09 AM
Could not find plugin to load objects... halley Vizard 1 05-30-2006 11:01 AM


All times are GMT -7. The time now is 05:08 AM.


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