Mon, Nov 25, 12:59 AM 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: Getting "PointAt" angles via python....


konan ( ) posted Sat, 15 January 2005 at 4:55 PM ยท edited Mon, 25 November 2024 at 12:59 AM

Is it possible, using python, to "bake in" the angles of a particular actor that is set to "point at" another object? For example, if I have the head of a figure pointing at a prop, and I delete the prop, the head resets back to normal. I would like to have the temporary angles generated by the "point at" thingy transfered to the actor. Any advice you can provide would be appreciated, Konan


ockham ( ) posted Sun, 16 January 2005 at 11:46 AM

I think Bushi may have a good answer for this. In the meantime, here's my 2 cents... The regular joint angles for a point-at are just as wrong in Python as in the normal Poser world. But Python can read an internal measurement (quaternion) that does seem to reflect the point-target movement. So it's certainly possible to record the point-at moves. Putting them back is the problem. At one time I had a formula for turning quaternions into joint rotations; have to see if I can find that again.

My python page
My ShareCG freebies


ockham ( ) posted Sun, 16 January 2005 at 12:38 PM

Found a good formula, which is just about working. More later... (The web has more good 3d stuff now than it did when I was pursuing this subject earlier.)

My python page
My ShareCG freebies


ockham ( ) posted Sun, 16 January 2005 at 2:31 PM

Attached Link: http://ockhamsbungalow.com/PPP/PointAt1.zip

Here's a first try. I think some angles may have quadrant problems, because of the use of arcsin and arctan. Give it a run and see what's wrong.........

My python page
My ShareCG freebies


konan ( ) posted Sun, 16 January 2005 at 8:40 PM

I just ran it and it is great. You are right, there is an issue with the quadrants. I had he right shoulder pointing at a prop, and made it bend 90 to the front, and iwhen I ran the script, it was pointing backwards instead of forwards. I'll take a look at the math and see if I can figure it out. I'm sure it'll be easy to fix. Dude, you're awesome. Thank you so much for your help! Konan


konan ( ) posted Sun, 16 January 2005 at 8:51 PM

The Martin Baker code found at http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/ specifies the following... "This depends on what conventions are used for the Euler Angles. The following assumes the standards here... Euler angles Heading = rotation about y axis Attitude = rotation about z axis Bank = rotation about x axis Euler angle order Heading applied first Attitude applied second Bank applied last" i.e. YZX rotational order. So I guess that we need to determine the rotation order for each actor, and adjust the calculation accordingly. Do you agree? Konan


konan ( ) posted Mon, 17 January 2005 at 8:59 AM ยท edited Mon, 17 January 2005 at 9:03 AM

I have played around with this a bit, and ran into a few issues. Using the "world quaternion" seems to be problematic since we should be using the local rotations, however, the LocalQuaternion method does not appear to include the PointAt angles.

I believe that it may be best manually calculate the point at angles. I cannot seem to find a "GetPointAt" method, to retrieve the object at which the object is point at, so it may be necessary to establish a naming convention for the objects.

e.g. The "Head" points at the "PointAt_Head" prop.

Then the math would go something like this...

Let P be the parent world matrix.
Let v be the position of the PointAt object.

Therefore, in the head's local coordinate system, the position of the PointAt object is v' where

v' = (P^-1) v // inverse of P times v

Since the position of the head is {0,0,0} in it's own local space, then the direction to point at is simply the unit vector for v'.

From this direction vector, we can then calculate the euler angles, making sure to consider the rotation order.

Anyway, I'll give it a try when I get a moment. Anyone, please give me your opinion if you can think of a better way, or is you see an error in my logic (above).

Konan

Message edited on: 01/17/2005 09:03


ockham ( ) posted Mon, 17 January 2005 at 12:22 PM

Maybe the best approach is to go completely external. Use the script to set up a point-at-like relationship without touching Poser's own point-at. This wouldn't give the same moves as the internal, but it would give a completely reproducible set of moves with no mystery! It would also make some needed variations possible, like pointing a head toward its front instead of toward its top.

My python page
My ShareCG freebies


konan ( ) posted Mon, 17 January 2005 at 3:32 PM

That sounds like a good idea. The math that I posted above should be suitable for that purpose. The main thing to remember when calculating the Euler angles, is that they depend on the order of rotation for the actor in question. In general, there are 9 different combinations, however, the standard Poser 3/4/5 characters probably only use 2 or 3 (just guessing).

e.g.

for XYZ rotations...

R = RzRyRx (or the opposite, can't remember off the top of my head)

for ZXY rotations...

R = RyRxRz

Then extract the angles ax, ay and az from the appropiate rotation matrix R.

It would also be extremely useful to track the "twist" parameter of the object that it is point at. So you can move the prop to point the body part towards it, and you can twist the prop to make the body part twist. Konan (Creator of Blacksmith3D)

Blacksmith3D_Signature.jpg

Blacksmith3D - Morph - Paint - Suite
Reshape Objects Easily. Paint textures in true 3D.
Import/Export Poser CR2 or OBJ files.
New version available (December 3, 2004)
http://www.blacksmith3d.com


tromnek ( ) posted Thu, 20 January 2005 at 8:12 PM

Konan, any chance of getting a glimpse at your python code?
I wanted to get 'point at' angles for a script I have for making eye adjustments. I gave up when I hit the quadrant problems. In truth I didn't really understand the transformations needed. The web link you gave is a great help, some python code would really bring it together.

tia,
ken


konan ( ) posted Fri, 21 January 2005 at 11:36 AM

I don't have any python code to give at this point. The code given by Ockham above is all I have.

The alternative "point at" routine above that we discussed would be a great idea. In this way, we could deal directly with the native poser angles and not these quaternion things.

If you need any help with the rotation matrices, I may be able to lend a hand. I'm OK with the math end of things.

Konan (Creator of Blacksmith3D)

Blacksmith3D_Signature.jpg

Blacksmith3D - Morph - Paint - Suite
Reshape Objects Easily. Paint textures in true 3D.
Import/Export Poser CR2 or OBJ files.
New version available (December 3, 2004)
http://www.blacksmith3d.com


tromnek ( ) posted Fri, 21 January 2005 at 4:56 PM

Thanks, I'll call you when I can get back to that project.

Another thing I'd like to do is 'auto' adjust foot angles so that poses made for one shoe type will adjust to the the current shoe type. I think I'm going to need to understand the stuff in this thread better in order to calculate a set of solutions.


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.