A script to create a polylines dForce Add-On Modifier for a bouncing ball

PraxisPraxis Posts: 252

In RGcincy's excellent dForce thread, I posted an example of a dForce bouncing ball whose polylines Add-On was created in Cinema4D and imported into DAZ Studio via an .obj file.

The attached Add_Structure_v4.dsa script creates and adds the same polylines Add-On, using only DAZ Script - I've posted it here so others can see and use the techniques.  NB: Requires DAZ Studio v4.11.0.236 or later

For this it uses code from the following DAZ Samples (thank you Rob!):

To use this script:

  1. In DAZ Studio v4.11.0.236 or later, open the attached Bouncing_Ball_01b.duf (or create your own equivalent per the instructions in my post in RGcincy's thread).
  2. In the Scene Pane, ensure that the "Ball" Node is Selected.
  3. Load the attached Add_Structure_v4.dsa into the Script IDE Pane, and Execute it.

The results should be:

  • An AddOn_Structure.obj file is created (or overwritten!) in the same directory as the .dsa script, and is Imported into DAZ Studio.
  • The new Node "AddOn_Structure" made of polylines is added to the Scene and parented to the "Ball" Node.
  • The new Node has a "dForce Add-On Modifier" added to it.

If you now run the dForce Simulation, you should get the effect shown in the .gif above.

(If you execute the script while holding down the Alt key, then instead of creating and importing an.obj file, the script uses DzFacetMesh::addPolyline() to create the Add-On (coloring it orange instead of white, so you can tell the difference) - but I cannot get this to work correctly, so I have started a separate thread to ask for help with that).

P.

Updated 30-Jul-2019: The attached script is now Add_Structure_v4.dsa, which fixes a "variable not found" bug in v3.

Updated 02-Feb-2019: The attached script is now Add_Structure_v3.dsa, which contains these changes since v2:

  a) The output .obj file is now correctly created in the same directory as the script (instead of in the default location).
  b) Speed improvement in the calculation of symmetric pairs of vertices.
  c) When calculating symmetric pairs of vertices, the Node's Origin is now correctly temporarily set to the World Origin.

Updated 19-Jan-2019: The attached script is now Add_Structure_v2.dsa, which partly fixes the problems when using the Alt key and DzFacetMesh::addPolyline() - see the separate thread for details.

duf
duf
Bouncing_Ball_01b.duf
158K
Bouncing_Ball_01b.gif
600 x 600 - 192K
dsa
dsa
Add_Structure_v4.dsa
41K
Post edited by Praxis on

Comments

  • PraxisPraxis Posts: 252

    Fixed some issues since v2:

    Updated 02-Feb-2019: The script attached to the original is now Add_Structure_v3.dsa, which contains these changes since v2:

      a) The output .obj file is now correctly created in the same directory as the script (instead of in the default location).
      b) Speed improvement in the calculation of symmetric pairs of vertices.
      c) When calculating symmetric pairs of vertices, the Node's Origin is now correctly temporarily set to the World Origin.

     

  • mx90209mx90209 Posts: 69
    Great job!
  • PraxisPraxis Posts: 252

    Thank you!

    P.

Sign In or Register to comment.