WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-11-2009, 09:39 AM
Penguin Penguin is offline
Member
 
Join Date: Mar 2009
Posts: 14
rotating an object

Hi, I want to rotate an object (sphere) similar to the globe in google earth.

The sphere is mapped in front of the main view. With the use of the viz.pick() command I get the intersection position of the mouse pointer on the sphere (intersectionItem.point).

The following code is running in a mouse button down callback function. While dragging the mouse over the sphere the new intersection position is callculated (curIntersectionItem.point)

With this two points and the center of the sphere I get two direction vectors and the angle inbetween.

The rotation of the sphere seems to work until it rolls. Then the mouse movement does not match to the rotation of the sphere any more!

Is there a better way to achieve a stable rotation? While dragging in google earth the same part of the globe always stays under the mouse pointer.

Code:
curIntersectionItem = calcUiIntersection()
rotationMat = vizmat.Transform()
rotationMat.makeVecRotVec(vizmat.VectorToPoint(sphere.getPosition(viz.ABS_GLOBAL),intersectionItem.point),vizmat.VectorToPoint(sphere.getPosition(viz.ABS_GLOBAL),curIntersectionItem.point))

spherePos = sphere.getPosition(viz.ABS_GLOBAL)
sphereMat = sphere.getMatrix(viz.ABS_GLOBAL)
sphereMat.setTrans(0,0,0)

transformMat = vizmat.Transform()
transformMat = rotationMat * sphereMat

transformMat.setTrans(spherePos)
sphere.setMatrix(transformMat,viz.ABS_GLOBAL)

intersectionItem = curIntersectionItem
Reply With Quote
 


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
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
reseting an object durf Vizard 3 03-17-2009 11:48 PM
Object rotating around world axis, not own axis tacbob Vizard 1 02-15-2007 09:12 AM
Child Object Rotation paulgoldberg Vizard 5 09-05-2006 11:33 AM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM


All times are GMT -7. The time now is 07:15 AM.


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