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

    Sketchy physics replay - Mac

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

      I'm trying to take advantage of one of the great assets of the mac version of sketch up and sketchy physics, the transparent background. Any suggestion on how to capture frames in sketchy physics so that the background is transparent. For now I am just exporting an image per frame so that I can control the resolution and frame size but I would guess there is a better way and a better tinkerer out there who can tell me. This code was nicked from Mr. K and works to interpolate camera positions between scenes while saving an image every frame. Put the code in the on tick box of any sketchy physics solid.

      if frame==0
        @transition_time=100
        @pages=Sketchup.active_model.pages
        @cam=Sketchup.active_model.active_view.camera
        @view=Sketchup.active_model.active_view
        @page_num=@pages.count-1
        @cur_page=0
        @next_page=1
      end
      
      if frame>0
        per=frame%@transition_time
        if per==0
          @cur_page+=1
          @next_page+=1
          @cur_page=0 if(@cur_page>@page_num)
          @next_page=0 if(@next_page>@page_num)
        end
        per=per.to_f/@transition_time
        page_cam1=@pages[@cur_page].camera
        page_cam2=@pages[@next_page].camera
        fov,eye,target,up=interpolate_camera(page_cam1,page_cam2,per)
        @cam.fov=fov
        @cam.set(eye,target,up)
        @newview=@view.refresh
        framet=frame.to_s
        while framet.length< 4
          framet="0"+framet
        end
        @name="/Users/markptak/Desktop/tempimage/write_image."+framet+".png"
        keys={
            ;filename => @name,
            ;width => 1924,
            ;height => 1080,
            ;antialias => false,
            ;compression => 0.9,
            ;transparent => true
            }
        @newview.write_image keys
      end
      
      if frame==0
       def interpolate_camera(cam1,cam2,per2)
         per1=1-per2
         fov1=cam1.fov
         fov2=cam2.fov
         fov=fov1*per1+fov2*per2
         eye=[]
         eye1=cam1.eye.to_a
         eye2=cam2.eye.to_a
         (0..2).each{|index| eye[index]=eye1[index]*per1+eye2[index]*per2}
         tar=[]
         tar1=cam1.target.to_a
         tar2=cam2.target.to_a
         (0..2).each{|index| tar[index]=tar1[index]*per1+tar2[index]*per2}
         up=[]
         up1=cam1.up.to_a
         up2=cam2.up.to_a
         (0..2).each{|index| up[index]=up1[index]*per1+up2[index]*per2}
         return fov,eye,tar,up
        end
      end
      
      
      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