sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Piston and slider are the same, but I think...

    Scheduled Pinned Locked Moved SketchyPhysics
    11 Posts 4 Posters 1.4k Views 4 Watching
    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.
    • M Offline
      MrPlanet
      last edited by

      Great point, i think it can be done, using gears, but if you do that, SketchUp and SketchyPhysics may suffer an application crash.

      I reject your reality and substitute my own.

      1 Reply Last reply Reply Quote 0
      • B Offline
        BTM
        last edited by

        @unknownuser said:

        Great point, i think it can be done, using gears, but if you do that, SketchUp and SketchyPhysics may suffer an application crash.

        Not really, look at the example (found on the warehouse, or download from link)
        It's not a real etch-e-sketch, because I'd need to be able to input a key to get rid of the emitters, and I can't do that. So they last for 3000 frames.

        Also, for moving/complex objects, worm gears are sometimes just not possible. I was trying to set up a movable camera for something, but there was no way I could include worm gears (well, no way without adding extra weight to the object, which I couldn't do)

        1 Reply Last reply Reply Quote 0
        • B Offline
          BTM
          last edited by

          An example of what I mean is this Etch-e-Sketch thing I made. It uses worm gears, but should I really need them?
          http://sketchup.google.com:80/3dwarehouse/download?mid=cc25ee1885707f70ffa95f224611fcb6&rtyp=s7&fn=etch-e-sketchup&ctyp=sm&ts=1238859809000
          Arrow keys to move, space to draw.
          Sketch.jpg

          1 Reply Last reply Reply Quote 0
          • C Offline
            CPhillips
            last edited by

            Sliders were in SP1 and Pistons were added in SP2. Even though they are very much the same and could have been one joint I left them in to retain backward compatibility.

            Your right that it would be useful to have such a joint.

            In the meantime you could do a few other things. One would be use a regular slider and then a thruster on the body to move it along the slider.

            Another that would allow the keyboard to work would be do something like in a piston controller.

            
            #Formatted for clarity.
            
            pos=getVar("pos");
            pos=pos+(key("up")*0.02);
            pos=pos+(key("down")*-0.02);
            setVar("pos",pos);
            pos;
            
            

            The last line tells the controller to set to the value of pos.

            A shorter less easy to read version of the above.

            
            
            pos=getVar("pos")+(key("up")*0.02)+(key("down")*-0.02);setVar("pos",pos);pos;
            
            
            
            1 Reply Last reply Reply Quote 0
            • S Offline
              Sgt.A.Johnson
              last edited by

              @cphillips said:

              Sliders were in SP1 and Pistons were added in SP2. Even though they are very much the same and could have been one joint I left them in to retain backward compatibility.

              Your right that it would be useful to have such a joint.

              In the meantime you could do a few other things. One would be use a regular slider and then a thruster on the body to move it along the slider.

              Another that would allow the keyboard to work would be do something like in a piston controller.

              
              > #Formatted for clarity.
              > 
              > pos=getVar("pos");
              > pos=pos+(key("up")*0.02);
              > pos=pos+(key("down")*-0.02);
              > setVar("pos",pos);
              > pos;
              > 
              

              The last line tells the controller to set to the value of pos.

              A shorter less easy to read version of the above.

              
              > 
              > pos=getVar("pos")+(key("up")*0.02)+(key("down")*-0.02);setVar("pos",pos);pos;
              > 
              > 
              

              That is a very good code but i found a problem with the second version. I'm yet to try the first one. It ignores the min and max values when you run it

              1 Reply Last reply Reply Quote 0
              • S Offline
                Sgt.A.Johnson
                last edited by

                @sgt.a.johnson said:

                That is a very good code but i found a problem with the second version. I'm yet to try the first one. It ignores the min and max values when you run it

                First code won't copy and paste into text box. looks pretty much the same though

                1 Reply Last reply Reply Quote 0
                • C Offline
                  CPhillips
                  last edited by

                  @sgt.a.johnson said:

                  That is a very good code but i found a problem with the second version. I'm yet to try the first one. It ignores the min and max values when you run it

                  Controllers usually allow values to exceed 0-1.0 (the min max values). That can be very useful in some cases.

                  If you want to clamp the values in the above example add:

                  if(pos>1.0);pos=1.0;elsif(pos<0.0)pos=0.0;end
                   
                  
                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    Sgt.A.Johnson
                    last edited by

                    @cphillips said:

                    @sgt.a.johnson said:

                    That is a very good code but i found a problem with the second version. I'm yet to try the first one. It ignores the min and max values when you run it

                    Controllers usually allow values to exceed 0-1.0 (the min max values). That can be very useful in some cases.

                    If you want to clamp the values in the above example add:

                    if(pos>1.0);pos=1.0;elsif(pos<0.0)pos=0.0;end
                    >  
                    

                    Some reason adding that won't work. Im not good at code so perhaps i misunderstood what to do. i just copied and pasted first code in and then copied and pasted constraining code onto the end

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      CPhillips
                      last edited by

                      @sgt.a.johnson said:

                      @cphillips said:

                      @sgt.a.johnson said:

                      That is a very good code but i found a problem with the second version. I'm yet to try the first one. It ignores the min and max values when you run it

                      Controllers usually allow values to exceed 0-1.0 (the min max values). That can be very useful in some cases.

                      If you want to clamp the values in the above example add:

                      if(pos>1.0);pos=1.0;elsif(pos<0.0)pos=0.0;end
                      > >  
                      

                      Some reason adding that won't work. Im not good at code so perhaps i misunderstood what to do. i just copied and pasted first code in and then copied and pasted constraining code onto the end

                      I just typed that off the top of my head and made a few errors. Here is a correct version:

                      
                      pos=getVar("pos")+(key("up")*0.02)+(key("down")*-0.02);if(pos>1.0);pos=1.0;elsif(pos<0.0);pos=0.0;end;setVar("pos",pos);pos
                      
                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        Sgt.A.Johnson
                        last edited by

                        @cphillips said:

                        I just typed that off the top of my head and made a few errors. Here is a correct version:

                        
                        > pos=getVar("pos")+(key("up")*0.02)+(key("down")*-0.02);if(pos>1.0);pos=1.0;elsif(pos<0.0);pos=0.0;end;setVar("pos",pos);pos
                        

                        Thanks. that works. Ive just tried it in a servo and a motor aswell. Works on those too.

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

                        Advertisement