WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-16-2009, 11:46 AM
durf durf is offline
Member
 
Join Date: Feb 2009
Posts: 61
mouse link

Hello,

Is there a way to link the mouse to an obj rather then using ppt to an object?

Thanks
Reply With Quote
  #2  
Old 07-16-2009, 12:17 PM
durf durf is offline
Member
 
Join Date: Feb 2009
Posts: 61
I tried viz.link(viz.Mouse, box) and all I can get it to do is move side to side and not very much. I even tried this to improve the amount it moves, boxLink.postScale([4,1,6],target = viz.LINK_FULL_OP).

my view is a straight down view(IE view would be on a ceiling looking straight down on the floor.)

Is there a way to move the box in a x,z movement?
Reply With Quote
  #3  
Old 07-20-2009, 10:03 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The problem is that the mouse position is in 2D coordinates, and your model is in 3D coordinates, so there isn't an easy way to convert between the two reference frames. You can use the viz.MainWindow.screenToWorld command to get the line that passes through the given 2D coordinates. You can view the documentation for the command here.

Here is sample code that uses this command to place an object 5 meters away from the viewpoint at the current mouse position:
Code:
import viz
viz.go()

# Create a model
model = viz.add('ball.wrl')

def UpdateModel():
	
	# Get line that passes through current mouse position
	line = viz.MainWindow.screenToWorld(viz.mouse.getPosition())
	
	# Place model 5 meters away from current view
	model.setPosition(line.endFromDistance(5))
	
vizact.ontimer(0,UpdateModel)
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
how to do it using mouse nasr Vizard 0 05-12-2009 02:38 AM
multiple mouse clicks jaclyn.bill Vizard 2 06-03-2008 02:19 AM
Mouse problem steve Vizard 7 07-14-2005 03:01 PM
Draw Line between Points selected by mouse Johannes Vizard 7 01-07-2005 02:50 PM
Halting mouse view-transforms FlyingWren Vizard 1 10-01-2003 05:29 PM


All times are GMT -7. The time now is 12:24 AM.


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