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