Official Release - mcjMechAnim - D|S1,2,3,4 Script to Animate Arms and Piston mechanisms

mCasualmCasual Posts: 4,607
edited December 2014 in Freebies

Manual and download here :

https://sites.google.com/site/mcasualsdazscripts5/mcjmechanim

-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-
History
-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=-
Dec 6 - Rush release, the ds1/ds2 version was not dunctional
Dec 7 improved robustness and implemented DS1/DS2 compatibility, completed the manual

example: you animate the master wheel,
select some of the mechanical components
ex:
the push-rod is parented to the master wheel
you select
the piston end node : a null node parented to the extremity of the piston
the push-rod end node : a null node parented to the extremity of the push-rod

before using the script, the push-rod
swings wildly around the master wheel

after using the script
for each frame of the animation,
the script rotated the push-rod precisely as needed
so that the end of the push-rod meets the line of action of the piston
and it moved the piston
precisely as needed so that the end of the push-rod
meets the origin of the piston

manivelle2.gif
600 x 450 - 808K
twainee.gif
480 x 270 - 985K
Post edited by mCasual on
«1

Comments

  • mCasualmCasual Posts: 4,607
    edited September 2014

    the source code for now

    the final version will adapt to other configurations

    mcjKeepOrientation
    was used to keep the rod connecting the 3 wheels horizontal
    that connecting rod is parented to the master wheel

    mcjKeepOrientation was also used to keep the piston horizontal
    the piston is parented to the push-rod

    the push-rod is parented to the master wheel

    before running this script i selected
    1 - the push-Rod
    2 - the piston
    3 - the cylinder

    the slave wheels copy the master wheel rotation
    i locked their translations then copy-pasted the master wheel X rotation

    
    tick = Scene.getTimeStep();
    pushrod = Scene.getSelectedNode( 0 );
    piston = Scene.getSelectedNode( 1 );
    cylinder = Scene.getSelectedNode( 2 );
    pistonPos = piston.getWSPos( 0 );
    pushrodPos = pushrod.getWSPos( 0 );
    pushrodLen = pistonPos.subtract( pushrodPos ).length();
    vz = DzVec3( 0, 0, 1 );
    for( fr = 0; fr < 31; fr++ )
    {
     t = fr * tick;
     pushrodPos = pushrod.getWSPos( t );
     pushrodPos.x = 0
     cylinderPos = cylinder.getWSPos( t );
     cylinderPos.x = 0
     cylinderAxis = cylinder.getWSRot( t ).getZAxis();
     pushrodAxis = pushrodPos.subtract( cylinderPos );
     hyp = pushrodAxis.length();
     v = pushrodAxis.cross( cylinderAxis );
     opp = v.x;
     cosang = opp / pushrodLen
     ang = Math.acos( cosang );
     if( fr == 0 )
     {
      zeroang = ang;
     }
     else
     {
      ang = ang - zeroang;
      v = new DzVec3( 0, Math.sin( ang ), Math.cos( ang ) )
      r = vz.getRotationTo( v )
      pushrod.setWSRot( t, r );
     }
    }
    
    allaboard.jpg
    1920 x 1080 - 929K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 1969

    Amy inspecting a Sterling engine ( hot/cold air based )

    hotair.jpg
    1920 x 1080 - 554K
  • RuphussRuphuss Posts: 2,631
    edited December 1969

    hi casual
    I have win 7 IE11
    and I cant see the animations of your gifs in browser
    but when I download with irfanview I can
    should they work in browser ?

  • mCasualmCasual Posts: 4,607
    edited September 2014

    ruphuss said:
    hi casual
    I have win 7 IE11
    and I cant see the animations of your gifs in browser
    but when I download with irfanview I can
    should they work in browser ?

    in win7 google-chrome, the animations are running when i open this page
    and if i click the animated gifs, they pop-up in a separate window and are animated there too

    i have ... lets see ... IE11 too and ....

    the 2 animated gifs at the top of the page work

    so .. mmmmmmmaybe there's a setting in IE to block animated gifs?

    sterling.jpg
    707 x 1000 - 128K
    animz.jpg
    413 x 533 - 73K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited September 2014

    the displacer mechanism of a Sterling engine

    note that this design is absolutely not guaranteed to work in real life
    but it's the general configuration for a Sterling engine

    the displacer pushrod will be parented to the flyWheel
    the displacer will be parented to the displacer pushrod
    the script will keep the displacer sliding up and down along the Y Axis of the displacerGuide

    this is achieved by rotating the displacer pushrod and the displacer around their respective X Axis

    ===================

    Figure 2 , your sole task is to animate the wheel rotation

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

    Figure 3, there ya go i was able to make it work for Y-Axis piston action

    i just have to make it work for any configuration, including , in movement !, for example, a train climbing hills, and following curvy paths

    ster2done.gif
    480 x 640 - 783K
    ster2.gif
    320 x 180 - 93K
    dsplacer.jpg
    1030 x 960 - 60K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited September 2014

    4 important states of a Sterling engine

    motordemo0005.jpg
    1280 x 720 - 123K
    principle.jpg
    954 x 1080 - 100K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 1969

    demonstration video oh yay

    https://www.youtube.com/watch?v=FhgCemjxEjA

  • mCasualmCasual Posts: 4,607
    edited September 2014

    i'm not sure the script will be able to solve a complex mechanism like that but , that's the experimental setup

    75.jpg
    960 x 960 - 182K
    sleevezmech.jpg
    960 x 960 - 322K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited September 2014

    the script will probably be called mcjArticulate

    and is probably best described as a planar mechanism solver

    =========

    figure 2 - it can also be seen as a case of two coupled wheels

    fig 3 it boils down to a triangle

    fig4 2 solutions satisfy the constraints so we must chose the nearest from the previous frame pose

    piston.gif
    1000 x 830 - 130K
    sleech2.jpg
    960 x 960 - 107K
    sleevech2.jpg
    960 x 960 - 103K
    sleevezmech2.jpg
    960 x 960 - 307K
    slide1.jpg
    1280 x 720 - 145K
    Post edited by mCasual on
  • RuphussRuphuss Posts: 2,631
    edited September 2014

    looks like it will be a lot of fun
    can we get some of the props with it ?

    there comes a related idea to mind
    can you tell how quick a person moves (translation ) from the movement of the feet ?
    to prevent it from sliding

    you have so many scripts
    perhaps its already existing

    Post edited by Ruphuss on
  • mCasualmCasual Posts: 4,607
    edited September 2014

    ruphuss said:
    looks like it will be a lot of fun
    can we get some of the props with it ?

    there comes a related idea to mind
    can you tell how quick a person moves (translation ) from the movement of the feet ?
    to prevent it from sliding

    you have so many scripts
    perhaps its already existing

    yes i'll probably post the machines as free props

    note that the last test setup is made mostly using the very morphable props
    https://sites.google.com/site/mcasualsdazscripts3/mcjlinks
    https://sites.google.com/site/mcasualsdazscripts3/mcjroundrods
    there's also
    https://sites.google.com/site/mcasualsdazscripts3/mcjovalrods
    https://sites.google.com/site/mcasualsdazscripts3/mcjovals

    about walks
    you can look into
    https://sites.google.com/site/mcasualsdazscripts3/mcjtoebasedfootpose
    https://sites.google.com/site/mcasualsdazscripts3/mcjtoewalker

    my main animation tool for walks and dances is
    https://sites.google.com/site/mcasualsdazscripts3/mcjautolimb2014
    along with
    https://sites.google.com/site/mcasualsdazscripts/mcjmaketarget
    https://sites.google.com/site/mcasualsdazscripts/mcjkeeporient

    91.jpg
    1920 x 1080 - 447K
    130.jpg
    1920 x 1080 - 291K
    connect.jpg
    960 x 960 - 219K
    linkspromo.jpg
    1280 x 720 - 161K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 1969

    there will possibly be 2 scripts

    this one where the hinge position is the ending constraint

    and one for piston+cylinder where the constraint is the piston's travel axis

    allsetup.jpg
    1392 x 768 - 173K
  • mCasualmCasual Posts: 4,607
    edited October 2014

    it works i just have to make sure it works for any axis configuration

    for example, the FreeRod ( which is in fact attached to the wheel ) uses YRotation to solve the arm position
    the FollowRod ( which is anchored to the floor hinge ) also uses the YRotation

    but using other props will yield other axis

    solutionne.gif
    512 x 288 - 363K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited October 2014

    actually i didn't expect the script to pass this acid-test

    the whole mechanisms swings and the script doesn't get confused


    In the second test i animated a node along a circular trajectory

    the FreeRod is the Shoulder, the FollowRod is the foreArm and the Hinge is the null node

    the flat segment of the resulting trajectory is due to the fact that the target node was out of reach
    in fact i had to delete those keyframes because the script was spitting out a few nan ( not a number )
    i'll fix that and the script will be able to handle the impossible :)

    armtest.gif
    768 x 464 - 673K
    thistest.gif
    640 x 360 - 728K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited October 2014

    so there will be a function to solve an arm type of linkage : shoulder / foreArm / hand
    and there will be one for a piston type of linkage : pushRod / piston / cylinder

    fig 2. eventually this will be on my site as morphing props

    laloup.jpg
    800 x 450 - 121K
    theananas.gif
    480 x 270 - 368K
    mecparts.jpg
    1920 x 1080 - 606K
    sonmecasoi.jpg
    1920 x 1080 - 327K
    stirling.jpg
    2000 x 2000 - 392K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited October 2014

    this should be useful, next , adjustable lengths

    herownprivateidaho.jpg
    1920 x 1080 - 643K
    inthenav.jpg
    1920 x 1080 - 665K
    inthenavyinthenavy.jpg
    1920 x 1080 - 597K
    inthenavy.jpg
    1920 x 1080 - 650K
    laloup2.jpg
    800 x 450 - 95K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited October 2014

    pretty good song right there https://www.youtube.com/watch?v=1ny4XvhoMMc

    figure 2 - the L-Shaped morphable props ... coming soon ( which is way before never )

    getoffthepathdaddy-o.jpg
    1920 x 1080 - 781K
    getoffthepatio.jpg
    1920 x 1080 - 695K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited November 2014

    now that i made a mountain of mechanical props, work can resume on the machine animator!

    solving is done using trigonometry, not simulations

    itsfriday.jpg
    1920 x 1080 - 1M
    xpatest.jpg
    1920 x 1080 - 494K
    theheatisoff.jpg
    1920 x 1080 - 1M
    displacer.jpg
    1920 x 1080 - 1M
    firetotherain.jpg
    1920 x 1080 - 815K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited November 2014

    getting closer to the ready-to-animate build

    the problem with the 1816 Stirling engine is that everyone ( and that's not a lot of people ) only show it in plan view

    Fig 2 - yes one of the arms in fig 1 would break, but in fig 2 it wont

    Fig 5 - so this was done in 4 script runs - the tedious part is positioning and parenting the "end" nodes

    ( using mcjMakeTarget and mcjParent ) )

    the piston-action was "simulated" using mcjKeepOrient

    spinnit2.gif
    480 x 270 - 409K
    weelofortunn.gif
    480 x 270 - 750K
    gnor.png
    1920 x 1080 - 511K
    betterdatway.jpg
    1920 x 1080 - 1M
    itsfriday_for_real.jpg
    1920 x 1080 - 1M
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 1969

    almost there !

    spinnit3.gif
    640 x 360 - 1M
  • mCasualmCasual Posts: 4,607
    edited November 2014

    the movie !
    https://www.youtube.com/watch?v=QEwpUlsqDGI

    so, the script may end up being named mcjMechAnim or mcjArticulate and/or mcjPiston

    or fancier would be

    mcjMechAnim.arms

    and

    mcjMechAnim.pistons

    gnorab.jpg
    1920 x 1080 - 634K
    chaichaichain.jpg
    1178 x 612 - 386K
    pistonsolve.jpg
    1920 x 1080 - 589K
    gnora.png
    1920 x 1080 - 2M
    Post edited by mCasual on
  • LycanthropeXLycanthropeX Posts: 2,287
    edited December 1969

    will there be a Poser version?

  • mCasualmCasual Posts: 4,607
    edited December 1969

    will there be a Poser version?

    probably not in the near future , but when i'll try my hand at poser scripting, i may start with this one

    i did some python programming for the DazStudio-to-Blender scripts and Poser uses Python too

  • LycanthropeXLycanthropeX Posts: 2,287
    edited December 1969

    Casual said:
    will there be a Poser version?

    probably not in the near future , but when i'll try my hand at poser scripting, i may start with this one

    i did some python programming for the DazStudio-to-Blender scripts and Poser uses Python too

    a Poser version would be awesome, so i will beg and drool

  • mCasualmCasual Posts: 4,607
    edited December 2014

    mcjMechAnim ( name was chosen )

    will have at least 4 tabs

    1 - a solver for 2 planar-rotation rods and a joint

    2 - a solver for a push-rod and a piston

    3 - a solver where you chose the endpoints of 2 rods
    the script will keep rodA pointing at rodB's origin

    4 - a utility that creates a null-node at the center of a circle
    this circle is computed based on 3 points
    the 3 points are the positions of a node of your choice at the
    beginning, midpoint and endpoint of the animation playrange

    Fig. 1 shows an example of tab 4, i needed to find the center of rotation for a rod
    and tab 3 will be used to keep that rod oriented correctly
    the length of the rod is fixed and adjusted "manually" by me

    ---

    i'll probably "force" you to supply a primitive plane which tells the script
    the rotation plane for your machine, because that's what is is, a solver for planar mechanisms

    if your machine is aboard a train, that plane must be aboard too !

    depz.jpg
    800 x 800 - 395K
    deplanz5.jpg
    1920 x 1080 - 1M
    smokinn.gif
    400 x 400 - 548K
    bluedress3.jpg
    1920 x 1080 - 939K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 2014

    the "joint solver"
    basically finds the intersection of 2 circles
    after having projected the machine onto the machine's "plane" of action

    since there's 0, 1 or 2 solutions to this, i want to make sure the script chooses wisely

    -----

    in figure 3 a challenging test for the ''joint solver''
    since the large torus turns 5 times slower than the small torus, i was expecting 5 loops or something
    instead we got 4 blades

    note that the trace is courtesy of mcjTracer
    https://sites.google.com/site/mcasualsdazscripts/mcgtracepath-for-mcjtracer
    https://sites.google.com/site/mcasualsdazscripts2/mcjtracerv2

    the constant rotation speed is obtained using
    https://sites.google.com/site/mcasualsdazscripts/setinterpolation-for-ds2-3
    which is a pretty indispensable tool for animators by the way

    jointsolvertest.gif
    600 x 360 - 619K
    kasbah.gif
    600 x 600 - 199K
    sincethen.jpg
    960 x 540 - 110K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 2014

    i'm adding the reach solver
    which is a bit like mcjAutoLimb

    you select a 'hand' node ( in this case a null node parented to the green "foreArm" cylinder )
    and you select a target node, in this case a null node parented to a rotating torus

    and the script will solve the elbow bend angle of the foreArm for each frame of the animation

    Fig 3 - the "reach" solver seems to be ready

    next is to re-implement the piston solver and make sure it can handle equivocal configurations

    garbo.gif
    480 x 480 - 513K
    tada.jpg
    630 x 636 - 69K
    reach.jpg
    669 x 659 - 69K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 2014

    configuration for the "piston solver" tests

    note that the origin of the piston is often in the middle of the piston cup

    Figure 2, the "Help" panel

    Figure 3 - The Piston Solver's good work

    pistoning.gif
    564 x 318 - 127K
    instructions.jpg
    682 x 635 - 208K
    pistonsolver.jpg
    1056 x 672 - 172K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 2014

    there's little delays because
    the same exact machine animation test works perfectly in DS4.7 and spuriously fails in DS 3.0

    the issue seems to be, that some Quaternions are rejected by the setWSRot() function

    well ... i should get through that bug but i was almost ready to post the script !

    if i get stuck i'll post it as it is, before noon

    and work on the DS 1, 2, 3 versions tomorrow

    case in point, in DS3

    this doesn't work

    node.setWSRot(
     DzQuat(
      -0.17301946431094165, 
      -0.6856122568258763, 
      0.17301961737466548, 
      0.6856123577494427 
     )

    this ( equivalent) works

    node.setWSRot(
     DzQuat(
      0.17301946431094165, 
      0.6856122568258763, 
      -0.17301961737466548, 
      -0.6856123577494427 
     )


    after long and painful (nah s'not that bad) trials in DS3
    apparently, doing
    Q.w -= 0.00001;
    before calling setWSRot( t, Q )
    gets rid of errors
    though i suspect i need to use abs()

    omma.gif
    600 x 600 - 83K
    Post edited by mCasual on
  • mCasualmCasual Posts: 4,607
    edited December 2014

    ** Rush Release **** Rush Release **** Rush Release **** Rush Release **

    https://sites.google.com/site/mcasualsdazscripts5/mcjmechanim

    or you could call it a Beta'ish release

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

    Demonstration Videos :

    https://www.youtube.com/watch?v=QEwpUlsqDGI
    and
    https://www.youtube.com/watch?v=FhgCemjxEjA

    mapromo`.jpg
    570 x 570 - 100K
    Post edited by mCasual on
Sign In or Register to comment.