AndyCLon opened this issue on Jul 11, 2007 · 8 posts
AndyCLon posted Wed, 11 July 2007 at 5:38 AM
I wish to rotate figure around the centre of their left foot rather than the centre of the hip. I appreciate that this can't be done easily through the user interface, my attempt looks like moon walking
http://uk.youtube.com/watch?v=huE0MRP6W-k
Would I be correct in thinking that this is possible via script. Has anyone already done this? I've found the maths but as I've never used python in poser before I'm not too sure where to start.
http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
Is the object model documented somewhere? Are there turtorials?
PhilC posted Wed, 11 July 2007 at 5:43 AM
One method you may try is:-
Load the sphere prop.
Position it where you want the rotation point to be.
Parent the figure to the prop.
Rotate the prop.
Set the prop invisible prior to render.
Does that help any?
PhilC posted Wed, 11 July 2007 at 5:47 AM
I've just looked over that maths page .......
.............. I'm now going to go lie down in a nice quiet dark room untill my head stops spinning :)
AndyCLon posted Wed, 11 July 2007 at 5:48 AM
Now that idea I like, it's simple and I've used similar techniques in other tools, I'm slightly worried that the parenting will cause problems for the other bits of the animation though. Will give it a try later.
PhilC posted Wed, 11 July 2007 at 5:55 AM
Failing that, dont parent but use the sphere to realign the figure as it rotates. Then delete the sphere. This tutorial may help also.
AndyCLon posted Wed, 25 July 2007 at 12:51 PM
I've produced the following script but I'm not sure why it's not working as expected. My variables f2x and f2z always appear to be reporting as zero. Am I missing something? Is there an alternative way of getting the x and z co-ordinates?
<pre style="border:1px solid #000000;margin:2mm;padding:2mm;color:#000000;background-color:#f0f0f0;">
import poser
scene = poser.Scene()
fig = scene.CurrentFigure()
hip = fig.Actor("Hip")
foot = fig.Actor("Right Foot")
f1x = foot.ParameterByCode(poser.kParmCodeXTRAN).Value()
f1z = foot.ParameterByCode(poser.kParmCodeZTRAN).Value()
print f1x
print f1z
yrot = hip.ParameterByCode(poser.kParmCodeYROT).Value()
#Preserve IK settings (not sure how this works on models without IK)
ikl = fig.IkStatus(fig.IkNames().index('LeftLeg'))
ikr = fig.IkStatus(fig.IkNames().index('RightLeg'))
# Turn off
fig.SetIkStatus(fig.IkNames().index('LeftLeg'),0)
fig.SetIkStatus(fig.IkNames().index('RightLeg'),0)
# Rotate figure around hip
hip.ParameterByCode(poser.kParmCodeYROT).SetValue(yrot + 15)
# Move hip so that foot is back where it was
f2x = foot.ParameterByCode(poser.kParmCodeXTRAN).Value()
f2z = foot.ParameterByCode(poser.kParmCodeZTRAN).Value()
print f2x
print f2z
hx = hip.ParameterByCode(poser.kParmCodeXTRAN).Value()
hz = hip.ParameterByCode(poser.kParmCodeZTRAN).Value()
print hx
print hz
print hx+f2x-f1x
print hz+f2z-f1z
hip.ParameterByCode(poser.kParmCodeXTRAN).SetValue(hx+f2x-f1x)
hip.ParameterByCode(poser.kParmCodeZTRAN).SetValue(hz+f2z-f1z)
f2x = foot.ParameterByCode(poser.kParmCodeXTRAN).Value()
f2z = foot.ParameterByCode(poser.kParmCodeZTRAN).Value()
print f2x
print f2z
# Turn back on IK settings
fig.SetIkStatus(fig.IkNames().index('LeftLeg'),ikl)
fig.SetIkStatus(fig.IkNames().index('RightLeg'),ikr)
nruddock posted Wed, 25 July 2007 at 2:13 PM
Quote - I've produced the following script but I'm not sure why it's not working as expected. My variables f2x and f2z always appear to be reporting as zero. Am I missing something? Is there an alternative way of getting the x and z co-ordinates?
The translation parameters are relative to the joint origin.
I fairly certain that you need to be using actor.WorldDisplacement()
The problem then is how to calculate the correct values to apply to the translation parameters for any given actor, which I think you can do by using the inverse of actor.WorldMatrix()
AndyCLon posted Wed, 25 July 2007 at 4:13 PM
Ah ha. I think I've got it working now. The redrawing was also puzzling me but I've got that too.
<pre style="border:1px solid #000000;margin:2mm;padding:2mm;color:#000000;background-color:#f0f0f0;">
import poser
scene = poser.Scene()
fig = scene.CurrentFigure()
hip = fig.Actor("Hip")
foot = fig.Actor("Right Foot")
a = 15.0
f1 = foot.WorldDisplacement()
h = hip.WorldDisplacement()
yrot = hip.ParameterByCode(poser.kParmCodeYROT).Value()
#Preserve IK settings (not sure how this works on models without IK)
ikl = fig.IkStatus(fig.IkNames().index('LeftLeg'))
ikr = fig.IkStatus(fig.IkNames().index('RightLeg'))
# Turn off IK
fig.SetIkStatus(fig.IkNames().index('LeftLeg'),0)
fig.SetIkStatus(fig.IkNames().index('RightLeg'),0)
# Rotate figure around hip
hip.ParameterByCode(poser.kParmCodeYROT).SetValue(yrot + a)
# Move hip so that foot is back where it was
f2 = foot.WorldDisplacement()
hip.ParameterByCode(poser.kParmCodeXTRAN).SetValue(h[0]+f1[0]-f2[0])
hip.ParameterByCode(poser.kParmCodeZTRAN).SetValue(h[2]+f1[2]-f2[2])
# Turn back on IK settings
fig.SetIkStatus(fig.IkNames().index('LeftLeg'),ikl)
fig.SetIkStatus(fig.IkNames().index('RightLeg'),ikr)
# Refresh the screen
scene.Draw()