View Single Post
  #4  
Old 05-06-2009, 10:37 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Ok, it sounds like you want a hierarchical relationship between object1 and object2. In this case you would simply add object1 as a child to object2. When object2 is rotated, object1 will automatically rotate in object2's reference frame. If for some reason you don't want a to use a hierarchical relationship, then here is some code to manually compute the matrix:
Code:
euler = viz.Matrix.euler(0,0,roll)
m1 = object1.getMatrix()
m2 = object2.getMatrix()
	
diff = m1 * m2.inverse()
	
m2new = euler * m2
object2.setQuat(m2new.getQuat())
object1.setMatrix(diff * m2new)
Reply With Quote