WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-12-2009, 01:09 PM
Penguin Penguin is offline
Member
 
Join Date: Mar 2009
Posts: 14
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
import vizmat
import vizshape

viz.go()
viz.mouse.setOverride(viz.ON)

root = viz.add(viz.GROUP, parent=viz.WORLD)
root.setPosition([0,1.8,3],viz.REL_GLOBAL)

node = vizshape.addSphere(pos=[0,0,0], parent=root)
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)
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 12:08 AM.


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