![]() |
|
#2
|
|||
|
|||
|
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
import vizmat
import vizshape
viz.go()
viz.mouse.setOverride(viz.ON)
node = vizshape.addSphere(pos=[0, 1.8, 3])
node.texture(viz.add('image2.jpg'))
rotation = None
def onGrab():
global rotation
intersectionItem = viz.pick(1)
if intersectionItem.valid:
src_ori = vizmat.Quat(node.getQuat(viz.ABS_GLOBAL))
node.lookat(intersectionItem.point, viz.ABS_GLOBAL)
dst_ori = vizmat.Quat(node.getQuat(viz.ABS_GLOBAL))
#D = O * S so O = D * 1/S
rotation = src_ori * dst_ori.inverse()
vizact.onmousedown(viz.MOUSEBUTTON_LEFT, onGrab)
def moveSphere():
if rotation:
intersectionItem = viz.pick(1)
if intersectionItem.valid:
node.lookat(intersectionItem.point)
node.setQuat(rotation, viz.ABS_LOCAL)
vizact.onupdate(viz.PRIORITY_DEFAULT, moveSphere)
def endGrab():
global rotation
rotation = None
vizact.onmouseup(viz.MOUSEBUTTON_LEFT, endGrab)
__________________
Paul Elliott WorldViz LLC |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| retrieve Object names | Geoffrey | Vizard | 11 | 12-11-2009 05:26 AM |
| reseting an object | durf | Vizard | 3 | 03-18-2009 12:48 AM |
| Object rotating around world axis, not own axis | tacbob | Vizard | 1 | 02-15-2007 10:12 AM |
| Child Object Rotation | paulgoldberg | Vizard | 5 | 09-05-2006 12:33 PM |
| rotate to object | jargon | Vizard | 1 | 08-08-2005 01:20 PM |