sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    SketchyPhysics 3x June 27 version.

    scheduled pinned locked moved SketchyPhysics
    95 Posts 12 Posters 23.6k Views 12 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • W Offline
      Wacov
      last edited by

      Got cloth smoothing working, and made it easier to change the scripting (everything's in the floor). Chris, it seems if there's a script error in onend, objects fail to move back to their starting positions... and it can't be undone 😕 Try sticking jargon in onend, and see for yourself.

      Anyway, the updated cloth!


      Cloth wth smooth faces.skp

      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

      one-reply-to-this-post last-reply-time reply quote 0
      • C Offline
        CPhillips
        last edited by

        @wacov said:

        Chris, it seems if there's a script error in onend, objects fail to move back to their starting positions... and it can't be undone 😕 Try sticking jargon in onend, and see for yourself.

        Thanks. I fixed it.

        one-reply-to-this-post last-reply-time reply quote 0
        • C Offline
          CPhillips
          last edited by

          This script is inspired by a new model on 3dwarehouse that ran really smooth... once I turned off shadows and edges.

          Paste this into one objects scripted field. It tries to speed up the rendering by disabling shadows and edges during the simulation. Don't worry if you dont understand it. It should be plug and play.

          onstart{
                #save current settings
             ropts=Sketchup.active_model.rendering_options
             sopts=Sketchup.active_model.shadow_info
             @saveROpts=ropts.collect{|k,v|[k,v]}
             @saveSOpts=sopts.collect{|k,v|[k,v]}
          
                #changes to speed up render
             ropts["EdgeDisplayMode"]=0
             sopts["DisplayShadows"]=false
          
          }
          onend{
                #restore render settings.
             @saveROpts.each{|k,v|; Sketchup.active_model.rendering_options[k]=v}
             @saveSOpts.each{|k,v|; Sketchup.active_model.shadow_info[k]=v}
          }
          

          Original model. http://sketchup.google.com/3dwarehouse/details?mid=3107b3d9c4c935b2b006aed51312d6bb&prevstart=0

          one-reply-to-this-post last-reply-time reply quote 0
          • J Offline
            JaViXP
            last edited by

            Thanks, that script will be really helpful 👍

            The bot... Love playing with it! 😆 (I know it's Pecoler's)
            By the way, how do you keep the breakable objects already broken? I mean, they are crashed and the simulation didn't start.

            "Giving up is way harder than trying"
            JaViXP's Rendering

            one-reply-to-this-post last-reply-time reply quote 0
            • W Offline
              Wacov
              last edited by

              Uh... Chris... the Joystick commands don't work. I know you said it's all completely new, but that seems like a step backwards 😕

              You can bridge the gap using global variables, but that's the only way I can find... here's a demo:


              Fixed, hopefully

              http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

              one-reply-to-this-post last-reply-time reply quote 0
              • P Offline
                phy
                last edited by

                Um, Wacov is the file supposed to not work?
                Okay it works now.

                Tableau de comparaison de Staxyn s'agit d'un mГ©dicament uniquement sur ordonnance.

                one-reply-to-this-post last-reply-time reply quote 0
                • P Offline
                  phy
                  last edited by

                  If you cut the script in box1, and run and reset the simulation, and then paste the script back into box1 it will work, I don't know why.

                  Tableau de comparaison de Staxyn s'agit d'un mГ©dicament uniquement sur ordonnance.

                  one-reply-to-this-post last-reply-time reply quote 0
                  • P Offline
                    phy
                    last edited by

                    Sketchyphysics isn't recognizing @@pos2 for some reason. To see for yourself open ruby console hit the play button.

                    Tableau de comparaison de Staxyn s'agit d'un mГ©dicament uniquement sur ordonnance.

                    one-reply-to-this-post last-reply-time reply quote 0
                    • W Offline
                      Wacov
                      last edited by

                      Thanks Phy! Since you pinpointed it, I found the problem. Seems it was trying to use @@pos2 before it had been created, I just had to add it into onstart and it worked fine!

                      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                      one-reply-to-this-post last-reply-time reply quote 0
                      • W Offline
                        Wacov
                        last edited by

                        Okay, playing around with vectors (another toe in the API pond). Basically, I'm finding them, then changing their length with joystick inputs. I then use them to control the velocity of an object; in this case, the player in an FPS system; this works pretty sweet, so I'll continue to add features, and see where it takes me!

                        EDIT: Fixed. Tell me if it's not 😉


                        FPS Rig1.0.skp

                        http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                        one-reply-to-this-post last-reply-time reply quote 0
                        • P Offline
                          Physicsguy1
                          last edited by

                          there is an Error. double-clicking wont kick the object.

                          one-reply-to-this-post last-reply-time reply quote 0
                          • C Offline
                            CPhillips
                            last edited by

                            I removed double click = kick because it was seldom used and interfering with the new events.

                            one-reply-to-this-post last-reply-time reply quote 0
                            • C Offline
                              CPhillips
                              last edited by

                              Here is another useful script. It allows scripts to print text to the screen. In this case a log of whatever touches the floor.

                                 #add blank text to screen at 10,50
                              @@log=SketchyPhysics;;addWatermarkText(10,50,"")
                                 #place to store lines
                              @@lines=[]
                              
                              ontouch{|t,s,p|
                                    #add new line
                                 @@lines.push(t.name+" touched "+self.name)
                              
                                    #ensure only 5 lines on screen at once.
                                 @@lines.shift if @@lines.length>5
                                    #display lines
                                 @@log.text=@@lines.join("\n")
                              
                              }
                              
                              onend{
                                 @@log.erase!
                                 @@lines=nil
                              }
                              

                              logging.skp

                              one-reply-to-this-post last-reply-time reply quote 0
                              • J Offline
                                JaViXP
                                last edited by

                                Very nice script! 👍

                                Can we upload with this version if we don't use the new features? 😉

                                "Giving up is way harder than trying"
                                JaViXP's Rendering

                                one-reply-to-this-post last-reply-time reply quote 0
                                • P Offline
                                  Physicsguy1
                                  last edited by

                                  Never really got back to this one: Are we going to be able to set an object's scripting from an external source code?(ie setting an emitted object to explode on impact.)

                                  one-reply-to-this-post last-reply-time reply quote 0
                                  • J Offline
                                    JaViXP
                                    last edited by

                                    Nice question, what do you want it for? 😉

                                    Something like this should work (this one doesn't work, just play around with it):

                                    
                                    ontouch{|toucher,speed,pos|
                                       if(toucher.name=="box"){
                                          split(self,1)
                                    }
                                       end
                                    }
                                    

                                    Hope this helps! 😄

                                    "Giving up is way harder than trying"
                                    JaViXP's Rendering

                                    one-reply-to-this-post last-reply-time reply quote 0
                                    • W Offline
                                      Wacov
                                      last edited by

                                      @unknownuser said:

                                      Never really got back to this one: Are we going to be able to set an object's scripting from an external source code?(ie setting an emitted object to explode on impact.)

                                      Any SU ruby would work, ao you might be able to load an external .rb file as an ontick func, or whatever. But you don't need that to do what you're asking, as Jav has shown; and anything that SU can detect can be acted upon.

                                      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

                                      one-reply-to-this-post last-reply-time reply quote 0
                                      • C Offline
                                        CPhillips
                                        last edited by

                                        @wacov said:

                                        @unknownuser said:

                                        Never really got back to this one: Are we going to be able to set an object's scripting from an external source code?(ie setting an emitted object to explode on impact.)

                                        Any SU ruby would work, ao you might be able to load an external .rb file as an ontick func, or whatever. But you don't need that to do what you're asking, as Jav has shown; and anything that SU can detect can be acted upon.
                                        Hi everyone. Sorry I have been quiet lately. Been taking some time off and enjoying the summer.

                                        I think it is possible to set events externally with this version. I know the the syntax is a bit weird and I plan to clean it up.

                                        Create a good sized cone and put this in its scripted field.

                                        b=copy
                                        b._setEvent("ontick",
                                        <<CODE
                                           push([0,0,1])#go forward
                                           if(frame>50)
                                              destroy #die after 50.
                                           end
                                        CODE
                                        )
                                        

                                        The cone will copy itself and then set the "ontick" event in the copy.

                                        I tried to make an example that uses "ontouch" but it didnt work for some reason. I will have to debug it.

                                        one-reply-to-this-post last-reply-time reply quote 0
                                        • N Offline
                                          NorviewsVeteran
                                          last edited by

                                          Sorry I don't have much to add, but there are a few things. I'm no programmer, I'm on the mechanical team.

                                          1. You guys are blowing my mind. Wacov, when I opened your cloth file my jaw dropped for so long I almost drooled on my cat.

                                          @unknownuser said:

                                          Can we upload with this version if we don't use the new features?

                                          1. I needed an excuse to upload the Gopher.

                                          Gopher Armored Car.skp

                                          ```
                                          //This_Is_All(I)+=Know()About.Code;
                                          ```

                                          one-reply-to-this-post last-reply-time reply quote 0
                                          • C Offline
                                            CPhillips
                                            last edited by

                                            Nice model!

                                            one-reply-to-this-post last-reply-time reply quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 3 / 5
                                            • first-post
                                              last-post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement