PDA

View Full Version : Request for Double Check of code for New Posing System I am Creating


CGMATLAM
07-19-2009, 03:47 PM
Post Update Monday 7-20-09 - I just updated the attachment with some fixes that I just found. Fixed a problem with the indexing being off with custom coordinate objects when removing poses. Also fixed a problem with the only if parented to checkbox throwing the indexing off.

Feel free to try this out right now but I still have a few things to check before I will consider this production ready. So Please test it thoroughly before using it for anything serious.

Post Update Monday 7-20-09 5:30 pm

I think I fixed the custom coordinate problem for good. I replaced the attachment below with the updated fixed script.

If you like keep checking back as I will be posting updates as I test this out until hopefully it will be ready to be posted on Scripspot.com .
----------------------------------

Original post-

I accidentally posted this in the main 3dmax section but I really intended to post it here.

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 have included the actual 3DsMax Script In the attachment for any who would like to try it out.

To install put the startup one in the scripts startup folder and put the macro script ones in the UI macroscript folder. Start Max. Go to Customize User Interface. Category Pose Morpher v2 w direct open. Add it to your desired interface. There will be two macros one that allows you to size the Posing Dialog. The Other Opens it directly after you have defined an initial size. The name of the Script Pose Morpher is not set in stone yet.

 

To Use it Create a Pose collection first. Then select some objects that are in the pose you want and then press Add Pose. Each Pose Can Have different objects at different poses. If You select Use Custom Coordinate system you can choose an object who's coordinate space the pose will always be in. So if you Add a pose for a foot forward and put it in the coordinate system of the hips the foot will always move to that position in relation to the hips no matter where in world space the hips are enabeling you to do things like make a character walk or run forward etc.

I hope the following Explanation is not too long.

My script is similar to Chugg Nut's anipose ( http://www.chuggnut.com/ ) 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 ( times 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 as a point 3 and rotation converted to EulerAngles 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

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 )

 

-- the following is what row 4 would be but we use NowPos for the position instead
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 it is correct. But I just wanted to see if anyone wanted to take a look at it just to make sure.

Thank you.

 

Matthew

Home219104@yahoo.com
http://s18.photobucket.com/albums/b117/dalek333/
http://www.freewebs.com/lamoreart/index.htm
http://www.scriptspot.com/3ds-max/joint-bend-rig



To Use The Script

put the script named Pose_Morpher_Strtup_DISTR_READY_ALMOST- STAGE-2
in your 3dmax > Scripts > Startup folder

put the 2 scripts in the other folder That says Macroscript in your
3dmax > UI > macroscripts folder

labbejason
07-19-2009, 07:14 PM
Hey Matt,

Looks cool. There's a few stuff I noticed right off the bat.

- The UI needs more thought on its layout as it looks way too spaced out and confusing. Try to cramp it in more since it's no fun having to scroll so much.

- Refreshing the pose list is a problem right now (you have to reopen it if you opened a new scene). Should either have a refresh button in the UI or a callbacks to make it automatically refresh.

- Going to direct open for the first time does NOT directly open, but instead opens up the sizer dialog. If it's the first time it's been use, just make it have default settings, and if it's been used before, just save the latest state of the dialog to an ini or something so that doesn't happen every time max is restarted.

- The tool shouldn't be dependent on the hidden helpers' names. I noticed as soon as you changed their names, it couldn't reference them anymore. So let's say I used this tool on two separate scenes with the same character. If I wanted to merge the one scene to the other, and those helpers had the same name, it would mess up the tool. Maybe just stick with custom attributes or object properties?

CGMATLAM
07-20-2009, 12:57 AM
Thanks a lot for the input labbejason and taking the time to evaluate my script.

As you mentioned the UI is a little raw right now . I will definitely consider your suggestions about the user friendliness of the interface. I don't have much more time to devote to this since developing this script took me away from a major animation project I have been working on for the past year and a half and I really need to get back to actually animating the thing. So I will say most of the stuff you suggested I will work on over time and I may still release the script with these things in mind for future versions. I will at least mention this in the readme for the script so users know about this and that I will try to adress it in the future.

Specifically the thing about name dependant helper objects. I think what you are referring to specifically Is the scene 'Supreme Master' Point object. this is the only object which is actually name dependant in the script. All the other stuff is stored on this supreme master object in node tab attributes. I see what you are saying about merging objects that have another scene Suprem master object since the master must have the same name. I will look in to possible solutions.

