View Single Post
  #2  
Old 05-12-2005, 04:14 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Even though you didn't explicitly say anything about it, I'm assuming you are trying to apply an offset rotation to the racket?

There are many ways to go about this.

1) As you already mentioned, you could rotate the model in 3ds max. This would probably be the easiest solution.

2) Manually apply the rotation in a timer and apply the offset with it. It seems like this is what you are already trying to do. Try the following code instead:
Code:
def mytimer(num):
    ori = racketOri.get()
    racket.rotate(ori[3],ori[4],ori[5])
    racket.rotate(offset[0],offset[1],offset[2],viz.RELATIVE_LOCAL)
This will perform exactly what the link command does, but afterwards it applies an offset rotation.

3) You could use a transform hierarchy to offset the racket automatically. Here is some sample code:
Code:
racket = viz.add(viz.GROUP)
racketModel = racket.add('racket3.wrl')
racketModel.rotate(offset[0],offset[1],offset[2])
racket.link(racketOri)
This will place the racket model underneath a hierarchy. The offset rotation will be applied to the racket model and the intersense will be linked to the parent transform, which is the GROUP node.

4) Reset the intersense in your offset rotation. Hold the physical racket in the neutral position and apply a reset command to the racketOri. After this point the intersense plugin will automatically apply an offset to the rotation. I noticed that you are using a different intersense plugin named intersense2.dls. If it is an older version of the plugin, then this method might not work. Anyway, to use this method you would use the following code:
Code:
racketOri = viz.add('intersense.dls')
racketOri.command(8) #Tell the intersense to use quaternion rotations instead of eulers
racketOri.command(9) #Tell the intersense to apply offset rotation
Now, whenever you want to reset the racket to its neutral rotation you would issue the following command:
Code:
racketOri.reset()
Let me know if any of these methods don't work
Reply With Quote