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() |
Interesting goal. I whipped up a bit of code that orbits the sphere by telling the sphere to "lookat" the intersection point, then rotating the sphere the initial offset amount.
The code is not quite right yet because sustained clicking on the same point rolls the sphere around that point. Maybe somebody knows whats wrong? Code:
import viz |
Except for the slight roll, your code works fine. But here it comes: when I attach the sphere to the main view the rotation doesn't work any longer.
Code:
import viz |
Righto. The link is overriding the rotation we are giving the sphere. To fix we tell the link to only operate on position
Code:
viewLink = viz.link(viz.MainView,node, mask=viz.LINK_POS) |
Step by step I'm able to locate the source of the problem: I use the sphere in a hierarchical group order. The following code reproduces the strange behaviour of rotating.
Code:
import viz |
Here's another way to do it.
Code:
|
Interesting... I shall dub thee Spinner Metaphor Method and place you in a file of honor.
|
Hi Gladsomebeast, the effect of slight roll results in the lookat call. The second argument is a optional roll value. The internal value of viz.ABS_GLOBAL is 4:
Code:
node.lookat(intersectionItem.point, 0, viz.ABS_GLOBAL) Code:
node.lookat(intersectionItem.point,viz.ABS_GLOBAL) Code:
node.lookat(intersectionItem.point,4) |
Of course, of course, the roll parameter =) Thanks for sharing the fix.
|
Since spinning balls is so much fun,
Let's try spinning more than one. Code:
from viz import * Or if you like the number three, Let's try to make them all agree. Code:
from viz import * And here's the one you want the most, Just like iPhone make it coast. Code:
from viz import * |
Spinning is fun
I do agree. But rotations be done, I'm going crazy. |
All times are GMT -7. The time now is 01:57 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC