• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

MSPhysics tests and questions

Scheduled Pinned Locked Moved Plugins
104 Posts 21 Posters 44.7k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    Anton_S
    last edited by 8 May 2017, 20:12

    Hello, Zoltan,

    Yes, you understood the concept correctly.

    For such behavior, however, a script might not be necessary. You can use a Piston or a CurvyPiston joint. When you add a Piston joint, set its position units to m, linear rate to like, 1000, and the controller to, world.time % 10. This will generate a value b/w 0 and 10 on a timescale of 10 seconds.

    Also, in case you don't know how to use joints, here is a Wiki:
    https://github.com/AntonSynytsia/MSPhysics/wiki/Using-Joints

    But if you want a special behavior that would teleport a moving object after it surpasses a scalar of a coordinate, then this is how you do it:

    onStart {
      @max_x = 100.m
      @start_pos = this.get_position(1)
    }
    
    onUpdate {
      this.set_velocity(1,0,0)
      if this.get_position(1).x > @max_x
        this.set_position(@start_pos)
      end
    }
    

    Paste this script into the desired moving object(s).

    Basically, this will move an object at 1 m/s along the x-axis and teleport it back to start when the objects X coordinate surpasses maximum x position.

    You can also, instead, control it by force rather than velocity:

    onStart {
      @max_x = 100.m # in inches; the .m converts it meters to inches.
      @start_pos = this.get_position(1)
      @des_vel_x = 1 # in m/s
    }
    
    onUpdate {
      # Compute the desired acceleration in m/s/s -> (des_vel - cur_vel) / timestep
      ax = (@des_vel_x - this.get_velocity.x) / simulation.update_timestep
      # Apply force
      this.add_force(ax * this.mass, 0, 0)
      # Teleport if necessart
      if this.get_position(1).x > @max_x
        this.set_position(@start_pos)
      end
    }
    

    Applying forces are better than applying velocities because they don't dissipate any other forces like the force of gravity or the force of contacts. Also, if you don't want to have the object be affected by the gravity, you can, as well, add force to the z component, like 9.801 * this.mass or you can simply disable gravity for the object. Both yield the same behavior.

    But, like I said, to if you want to create moving platform that doesn't involve teleportation, you can add a Piston joint and connect it to the desired object. Then add an oscillator controller to the Piston joint, like oscillator(50)*100.

    Regards,
    Anton

    1 Reply Last reply Reply Quote 0
    • D Offline
      DingBEN
      last edited by 7 Jun 2017, 04:52

      I created a floor (static mesh), and a ball and a cube both compounds
      I tilted the floor (5)
      ...Friction ON

      Play:

      • Ball rolls to the edge of the floor and stops! ?
      • Cube does not even move

      ...Friction OFF

      • both roll/slide off the floor and disappear in the abyss

      I wait for 10 15 secs,

      • the floor's front face disappears so the inside of the floor can be seen,
      • and from that face the floor melts away until it reaches the back right corner
      • then it melts from the back right corner to the left one and vanishes!

      Also if using any SketchUp commands, for example, to realign the scene
      then the behavior of objects and mouse pointing and other function go to the abyss of absurdity

      Hope this is helpful.

      1 Reply Last reply Reply Quote 0
      • F Offline
        faust07
        last edited by 8 Jun 2017, 11:34

        Hi DingBEN,
        I guess the ball stops at the edge because its shape is defined as "Compound".
        You could test is with a collision shape "Sphere".
        When in MSPhysics objects fall down into infinity, they gradually enlarge the overall model.
        They are falling too far away from the camera.
        And the "clipping" problem known in SketchUp is getting stronger until all objects are optically cut off in the field of view of the camera.
        You can read a bit more about the "clipping" issue here:
        http://support.google.com/sketchup/bin/ ... swer=36261

        1 Reply Last reply Reply Quote 0
        • C Offline
          chad3006
          last edited by 28 Jun 2017, 13:31

          I posted this same question at the MSPhysics Github. I'm very new to MSPhysics and not very smart either, so I was wondering if anyone has attempted a simulated wind-tunnel or something like that using MSPhysics? Is such a thing even possible at the moment? If so could you share?

          1 Reply Last reply Reply Quote 0
          • A Offline
            Anton_S
            last edited by 28 Jun 2017, 22:33

            Wind tests are not possible with MSPhysics. I once came across a plugin dealing with fluid analysis but can't recall the name of it.

            1 Reply Last reply Reply Quote 0
            • F Offline
              faust07
              last edited by 11 Jul 2017, 17:38

              Here the first small test example MSPhysics v1.0.0 with scripted emitters.
              Unfortunately, SketchUp crashes completely after a few seconds.
              In MSPhysics v1.0.0 WIP7 there was no problem with this.
              Thanks in advance.
              Edit: Fixed in high Speed - now it works - thanks to Anton! πŸ‘


              Rain-Test_SUp17-MSP100_01.skp

              1 Reply Last reply Reply Quote 0
              • ecatiE Offline
                ecati
                last edited by 13 Jul 2017, 09:19

                To ensure smooth movement, how should the green piece connect to the blue piece?


                soru.jpg


                soru.skp

                1 Reply Last reply Reply Quote 0
                • A Offline
                  Anton_S
                  last edited by 13 Jul 2017, 20:28

                  The green piece can be grouped with the blue pieces: ungroup both of the blue pieces, hold CTRL, select the green piece, and regroup them all together.

                  For improvements you can change the collision of the yellow wheels to Cylinder shape. Also, set the solver model to iterative 16 passes and material thickness to zero.

                  The only way you will achieve a smooth ride is by relying on the CurvySlider joints and having the entire track set be ignored; relying on contacts will rarely show you good results. Here I attached your model with two CurvySlider joints lining the entire track. I also used Fredo6's Curvyvizard (http://sketchucation.com/forums/viewtopic.php?p=415495#p415495) to smooth the curvy at certain, rough locations.
                  soru.skp

                  1 Reply Last reply Reply Quote 0
                  • F Offline
                    faust07
                    last edited by 7 Aug 2017, 15:42

                    Comparison between V0.9.9 and V1.0.1(V1.0.2)

                    Have the following problems:

                    • the deep impact of small scripted emitters on heavy bodies.
                    • strong reflection of that emitted objects (non collision) on a Buoyancy Plane.
                    • continuous OnTouch events of object with a plane for "waves" and "splashes" don't work anymore.

                    Here are two files, on for SkechUp 2016 with MSPhysics v0.9.9 witch worked well and the other for SketchUp 2017 with MSPhysics v1.0.1 for witch I need help.
                    For the parallel tests I hade to install MSP v0.9.9 on SUp 2016 - sorry!
                    The GIF of V0.9.9 shows what I want to achieve.
                    Thanks in advance!


                    OnTouch-Test_05_099.gif


                    OnTouch-Test_01_MSP0.9.9_SUp2016.skp


                    OnTouch-Test_05_101.gif


                    OnTouch-Test_01_MSP1.0.1_SUp2017.skp

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      Anton_S
                      last edited by 8 Aug 2017, 04:28

                      There were a few issues.

                      In new version, onTouch is triggered only one time, whenever there is a contact between bodies. In your script you tried to use the onTouch event as a repetitive event for generating trailing waves. It did work, as a bug, in version 0.9.9 but not anymore.

                      Another thing is setting emitted bodies non-collidable. Setting the original bodies non-collidable won't make the emitted body non-collidable. You must appply such state explicitly to the emitted body:

                      
                      body = simulation.emit_body(...)
                      body.collidable = false
                      
                      

                      I fixed all these issues and also made rain droplets be independent of touch event.


                      Faust's Whale.skp

                      1 Reply Last reply Reply Quote 0
                      • F Offline
                        faust07
                        last edited by 8 Aug 2017, 09:43

                        Hi Anton, once again thank you for the quick reply. πŸ‘
                        This is, of course, an interesting approach and for me something new to explore again.

                        A touch function as a repetitive event for generating something would be great. I think it was a good bug and you should bring it back as separate option. if it is possible... 😎

                        One problem in the new solution is, that after about 700 frames the lifetime of some emitted objects doesn't end.


                        Whale_AntonS_1150.png

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          Anton_S
                          last edited by 8 Aug 2017, 10:17

                          Hmm... I think something is wrong in code or with MSPhysics. Try changing the rain dproplet's code to this:

                          onStart {
                            @instances = {}
                          }
                          
                          onTick {
                            dir = this.group.transformation.zaxis
                            dir.length = this.mass
                            point = this.get_position + Geom;;Vector3d.new((rand()-0.5)*1000, (rand()-0.5)*1000, (rand()-0.5)*10)
                            tra = Geom;;Transformation.new(point)
                            rain = simulation.emit_body(this, tra, dir, 5)
                            rain.collidable = false
                            @instances[rain] = true
                            @instances.reject! { |k,v|
                              next true unless k.valid?
                              point = k.get_position(0)
                              if point.z < 0
                                #k.destroy(true)
                                posineu = Geom;;Point3d.new(point.x, point.y, 5)
                                tra = Geom;;Transformation.new(posineu)
                                body = simulation.emit_body(@@splash2, tra, @@dir, 0.25)
                                body.collidable = false
                                if frame % 3 == 0
                                  posineu = Geom;;Point3d.new(point.x, point.y, -2)
                                  tra = Geom;;Transformation.new(posineu)
                                  body = simulation.emit_body(@@bubble2, tra, @@dir, 0.2)
                                  body.collidable = false
                                end
                                next true
                              end
                              false
                            }
                          }
                          

                          Aside from that, you can use onTouching event for repetitive action, but it only yields toucher parameter and doesn't provide touch position.

                          1 Reply Last reply Reply Quote 0
                          • F Offline
                            faust07
                            last edited by 8 Aug 2017, 12:15

                            Without the k.destroy function it works better now. Thanks, Anton. πŸ‘
                            Controlling the disappearance of the drops by setting the lifetime is sufficient...
                            I have meanwhile found a way to make the marine life's bow wave smooth on the surface of the water, even if it slopes sideways.
                            More complicated is it, when objects are jumping out of the water, when diving or with falling ice floes causing the appropriate waves and splashes, which was very easy with the good old V0.9.9 bug function.
                            The gif-example is old, but shows what I mean.
                            Witch toucher parameters can I use from an onTouching event to get recurring waves and splashes during prolonged movement of objects in the water?


                            Foam_Test05.gif

                            1 Reply Last reply Reply Quote 0
                            • A Offline
                              Anton_S
                              last edited by 8 Aug 2017, 20:22

                              You can rely on MSPhysics::Body.#contacts function. Add this code to an iceberg to see the effect:

                              onTick {
                                if this.get_velocity.length > 1.0 && frame % 10 == 0
                                  this.contacts(true).each { |contact|
                                    body = simulation.emit_body(@@splash4, contact.point, @@dir, 0.4)
                                    body.collidable = false
                                  }
                                end
                              }
                              
                              1 Reply Last reply Reply Quote 0
                              • F Offline
                                faust07
                                last edited by 8 Aug 2017, 23:30

                                The script works in this form good for a few objects. The falling pieces of an iceberg touch each other and produce emitting objects everywhere in the air in mass. SketchUp crashes then ... It would be good if I could use instead of .each a certain surface for the contact. Another problem is that all splashes are created simultaneously. Therefore a script for a random time point of emitting would be very helpful. I'll try this...

                                1 Reply Last reply Reply Quote 0
                                • F Offline
                                  faust07
                                  last edited by 10 Aug 2017, 09:17

                                  After I have tried several things and have not come to any satisfactory result, I have a suggestion:
                                  It would be great to have a kind of "Penetration Joint" or function (onPenetration):
                                  to connect it to one or more noncollidable objects (or faces).
                                  The properties of objects that penetrate this noncollidable object are to be evaluated continuously:
                                  name, mass, velocity, position of the touch/penetration, direction of movement, etc..
                                  In other words, please bring back the old onTouch bug as an independent function!

                                  1 Reply Last reply Reply Quote 0
                                  • F Offline
                                    faust07
                                    last edited by 22 Aug 2017, 11:15

                                    I finally found a satisfactory solution for my imitated water fun in MSPhysics v1.0.2:
                                    A combination of a surface with onTouch function (water surface) and an evaluation of velocity.lenght (onTouching event) and contact.points of in the area of this surface moving objects.
                                    Anton, thank you for the examples, hints and help!


                                    OnTouch-0001.gif

                                    1 Reply Last reply Reply Quote 0
                                    • F Offline
                                      faust07
                                      last edited by 6 Sept 2017, 12:01

                                      Hi Anton,
                                      I want to bring more variation into the particles of the orca's breathing air. My intended scaling function does not show any reaction. What can be the cause? Can't scripted emitted objects not be scaled during simulation?

                                      
                                      for i in 1..20 do
                                        tra = this.group.transformation
                                        dir_zsf = tra.zaxis
                                        dir_zsf.length = 290 + rand(100)
                                        fount_p = Geom;;Point3d.new(0.0 + rand(-5..5), 2.9.m + rand(20), 0.5.m + rand(15)) # y-pos of fountain
                                        point = fount_p.transform(tra)
                                        transl = Geom;;Transformation.new(point)
                                        scalin = Geom;;Transformation.scaling point, rand(1..5)     
                                        transf = scalin * transl
                                        if point.z > 0.1.m
                                          body = simulation.emit_body(@@splashF, transf, dir_zsf, 0.2)
                                          body.collidable = false
                                        end
                                      end
                                      
                                      

                                      OnTouch-Test_21_V102.gif

                                      1 Reply Last reply Reply Quote 0
                                      • F Offline
                                        faust07
                                        last edited by 26 Oct 2017, 09:44

                                        The next step is to find a solution to bridge the gaps that arise between the moving parts of the objects at the pivot points.
                                        I think of flexible triangular or square surfaces, which I can clamp between the boundary lines of the moving parts. For this I have to immerse deeper into the Ruby programming of SketchUp geometry ...
                                        If someone from the experts has ideas, I would be very happy.


                                        OnTouch-Test_19_V102.gif


                                        and how it looks like rendered with indigo RT

                                        1 Reply Last reply Reply Quote 0
                                        • F Offline
                                          faust07
                                          last edited by 26 Oct 2017, 11:58

                                          Hello Anton, here an other little question:
                                          When I let run "Replay" with active hidden geometry all emitted objects remain in there last position still after there lifetime. Is this normal? Could that explain why Twilight takes longer and longer to render the images during the simulation?


                                          Flexi-Joint_SUp_07.gif


                                          Emitter_Hidden-Geometrie_02.jpg

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 5
                                          • 6
                                          • 4 / 6
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement