Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 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
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
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
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
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
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
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
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 - 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
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
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 - 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
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.
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.
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