Also about the direct open function. I defiitely see what you are saying but I think this might be a toss up. Some might want to be able to define the initial size of the dialog everytime on the first open of max and some might not. But then maybe if they have already decided how big they want the dialog to be they may want it to be that size and not need to change on each max open. I will definitely look in to the .ini file thing. I learned a lot of new stuff on this script and using .ini files will maybe be a next good thing try to add to my scripting repertoire. There is always also the possibility of storing stuff on the scene rootnode but I have always been uncomfortable with the idea of writing scripts that modify the rootnodes of users scenes.

As long as there are no major issues which the actual transforming specifically the rotation that I mentioned then I at least feel comfortable releasing the script for any who would like to use it.

Thank You.

Matthew

Home219104@yahoo.com (http://forums.cgsociety.org/Home219104@yahoo.com)
http://s18.photobucket.com/albums/b117/dalek333/
http://www.freewebs.com/lamoreart/index.htm
http://www.scriptspot.com/3ds-max/joint-bend-rig

CGMATLAM
07-20-2009, 11:39 AM
Post Update Monday 7-20-09 - I just updated the attachment with some fixes that I just found. Fixed a problem with the indexing being off with custom coordinate objects when removing poses. Also fixed a problem with the only if parented to checkbox throwing the indexing off.


See the original post for the updated file.



Feel free to try this out right now but I still have a few things to check before I will consider this production ready. So Please test it thoroughly before using it for anything serious.
Matthew

Home219104@yahoo.com
http://s18.photobucket.com/albums/b117/dalek333/
http://www.freewebs.com/lamoreart/index.htm
http://www.scriptspot.com/3ds-max/joint-bend-rig

CGMATLAM
07-20-2009, 06:06 PM
Just encountered a bit of a problem with the custom coordinate feature. Got some weird rotations. It works in some situations but seems to have trouble in others. This is a feature that is to powerful for me to give up on so I wll have to see if I can come up with any solutions. I will try to post a quick overview of the functioning of the custom coordinate feature and the problem I encountered for any who would like to have a go at trying to figure out what the problem might be.

Matthew

Home219104@yahoo.com
http://s18.photobucket.com/albums/b117/dalek333/
http://www.freewebs.com/lamoreart/index.htm
http://www.scriptspot.com/3ds-max/joint-bend-rig

CGMATLAM
07-20-2009, 10:21 PM
Well I think I fixed the Custom Coordinate Problem thing for good hopefully. Looks like everything is working well.

I posted the fixed script in the attachment of the original first post of this thread.

It was one of those problems that is obvious once you find it but is a nightmare to actually find.

The Pose Was being gotten in the Coordinate space of the Custom coordinate object but the rotation wasn't being posed in the Coordinate space of the Custom coordinate object. In the future I have to be sure I am always setting transforms in the same coordinate space I am getting them.

So Now if you choose the coordinate space for a pose it should always be in the same relationship to that object as it was at time of setting pose. So Say set the coordinate space of a pose for a Left foot stepping forward in the coordinate space of the right foot will enable a character to walk forward.

Still a bunch of testing to do but things are looking promising.

Matthew

Home219104@yahoo.com
http://s18.photobucket.com/albums/b117/dalek333/
http://www.freewebs.com/lamoreart/index.htm
http://www.scriptspot.com/3ds-max/joint-bend-rig

fajar
07-21-2009, 07:22 PM
Well I just don't understand how to running this script, I runnig it using 3dsMax 9 (is it support for your script) the way I running it using "run maxscript method" (which is ussualy I use) and execute the .ms file (not .mcr file) , can you explain why!!


Thank!

CGMATLAM
07-23-2009, 02:45 AM
To install The Script

put the script named Pose_Morpher_Strtup_DISTR_READY_ALMOST- STAGE-2
in your 3dmax > Scripts > Startup folder

put the 2 scripts in the other folder That says Macroscript in your
3dmax > UI > macroscripts folder

Then Start Max or Restart it if it is open.

I just updated the attachment in the original pose with a bunch of improvements so if you like get the latest one. There is still testing to do on the script but If you check back over the next couple of weeks I should be posting the final version here and on ScriptSpot.com with some demo vids and tutorials.

If you look in the text of the startup script it has some instructions on how to use the features of the script. Also some of the buttons have tooltips if you hold the mouse over them.

The biggest feature is the ability to pose objects in the coordinate space of any other object enabling you to make a character run or walk forward etc. However this feature should only be used for objects on a rig that are parented to the world or the world node of a rig. I will be providing a fuller explanation in the readme of the script when it is finished.


Matthew

Home219104@yahoo.com
http://s18.photobucket.com/albums/b117/dalek333/
http://www.freewebs.com/lamoreart/index.htm
http://www.scriptspot.com/3ds-max/joint-bend-rig

CGTalk Moderation
07-23-2009, 02:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.