sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Tutorial: How to create physics joints in SP simulation

    Scheduled Pinned Locked Moved SketchyPhysics
    1 Posts 1 Posters 1.2k Views 1 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
      MrDailyBlah
      last edited by

      Hi there..
      Now probably all of u guyz have used Sketchyphysics at some point, and created physics joints in them. πŸ˜„

      The problem though, is that sumtimes the joints become glitchy 😒 : they either become floppy or fall off completely... 😒 😠 not good...

      The solution to the problem is to create a joint while the simulation is running.

      Ever explored the scripts which make up Sketchyphysics? If so, u've probably seen the module "NewtonServer" sumwhere... πŸ˜• . this module is just about the kernel of the Sketchyphysics system. It creates nearly every physical feature of Sketchyphysics, from joints to forces to gravity and so on. πŸ€“

      We need one of its methods, which is "createJoint"...

      
      # this example creates a hinge joint
      parent={grp} # a grouped object that encases the joint
      child={grp} # a grouped object that is attached to the joint
      
      type="hinge"
      min=0
      max=0
      accel=0
      damp=0
      breakingForce=1000000
      limits=[min,max,accel,damp,0,0,breakingForce] # parameters for the joint
      
      xform=parent.transformation
      pinDir=xform.zaxis.to_a # the axis of the joint
      
      parentBody=DL;;PtrData.new(parent.get_attribute("SPOBJ","body",nil)) # converted parent body
      
      childBody=DL;;PtrData.new(child.get_attribute("SPOBJ","body",nil)) # converted child body
      
        jnt=NewtonServer.createJoint(type,xform.origin.to_a.pack("f*"),
                  pinDir.pack("f*"),
                  childBody,parentBody, 
                  limits.pack("f*") ) # the joint itself	
      
      
      

      Important: in general, all array objects need ".pack("f*")" after them, and all grouped bodies need to be converted into DL::PtrData (by using "DL::PtrData.new({grp}.get_attribute("SPOBJ","body",nil))" ) πŸ€“

      The created joint doesnt have the bugs normal joints have. (hopefully... πŸ˜† )

      Have fun "Sketchyphysic"ing (!) πŸ˜„ πŸ€“ πŸ€“ ❗ πŸ’š

      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