# Would Someone Like to Double Check My Code On A Script I am thinking of releasing soon.

I was wondering if any one would be willing to double check some of the techniques and methods I am using in a Scripted Posing System I am thinking of releasing soon for free of course on ScriptSpot.

I hope the following is not too long.

My script is similar to Chugg Nut's anipose but has some pretty neat extra features. It will allow you to define the pose in the object space of any Other Object. Which allows you to get effects like a character walking forward or running forward etc. It also allows you to turn off or on position or rotation for a pose at any time Or define Whether you want the Script to read whether an Objects Heirachy Position or Rotation Locks are on or off. You can also exclude any Position axis from being calculated for a pose.

I have tested the script on several rigs including Luminox Puppet Shop, and Brad Nobles Great Rig, and it seems to work well. It works for any max object except character studio.

Anyway the Script is Pretty Much Done But during the development of it I had some trouble with the method I was using for the posing of the rotation. So I studied Chugg Nuts

Anipose Script Which is a great script and derived a new rotation method based on what I learned from his script.

Basically If I am analyzing it correctly chuggs script does the position and rotation posing all in one go by directly modifiying the rows of the objects transform matrixes.

At the time of getting the pose If an object has a parent its pose transform is derived by multiplying its transform by the inverse of its parents transform getting the local transform.

If it does not have a parent then we just get its transform. Then at the time of Posing when the slider is changed ( essentially slider button down )the current transform of the object is gotten using the same method that its transform was gotten when it's pose was gotten. Then its current transform is subtracted from its pose transform to get the distance between them. Then the pose is blended between the two by adding the distance between the transforms time the value of the slider to the current transform.

When I was developing my script this is the same method I used but I used the position and rotation directly rather than modifiying the transform directly. The Position worked fine but the rotation was having problems when I was using Euler Rotation values * the value of my dialogs pose spinner which goes from 0 - 1. So I decided to try Chuggs Method of rotating by modifying the transform directly. I still use Regular Position to derive the Position of the object since in my code it is necessary for the extra features I put in.

The final Rotation Method I came up with By studying Chuggs Script was the following.

**Transform get method** : : ( matrix3 ) ( Method Used to get the transform ) =

>> If the object has a parent the objects transform * the inverse of the objects parents transform

>> If the object has no parent just the objects transform

** Pose Transform** : : ( The Stored Target Pose gotten at time of setting the pose ) = Transform get method ( )

**Start Transform** : : ( Current Object Transform ) ( The Current Position of the object before the pose spinner is changed ) = Transform get method ( )

>> This is gotten on spinner button down

**Current Pose Distance** : : ( Current Distance Between Start Transform and Pose Transform )

**Spinner Value** : : ( float values between 0 and 1 )

---------------- SPINNER CHANGED VALUE

**FINAL Transform** of the object ( When Posed Using the spinner )( On Spinner Changed Value ) =

>> Start Transform + ( Current Pose Distance * Spinner Value )

EACH TIME THE SPINNER CHANGES VALUE -

As mentioned the positon is gotten by getting the positions from the transforms above directly and then performing the operations mentioned above directly on the positions.

After This the rotation is calculated using the following method.

The Position of the object after calculating it is stored in A variable. After The transform for the rotation is calculated we set the calculated transform to this position since we do not wish to

use the Position from the calculated transform because we already set it above.

Then the rows of the start transform are subtracted from the rows of the pose transform multiplied by the Spinner Value and then added to the rows of the start transform.

VARIABLES

CurrentTransNodePHP = The Current Object being posed

Tcalc = matrix3 1 for storing the calculated matrix

tstart = Start Transform

tend = Pose Transform

PHPPoseSpnVar = Spinner Value

NowPos = THE POSITION OF THE OBJECT BEFORE ROTATION

THE FINAL CODE FOR ROTATION IS THIS

---------------------------------------------------------------------------------------------------------------

If CurrentTransNodePHP.parent != undefined then

(

NowPos = ( CurrentTransNodePHP.transform * inverse CurrentTransNodePHP.parent.transform ).pos

)

Else

(

NowPos = CurrentTransNodePHP.transform.pos

)

Tcalc = matrix3 1

Tcalc.row1 = tstart.row1 + ( ( tend.row1 - tstart.row1 ) * PHPPoseSpnVar )

Tcalc.row2 = tstart.row2 + ( ( tend.row2 - tstart.row2 ) * PHPPoseSpnVar )

Tcalc.row3 = tstart.row3 + ( ( tend.row3 - tstart.row3 ) * PHPPoseSpnVar )

-- ROW 4 WOULD BE THE FOLLOWING BUT WE DO NOT USE IT -- For The Position We Use NowPos

-- Tcalc.row4 = tstart.row4 + ( ( tend.row4 - tstart.row4 ) * PHPPoseSpnVar ) -- For The Position We Use NowPos

Tcalc.pos = NowPos

Tcalc = orthogonalize Tcalc

---- THE TRANSFORM WE ASSIGN TO THE OBJECT TO ROTATE IT

If CurrentTransNodePHP.parent != undefined then

(

TheTransForRotBuild = ( Tcalc * CurrentTransNodePHP.parent.transform )

)

Else

(

TheTransForRotBuild = Tcalc

)

CurrentTransNodePHP.transform = TheTransForRotBuild

--------------------------------------------------------------------------------------------------------------------

-----------------

The orthogonalize part was what was most new to me. I understand now that it sets the transform perpendicular. Every thing else seems pretty straight forward.

Hope that wasn't to Long. Anyway the above code has worked fine and I am pretty confident that is correct. But I just wanted to see if anyone wanted to take a look at it just to make sure.

Thank you.

Matthew

## Comments

## I attached the script itself

I attached the script itself for those who would like to try it out. The Startup one must go in the startup folder and the macroscript ones in the UI macroscript folder.

## I just fixed a few issues

I just fixed a few issues with the script and replaced the attachment above with the fixed script. Not done testing it yet but getting there.

Matthew

[email protected]

http://s18.photobucket.com/albums/b117/dalek333/

http://www.freewebs.com/lamoreart/index.htm

http://www.scriptspot.com/3ds-max/joint-bend-rig