Any can improve this script?

Home Page Forums General Chat Any can improve this script?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1613931
    Abad
    Participant
    Rank: Rank 5

    Ok...this is the "dsa" from the "dse" amazing script "female physichs". But...only work in ds 4.10...

    ------------------------
    // DAZ Studio version 4.10.0.123 filetype DAZ Script
    // Breast Physics Plus G8F and G3F 2018/05/19

    var nUpDownMorphAmplitude = 1;
    var nUpDownDamp = 30;
    var nUpDownNumberOfFrames = 15;
    var nUpDownNumberOfPeriods = 2;

    var nLeftRightMorphAmplitude = 1;
    var nLeftRightDamp = 30;
    var nLeftRightNumberOfFrames = 15;
    var nLeftRightNumberOfPeriods = 2;

    var nForwardBackMorphAmplitude = 1;
    var nForwardBackDamp = 10;
    var nForwardBackNumberOfFrames = 20;
    var nForwardBackNumberOfPeriods = 1;

    var nMovingAveFrames = 0;
    var nGravity = 9.8;

    var oNode = Scene.getPrimarySelection();

    var oDate = new Date(Date.now());
    var eDate = new Date(2029,5,6,0,0);

    if (eDate - oDate > 0) {
    //MessageBox.information(qsTr("You have " + Math.round((eDate-oDate)/1000/3600/24).toString()+" days left to use this software. "),qsTr("Breasts Physics"),qsTr("OK"));

    if (oNode){
    var oObject = Scene.getPrimarySelection().getSkeleton().getObject();
    fDialog();
    }
    else {
    MessageBox.information(qsTr("Select a target figure."),qsTr("Breast Physics"),qsTr("OK"));
    }
    }
    else {
    MessageBox.information(qsTr("Contact me for a new version."),qsTr("Breast Physics"),qsTr("OK"));
    // stop
    }

    function fDialog() {
    const cWindowTitleCaption = "Breast Physics Plus v.1.0 for G8F & G3F";
    const cDialogLabelText = "2018/05/18 by MasatoK0606. All rights reserved.\nDonation https://www.paypal.me/MasatoK0606.";
    const cFinishDialogCaption = "Breasts Physics";

    const cAmplitudeText = "Amplitude\n (++ Stronger)";
    const cDampingRatioText = "Damping ratio\n (% of peak to the previous)";
    const cNOFtext = "Number of frames per period\n (++ Slower to vibrate)";
    const cNOPtext = "Number of periods to vibrate\n (++ Longer to subside)";

    const cDialNameUDAmplitude = "Breast UD Amplitude";
    const cDialNameUDDampingRatio = "Breast UD Damping Ratio";
    const cDialNameUDNoF = "Breast UD Number of Frames";
    const cDialNameUDNoP = "Breast UD Number of Periods";

    const cDialNameLRAmplitude = "Breast LR Amplitude";
    const cDialNameLRDampingRatio = "Breast LR Damping Ratio";
    const cDialNameLRNoF = "Breast LR Number of Frames";
    const cDialNameLRNoP = "Breast LR Number of Periods";

    const cDialNameFBAmplitude = "Breast FB Amplitude";
    const cDialNameFBDampingRatio = "Breast FB Damping Ratio";
    const cDialNameFBNoF = "Breast FB Number of Frames";
    const cDialNameFBNoP = "Breast FB Number of Periods";

    const cDialNameMovingAve = "Breast Moving Average";
    const cDialNameGravity = "Breast Gravity";

    const nMARGIN = 5;
    const nSPACING = 5;
    const nMIN_BTN_WIDTH = 80;
    const nMAX_BTN_HEIGHT = 20;

    //var oNode = Scene.getPrimarySelection().getSkeleton();
    //Scene.setFrame(0);

    if (oObject.findModifier(cDialNameUDAmplitude)) {

    //Morph dials exist => set the values
    nUpDownMorphAmplitude = oObject.findModifier(cDialNameUDAmplitude).getValueChannel().getValue(0);
    nUpDownDamp = oObject.findModifier(cDialNameUDDampingRatio).getValueChannel().getValue(0);
    nUpDownNumberOfFrames = oObject.findModifier(cDialNameUDNoF).getValueChannel().getValue(0);
    nUpDownNumberOfPeriods = oObject.findModifier(cDialNameUDNoP).getValueChannel().getValue(0);

    nLeftRightMorphAmplitude = oObject.findModifier(cDialNameLRAmplitude).getValueChannel().getValue(0);
    nLeftRightDamp = oObject.findModifier(cDialNameLRDampingRatio).getValueChannel().getValue(0);
    nLeftRightNumberOfFrames = oObject.findModifier(cDialNameLRNoF).getValueChannel().getValue(0);
    nLeftRightNumberOfPeriods = oObject.findModifier(cDialNameLRNoP).getValueChannel().getValue(0);

    nForwardBackMorphAmplitude = oObject.findModifier(cDialNameFBAmplitude).getValueChannel().getValue(0);
    nForwardBackDamp = oObject.findModifier(cDialNameFBDampingRatio).getValueChannel().getValue(0);
    nForwardBackNumberOfFrames = oObject.findModifier(cDialNameFBNoF).getValueChannel().getValue(0);
    nForwardBackNumberOfPeriods = oObject.findModifier(cDialNameFBNoP).getValueChannel().getValue(0);

    nMovingAveFrames = oObject.findModifier(cDialNameMovingAve).getValueChannel().getValue(0);
    nGravity = oObject.findModifier(cDialNameGravity).getValueChannel().getValue(0);

    }
    else {

    //Morph dials dont exist ==> Create them
    fCreateDial(cDialNameUDAmplitude, nUpDownMorphAmplitude, 0, 2.0);
    fCreateDial(cDialNameUDDampingRatio, nUpDownDamp, 10, 90);
    fCreateDial(cDialNameUDNoF, nUpDownNumberOfFrames, 0, 30);
    fCreateDial(cDialNameUDNoP, nUpDownNumberOfPeriods, 0, 3);

    fCreateDial(cDialNameLRAmplitude, nLeftRightMorphAmplitude, 0, 2.0);
    fCreateDial(cDialNameLRDampingRatio, nLeftRightDamp, 10, 90);
    fCreateDial(cDialNameLRNoF, nLeftRightNumberOfFrames, 0, 30);
    fCreateDial(cDialNameLRNoP, nLeftRightNumberOfPeriods, 0, 3);

    fCreateDial(cDialNameFBAmplitude, nForwardBackMorphAmplitude, 0, 2.0);
    fCreateDial(cDialNameFBDampingRatio, nForwardBackDamp, 10, 90);
    fCreateDial(cDialNameFBNoF, nForwardBackNumberOfFrames, 0, 30);
    fCreateDial(cDialNameFBNoP, nForwardBackNumberOfPeriods, 0, 3);

    fCreateDial(cDialNameMovingAve, nMovingAveFrames, 0, 7);
    fCreateDial(cDialNameGravity, nGravity, 0, 10);

    }

    // Get the Help Manager for "What's This?" and tool tips
    var oHelpMgr = App.getHelpMgr();

    // find the "What's This?" action; for the help button
    var oActionMgr = MainWindow.getActionMgr();
    var oHelpAction = oActionMgr ? oActionMgr.findAction( "DzWhatsThisAction" ) : undefined;

    /*****************************
    Dialog
    *****************************/
    var wDlg = new DzDialog;
    wDlg.caption = cWindowTitleCaption;

    // Main Layout
    var wDlgLyt = new DzVBoxLayout( wDlg );
    wDlgLyt.autoAdd = true;
    wDlgLyt.margin = nMARGIN;
    wDlgLyt.spacing = nSPACING;

    // Tab code
    wTabStack = new DzTabWidget( wDlg );
    wUpDownPage = new DzVGroupBox( wTabStack );
    wLeftRightPage = new DzVGroupBox( wTabStack );
    wForwardBackPage = new DzVGroupBox( wTabStack );

    wUpDownPage.flat = true;
    wTabStack.addTab( wUpDownPage, "Up/Down" );
    wLeftRightPage.flat = true;
    wTabStack.addTab( wLeftRightPage, "Left/Right" );
    wForwardBackPage.flat = true;
    wTabStack.addTab( wForwardBackPage, "For/Back" );
    //wDlg.maxWidth = wDlg.minWidth;
    //wDlg.maxHeight = wDlg.minHeight;
    // End Tab code

    // Create a label
    //var wLbl = new DzLabel( wDlg );
    //wLbl.text = "\n\"Breast Control Genesis 8 Female(s)\" is required to run this script.\n";

    // =========================================
    // Create a UpDown Large Group box
    var wBoxUDLarge = new DzHGroupBox( wUpDownPage );
    wBoxUDLarge.orientation = DzHGroupBox.Vertical
    wBoxUDLarge.title = "Up / Down Vibration"

    // Create a group box
    var wBoxUDStrength = new DzHGroupBox( wBoxUDLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxUDStrength );
    wLbl.text = cAmplitudeText;
    // Create a float slider
    var wSliderUDStrength = new DzFloatSlider( wBoxUDStrength );
    wSliderUDStrength.min = 0;
    wSliderUDStrength.max = 2;
    wSliderUDStrength.clamped = true;
    wSliderUDStrength.sensitivity = 0.1;
    wSliderUDStrength.textEditable = true;
    wSliderUDStrength.textVisible = true;
    wSliderUDStrength.value = nUpDownMorphAmplitude;

    // Create a group box
    var wBoxUDDampingRatio = new DzHGroupBox( wBoxUDLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxUDDampingRatio );
    wLbl.text = cDampingRatioText;
    // Create a int slider
    var wSliderUDDampingRatio = new DzIntSlider( wBoxUDDampingRatio );
    wSliderUDDampingRatio.min = 10;
    wSliderUDDampingRatio.max = 90;
    wSliderUDDampingRatio.clamped = true;
    wSliderUDDampingRatio.sensitivity = 1;
    wSliderUDDampingRatio.textEditable = true;
    wSliderUDDampingRatio.textVisible = true;
    wSliderUDDampingRatio.displayAsPercent = true;
    wSliderUDDampingRatio.value = nUpDownDamp;

    // Create a group box
    var wBoxUDNoF = new DzHGroupBox( wBoxUDLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxUDNoF );
    wLbl.text = cNOFtext;
    // Create a int slider
    var wSliderUDNoF = new DzIntSlider( wBoxUDNoF );
    wSliderUDNoF.min = 0;
    wSliderUDNoF.max = 30;
    wSliderUDNoF.clamped = true;
    wSliderUDNoF.sensitivity = 1;
    wSliderUDNoF.textEditable = true;
    wSliderUDNoF.textVisible = true;
    wSliderUDNoF.value = nUpDownNumberOfFrames;

    // Create a group box
    var wBoxUDNoP = new DzHGroupBox( wBoxUDLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxUDNoP );
    wLbl.text = cNOPtext;
    // Create a enum slider
    wSliderUDNoP = new DzEnumSlider( wBoxUDNoP );
    wSliderUDNoP.addItem( "1" );
    wSliderUDNoP.addItem( "2" );
    wSliderUDNoP.addItem( "3" );
    wSliderUDNoP.addItem( "4" );
    wSliderUDNoP.value = nUpDownNumberOfPeriods;

    // =========================================
    // Create a LeftRight Large Group box
    var wBoxLRLarge = new DzHGroupBox( wLeftRightPage );
    wBoxLRLarge.orientation = DzHGroupBox.Vertical
    wBoxLRLarge.title = "Left / Right Vibration"

    // Create a group box
    var wBoxLRStrength = new DzHGroupBox( wBoxLRLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxLRStrength );
    wLbl.text = cAmplitudeText;
    // Create a float slider
    var wSliderLRStrength = new DzFloatSlider( wBoxLRStrength );
    wSliderLRStrength.min = 0;
    wSliderLRStrength.max = 2;
    wSliderLRStrength.clamped = true;
    wSliderLRStrength.sensitivity = 0.1;
    wSliderLRStrength.textEditable = true;
    wSliderLRStrength.textVisible = true;
    wSliderLRStrength.value = nLeftRightMorphAmplitude;

    // Create a group box
    var wBoxLRDampingRatio = new DzHGroupBox( wBoxLRLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxLRDampingRatio );
    wLbl.text = cDampingRatioText;
    // Create a int slider
    var wSliderLRDampingRatio = new DzIntSlider( wBoxLRDampingRatio );
    wSliderLRDampingRatio.min = 10;
    wSliderLRDampingRatio.max = 90;
    wSliderLRDampingRatio.clamped = true;
    wSliderLRDampingRatio.sensitivity = 1;
    wSliderLRDampingRatio.textEditable = true;
    wSliderLRDampingRatio.textVisible = true;
    wSliderLRDampingRatio.displayAsPercent = true;
    wSliderLRDampingRatio.value = nLeftRightDamp;

    // Create a group box
    var wBoxLRNoF = new DzHGroupBox( wBoxLRLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxLRNoF );
    wLbl.text = cNOFtext;
    // Create a int slider
    var wSliderLRNoF = new DzIntSlider( wBoxLRNoF );
    wSliderLRNoF.min = 0;
    wSliderLRNoF.max = 30;
    wSliderLRNoF.clamped = true;
    wSliderLRNoF.sensitivity = 1;
    wSliderLRNoF.textEditable = true;
    wSliderLRNoF.textVisible = true;
    wSliderLRNoF.value = nLeftRightNumberOfFrames;

    // Create a group box
    var wBoxLRNoP = new DzHGroupBox( wBoxLRLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxLRNoP );
    wLbl.text = cNOPtext;
    // Create a enum slider
    wSliderLRNoP = new DzEnumSlider( wBoxLRNoP );
    wSliderLRNoP.addItem( "1" );
    wSliderLRNoP.addItem( "2" );
    wSliderLRNoP.addItem( "3" );
    wSliderLRNoP.addItem( "4" );
    wSliderLRNoP.value = nLeftRightNumberOfPeriods;

    // =========================================
    // Create a Forward/Backward Large Group box
    var wBoxFBLarge = new DzHGroupBox( wForwardBackPage );
    wBoxFBLarge.orientation = DzHGroupBox.Vertical
    wBoxFBLarge.title = "Forward / Backward Vibration"

    // Create a group box
    var wBoxFBStrength = new DzHGroupBox( wBoxFBLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxFBStrength );
    wLbl.text = cAmplitudeText;
    // Create a float slider
    var wSliderFBStrength = new DzFloatSlider( wBoxFBStrength );
    wSliderFBStrength.min = 0;
    wSliderFBStrength.max = 2;
    wSliderFBStrength.clamped = true;
    wSliderFBStrength.sensitivity = 0.1;
    wSliderFBStrength.textEditable = true;
    wSliderFBStrength.textVisible = true;
    wSliderFBStrength.value = nForwardBackMorphAmplitude;

    // Create a group box
    var wBoxFBDampingRatio = new DzHGroupBox( wBoxFBLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxFBDampingRatio );
    wLbl.text = cDampingRatioText;
    // Create a int slider
    var wSliderFBDampingRatio = new DzIntSlider( wBoxFBDampingRatio );
    wSliderFBDampingRatio.min = 10;
    wSliderFBDampingRatio.max = 90;
    wSliderFBDampingRatio.clamped = true;
    wSliderFBDampingRatio.sensitivity = 1;
    wSliderFBDampingRatio.textEditable = true;
    wSliderFBDampingRatio.textVisible = true;
    wSliderFBDampingRatio.displayAsPercent = true;
    wSliderFBDampingRatio.value = nForwardBackDamp;

    // Create a group box
    var wBoxFBNoF = new DzHGroupBox( wBoxFBLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxFBNoF );
    wLbl.text = cNOFtext;
    // Create a int slider
    var wSliderFBNoF = new DzIntSlider( wBoxFBNoF );
    wSliderFBNoF.min = 0;
    wSliderFBNoF.max = 30;
    wSliderFBNoF.clamped = true;
    wSliderFBNoF.sensitivity = 1;
    wSliderFBNoF.textEditable = true;
    wSliderFBNoF.textVisible = true;
    wSliderFBNoF.value = nForwardBackNumberOfFrames;

    // Create a group box
    var wBoxFBNoP = new DzHGroupBox( wBoxFBLarge );
    // Create a label
    var wLbl = new DzLabel( wBoxFBNoP );
    wLbl.text = cNOPtext;
    // Create a enum slider
    wSliderFBNoP = new DzEnumSlider( wBoxFBNoP );
    wSliderFBNoP.addItem( "1" );
    wSliderFBNoP.addItem( "2" );
    wSliderFBNoP.addItem( "3" );
    wSliderFBNoP.addItem( "4" );
    wSliderFBNoP.value = nForwardBackNumberOfPeriods;

    // =========================================
    // Create Large Group box for Common
    var wBoxOthers = new DzHGroupBox( wDlg );
    wBoxOthers.orientation = DzHGroupBox.Vertical
    wBoxOthers.title = "Common"

    // Create a group box
    var wBoxMA = new DzHGroupBox( wBoxOthers );
    // Create a label
    var wLbl = new DzLabel( wBoxMA );
    wLbl.text = "Moving Ave.";
    // Create a enum slider
    wSliderMovingAve = new DzEnumSlider( wBoxMA );
    wSliderMovingAve.addItem( "1" );
    wSliderMovingAve.addItem( "2" );
    wSliderMovingAve.addItem( "3" );
    wSliderMovingAve.addItem( "4" );
    wSliderMovingAve.addItem( "5" );
    wSliderMovingAve.addItem( "6" );
    wSliderMovingAve.addItem( "7" );
    wSliderMovingAve.addItem( "8" );
    wSliderMovingAve.value = nMovingAveFrames;

    // Create a group box
    var wBoxGravity = new DzHGroupBox( wBoxOthers );
    // Create a label
    var wLbl = new DzLabel( wBoxGravity );
    wLbl.text = "Gravity";
    // Create a float slider
    var wSliderGravity = new DzFloatSlider( wBoxGravity );
    wSliderGravity.min = 0;
    wSliderGravity.max = 20;
    wSliderGravity.clamped = true;
    wSliderGravity.sensitivity = 0.1;
    wSliderGravity.textEditable = true;
    wSliderGravity.textVisible = true;
    wSliderGravity.value = nGravity;

    // =========================================

    // Create a group box for the dialog buttons
    var wDlgBtnsGB = new DzGroupBox( wDlg );
    wDlgBtnsGB.flat = true;

    // Create a layout for the dialog buttons
    var wDlgBtnsLyt = new DzGridLayout( wDlgBtnsGB );
    wDlgBtnsLyt.margin = nMARGIN;
    wDlgBtnsLyt.spacing = nSPACING;

    // Create a label
    var wLbl = new DzLabel( wDlgBtnsGB );
    wLbl.text = cDialogLabelText

    // Stretch the column between the left and right sides
    wDlgBtnsLyt.setColStretch( 1, 1 );

    // Create the accept push button
    var wAcceptBtn = new DzPushButton( wDlgBtnsGB );
    wAcceptBtn.text = "Simulate";
    wAcceptBtn.minWidth = nMIN_BTN_WIDTH;
    wAcceptBtn.maxHeight = nMAX_BTN_HEIGHT;
    wDlg.setAcceptButton( wAcceptBtn );
    //wAcceptBtn.toolTip = oHelpMgr.getToolTip( "AcceptDialog" );
    //wAcceptBtn.whatsThis = oHelpMgr.getHelpString( "AcceptDialog" );
    wDlgBtnsLyt.addWidget( wAcceptBtn, 0, 2 );

    // Create the cancel push button
    var wCancelBtn = new DzPushButton( wDlgBtnsGB );
    wCancelBtn.text = "Cancel";
    wCancelBtn.minWidth = nMIN_BTN_WIDTH;
    wCancelBtn.maxHeight = nMAX_BTN_HEIGHT;
    wDlg.setRejectButton( wCancelBtn );
    //wCancelBtn.toolTip = oHelpMgr.getToolTip( "CancelDialog" );
    //wCancelBtn.whatsThis = oHelpMgr.getHelpString( "CancelDialog" );
    wDlgBtnsLyt.addWidget( wCancelBtn, 0, 3 );

    // Polish
    wDlg.width = wDlg.minWidth > 400 ? wDlg.minWidth : 400;
    wDlg.height = wDlg.minHeight;

    // Launch the dialog
    if( wDlg.exec() ) {
    // Set parameters;
    nUpDownMorphAmplitude = wSliderUDStrength.value;
    nUpDownDamp = wSliderUDDampingRatio.value/100; // 2nd peak / 1st peak
    nUpDownNumberOfFrames = wSliderUDNoF.value; // number of frames per period
    nUpDownNumberOfPeriods = wSliderUDNoP.value + 1; // number of periods to vibrate

    nLeftRightMorphAmplitude = wSliderLRStrength.value;
    nLeftRightDamp = wSliderLRDampingRatio.value/100; // 2nd peak / 1st peak
    nLeftRightNumberOfFrames = wSliderLRNoF.value; // number of frames per period
    nLeftRightNumberOfPeriods = wSliderLRNoP.value; // number of periods to vibrate

    nForwardBackMorphAmplitude = wSliderFBStrength.value;
    nForwardBackDamp = wSliderFBDampingRatio.value/100; // 2nd peak / 1st peak
    nForwardBackNumberOfFrames = wSliderFBNoF.value; // number of frames per period
    nForwardBackNumberOfPeriods = wSliderFBNoP.value + 1; // number of periods to vibrate

    nMovingAveFrames = wSliderMovingAve.value + 1;
    vGravity = DzVec3(0,wSliderGravity.value*100/1400,0);

    // Set parameters to morph dials
    //Scene.setFrame(0);
    oObject.findModifier(cDialNameUDAmplitude).getValueChannel().setValue(0, wSliderUDStrength.value);
    oObject.findModifier(cDialNameUDDampingRatio).getValueChannel().setValue(0, wSliderUDDampingRatio.value);
    oObject.findModifier(cDialNameUDNoF).getValueChannel().setValue(0, wSliderUDNoF.value);
    oObject.findModifier(cDialNameUDNoP).getValueChannel().setValue(0, wSliderUDNoP.value);

    oObject.findModifier(cDialNameLRAmplitude).getValueChannel().setValue(0, wSliderLRStrength.value);
    oObject.findModifier(cDialNameLRDampingRatio).getValueChannel().setValue(0, wSliderLRDampingRatio.value);
    oObject.findModifier(cDialNameLRNoF).getValueChannel().setValue(0, wSliderLRNoF.value);
    oObject.findModifier(cDialNameLRNoP).getValueChannel().setValue(0, wSliderLRNoP.value);

    oObject.findModifier(cDialNameFBAmplitude).getValueChannel().setValue(0, wSliderFBStrength.value);
    oObject.findModifier(cDialNameFBDampingRatio).getValueChannel().setValue(0, wSliderFBDampingRatio.value);
    oObject.findModifier(cDialNameFBNoF).getValueChannel().setValue(0, wSliderFBNoF.value);
    oObject.findModifier(cDialNameFBNoP).getValueChannel().setValue(0, wSliderFBNoP.value);

    oObject.findModifier(cDialNameMovingAve).getValueChannel().setValue(0, wSliderMovingAve.value);
    oObject.findModifier(cDialNameGravity).getValueChannel().setValue(0, wSliderGravity.value);

    // Start Main process
    fMain();
    Scene.setFrame(0);
    // Display finish dialog
    if( MessageBox.question( qsTr("Simulation complete."), qsTr("Breast Physics"), qsTr("&Play"), qsTr("&Finish") ) == 0 ){
    Scene.play();
    }
    }
    else
    {
    MessageBox.information( "Process aborted by user.", cFinishDialogCaption, "&OK" );
    }
    }

    // ================= Main Routine ===================
    function fMain() {
    //const nMovingAveFrames = 2;
    //const vGravity = DzVec3(0,980/900,0);

    const sUpDownRMorph = "Up-Down";
    const sUpDownLMorph = "Up-Down";
    const sUpDownAdjustRMorph = "Y Translate";
    const sUpDownAdjustLMorph = "Y Translate";

    const sLeftRightRMorph = "Side-Side";
    const sLeftRightLMorph = "Side-Side";
    const sLeftRightAdjustRMorph = "X Translate";
    const sLeftRightAdjustLMorph = "X Translate";

    const sForwardBackRMorph = "Z Translate";//"3 R Depth";
    const sForwardBackLMorph = "Z Translate";//"3 L Depth";
    //const sForwardBackAdjustRMorph = "Side-Side";
    //const sForwardBackAdjustLMorph = "Side-Side";

    var qRot=[];

    var vRPos=[];
    var vRVel=[];
    var vRAcc=[];
    var vRAccLocal=[];
    var vRAccLocalAve=[];

    var vLPos=[];
    var vLVel=[];
    var vLAcc=[];
    var vLAccLocal=[];
    var vLAccLocalAve=[];

    var nRUpDownShiftValue=[];
    var nLUpDownShiftValue=[];
    var nRLeftRightShiftValue=[];
    var nLLeftRightShiftValue=[];
    var nRForwardBackShiftValue=[];
    var nLForwardBackShiftValue=[];

    var oNode = Scene.getPrimarySelection();
    var oSkel = oNode.getSkeleton();
    var oChest = oSkel.findNodeChild("chestLower", true);
    var oRPect = oSkel.findNodeChild("rPectoral", true);
    var oLPect = oSkel.findNodeChild("lPectoral", true);

    const pUpDownRMorph = oRPect.findPropertyByLabel(sUpDownRMorph);
    const pUpDownLMorph = oLPect.findPropertyByLabel(sUpDownLMorph);
    const pUpDownAdjustRMorph = oRPect.findPropertyByLabel(sUpDownAdjustRMorph);
    const pUpDownAdjustLMorph = oLPect.findPropertyByLabel(sUpDownAdjustLMorph);

    const pLeftRightRMorph = oRPect.findPropertyByLabel(sLeftRightRMorph);
    const pLeftRightLMorph = oLPect.findPropertyByLabel(sLeftRightLMorph);
    const pLeftRightAdjustRMorph = oRPect.findPropertyByLabel(sLeftRightAdjustRMorph);
    const pLeftRightAdjustLMorph = oLPect.findPropertyByLabel(sLeftRightAdjustLMorph);

    const pForwardBackRMorph = oRPect.findPropertyByLabel(sForwardBackRMorph);
    const pForwardBackLMorph = oLPect.findPropertyByLabel(sForwardBackLMorph);
    //const pForwardBackAdjustRMorph = oRPect.findPropertyByLabel(sForwardBackAdjustRMorph);
    //const pForwardBackAdjustLMorph = oLPect.findPropertyByLabel(sForwardBackAdjustLMorph);

    const cLastFrame = Scene.getAnimRange().end / Scene.getTimeStep();
    const tpf = Scene.getTimeStep().valueOf(); // number of ticks (dzTime) per fram

    // Initialize pect bone positions
    for(var n=0; n < cLastFrame+1; n++) {
    //Scene.setFrame(n)
    // UpDown Morph
    pUpDownRMorph.setValue(tpf * n, 0);
    pUpDownLMorph.setValue(tpf * n, 0);
    pUpDownAdjustRMorph.setValue(tpf * n, 0);
    pUpDownAdjustLMorph.setValue(tpf * n, 0);
    // LeftRight Morph
    pLeftRightRMorph.setValue(tpf * n, 0);
    pLeftRightLMorph.setValue(tpf * n, 0);
    pLeftRightAdjustRMorph.setValue(tpf * n, 0);
    pLeftRightAdjustLMorph.setValue(tpf * n, 0);
    // ForwardBack Morph
    pForwardBackRMorph.setValue(tpf * n, 0);
    pForwardBackLMorph.setValue(tpf * n, 0);
    }

    if(oChest) {
    startBackgroundProgress( "Simulation in progress...", 100000, false);
    stepBackgroundProgress( 20000 );processEvents();
    // Get position
    for(var n=0; n < cLastFrame+1; n++) {
    stepBackgroundProgress( 10000 / cLastFrame );
    // Proceed to Nth frame
    Scene.setFrame(n);
    // WS coordinates
    qRot[n] = oChest.getWSRot();
    vRPos[n] = oRPect.getWSPos();
    vLPos[n] = oLPect.getWSPos();
    }

    stepBackgroundProgress( 10000 );processEvents();
    // Velocity
    for(var n=0; n < cLastFrame+1; n++) {
    if(n<1){
    vRVel[n]=DzVec3[0,0,0];
    vLVel[n]=DzVec3[0,0,0];
    }
    else{
    vRVel[n]=vRPos[n].subtract(vRPos[n-1]);
    vLVel[n]=vLPos[n].subtract(vLPos[n-1]);
    }
    }
    stepBackgroundProgress( 10000 );processEvents();
    // Global accelaration in local coordinate system
    for(var n=0; n < cLastFrame+1; n++){
    if(n<2){
    vRAcc[n]=DzVec3(0,0,0);
    vLAcc[n]=DzVec3(0,0,0);
    }
    else{
    vRAcc[n]=vRVel[n].subtract(vRVel[n-1]);
    vLAcc[n]=vLVel[n].subtract(vLVel[n-1]);
    }
    vRAcc[n]=vRAcc[n].add(vGravity);
    vLAcc[n]=vLAcc[n].add(vGravity);
    qInv=qRot[n].inverse();
    vRAccLocal[n]=qInv.multVec(vRAcc[n]);
    vLAccLocal[n]=qInv.multVec(vLAcc[n]);
    vRAccLocal[n]=vRAccLocal[n].subtract(vGravity);
    vLAccLocal[n]=vLAccLocal[n].subtract(vGravity);
    }
    stepBackgroundProgress( 10000 );processEvents();
    // ====Moving Average====
    for(var n=0; n < cLastFrame+1; n++) {
    var vRTotal = new DzVec3(0,0,0);
    var vLTotal = new DzVec3(0,0,0);
    var vCounter = new DzVec3(0,0,0);
    var vInc = new DzVec3(1,1,1);
    for(var nTime=-(nMovingAveFrames-1); nTime < 1; nTime++) {
    if(n+nTime >= 0) {
    vRTotal=vRTotal.add(vRAccLocal[n + nTime]);
    vLTotal=vLTotal.add(vLAccLocal[n + nTime]);
    vCounter=vCounter.add(vInc);
    }
    }
    vRAccLocalAve[n] = vRTotal.divide(vCounter);
    vLAccLocalAve[n] = vLTotal.divide(vCounter);
    }
    stepBackgroundProgress( 10000 );processEvents();
    // Initialize Shape Shift Array
    for(var n=0; n < cLastFrame+1; n++){
    nRUpDownShiftValue[n]=0;
    nLUpDownShiftValue[n]=0;
    nRLeftRightShiftValue[n]=0;
    nLLeftRightShiftValue[n]=0;
    nRForwardBackShiftValue[n]=0;
    nLForwardBackShiftValue[n]=0;
    }
    stepBackgroundProgress( 10000 );processEvents();
    // Calculate Shape Shift values for each frame
    for(var n=0; n < cLastFrame+1; n++) {
    //Up Down oscillation
    for(var nTime=0; nTime < (nUpDownNumberOfFrames * nUpDownNumberOfPeriods) +1; nTime++) {
    if(n+nTime < cLastFrame+1) {
    nRUpDownShiftValue[n + nTime] += UpDownOscillation(nTime) * (vRAccLocalAve[n].y) * (-1);
    nLUpDownShiftValue[n + nTime] += UpDownOscillation(nTime) * (vLAccLocalAve[n].y) * (-1);
    }
    }
    //Right Left oscillation
    for(var nTime=0; nTime < (nLeftRightNumberOfFrames * nLeftRightNumberOfPeriods)+1; nTime++) {
    if(n+nTime < cLastFrame+1) {
    nRLeftRightShiftValue[n + nTime] += LeftRightOscillation(nTime) * vRAccLocalAve[n].x * (-1);
    nLLeftRightShiftValue[n + nTime] += LeftRightOscillation(nTime) * vLAccLocalAve[n].x * (-1);
    }
    }
    //Forward Back oscillation
    for(var nTime=0; nTime < (nForwardBackNumberOfFrames * nForwardBackNumberOfPeriods)+1; nTime++) {
    if(n+nTime < cLastFrame+1) {
    nRForwardBackShiftValue[n + nTime] += ForwardBackOscillation(nTime) * vRAccLocalAve[n].z * (-1);
    nLForwardBackShiftValue[n + nTime] += ForwardBackOscillation(nTime) * vLAccLocalAve[n].z * (-1);
    }
    }
    }
    stepBackgroundProgress( 10000 );processEvents();
    // set morph
    for(var n=0; n < cLastFrame+1; n++) {
    //Scene.setFrame(n)
    // UpDown Morph
    pUpDownRMorph.setValue(tpf * n, (-1) * nUpDownMorphAmplitude * nRUpDownShiftValue[n]);
    pUpDownLMorph.setValue(tpf * n, (-1) * nUpDownMorphAmplitude * nLUpDownShiftValue[n]);
    pUpDownAdjustRMorph.setValue(tpf * n, 0.3 * nUpDownMorphAmplitude * nRUpDownShiftValue[n]);
    pUpDownAdjustLMorph.setValue(tpf * n, 0.3 * nUpDownMorphAmplitude * nLUpDownShiftValue[n]);
    // LeftRight Morph
    pLeftRightRMorph.setValue(tpf * n, 1 * nLeftRightMorphAmplitude * nRLeftRightShiftValue[n] + (0.5) * nForwardBackMorphAmplitude * nRForwardBackShiftValue[n]);
    pLeftRightLMorph.setValue(tpf * n, 1 * nLeftRightMorphAmplitude * nLLeftRightShiftValue[n] + (-0.5) * nForwardBackMorphAmplitude * nLForwardBackShiftValue[n]);
    pLeftRightAdjustRMorph.setValue(tpf * n, 1 * nLeftRightMorphAmplitude * nRLeftRightShiftValue[n]);
    pLeftRightAdjustLMorph.setValue(tpf * n, 1 * nLeftRightMorphAmplitude * nLLeftRightShiftValue[n]);
    // ForwardBack Morph
    pForwardBackRMorph.setValue(tpf * n, -0.3 + 0.6 * nForwardBackMorphAmplitude * nRForwardBackShiftValue[n]);
    pForwardBackLMorph.setValue(tpf * n, -0.3 + 0.6 * nForwardBackMorphAmplitude * nLForwardBackShiftValue[n]);
    }
    finishBackgroundProgress();
    }
    }

    function UpDownOscillation(value) {
    return 2 * Math.exp(value/nUpDownNumberOfFrames*Math.log(nUpDownDamp)) * Math.sin(value/nUpDownNumberOfFrames*2*Math.PI);
    }

    function LeftRightOscillation(value) {
    return 2 * Math.exp(value/nLeftRightNumberOfFrames*Math.log(nLeftRightDamp)) * Math.sin(value/nLeftRightNumberOfFrames*2*Math.PI);
    }

    function ForwardBackOscillation(value) {
    return 2 * Math.exp(value/nForwardBackNumberOfFrames*Math.log(nForwardBackDamp)) * Math.sin(value/nForwardBackNumberOfFrames*2*Math.PI);
    }

    function fCreateDial(Name, Value, Min, Max) {
    //Scene.setFrame(0);
    var newMorphDeltas = new DzMorphDeltas();
    var newMorph = new DzMorph( newMorphDeltas );
    oObject.addModifier (newMorph, -1);
    var curModifier = oObject.getModifier(oObject.getNumModifiers()-1);
    curModifier.setName( Name );
    var curProperty = newMorph.getValueChannel();
    curProperty.setPath( "/Morphs/Breast Physics" );
    curProperty.setValue(0, Value );
    curProperty.setMin( Min );
    curProperty.setMax( Max );
    curProperty.setIsClamped ( true );
    }--------------------------------------
    The "mistake" goes in line 461, like:
    " 2020-07-10 16:34:06.289 WARNING: Script Error: Line 461
    2020-07-10 16:34:06.289 WARNING: TypeError: Result of expression 'oObject.findModifier(cDialNameUDAmplitude)' [null] is not an object.
    2020-07-10 16:34:06.289 WARNING: Stack Trace:
    <anonymous>()@H:/My DAZ 3D Library/Scripts/FemalePhysics/Breast Physics Plus for G8F_G3F v1.0.dse:461"
    ¿This a because a new morphs or a estupid change of the dll aorund Qt?

    #1613932
    Abad
    Participant
    Rank: Rank 5

    lines as"----------------" is srat and end of file..No include then..

    #1613933
    Abad
    Participant
    Rank: Rank 5

    Obviuosly, put a "//" in some code, like "my paypal..", and the "time...", just put 33300 in year... 😀

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

 

Post You Might Like