Tue, Nov 26, 11:31 PM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Rotate a figure around the centre of a foot


AndyCLon ( ) posted Wed, 11 July 2007 at 5:38 AM · edited Fri, 26 July 2024 at 2:16 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.

http://www.philc.net/forum/viewtopic.php?t=1298


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()


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.