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

    How to know if user has stopped orbiting camera?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 333 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.
    • fuzzybroF Offline
      fuzzybro
      last edited by

      Hi all,

      is there a way to know if User has stopped using OrbitTool to navigate camera?
      Or some way to know that Mouse Up event occurred, that might help but I'm not sure how to track it.

      I need to know if this event occurred to get transformations of instances whose definitions have always_face_camera flag after the camera has changed. I can do this by listening to ViewObserver but onViewChanged event fires too often.

      [OctaneRender for SketchUp Overview and Demo Version(http://sketchucation.com/click.php?url)]

      Latest updates, tutorials and artwork
      facebook.com/octane4sketchup

      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        You can use the ToolsObserver to detect when the Orbit tool isn't active any more - that would assume the user is using the middle mouse button. To catch when the Orbit tool has explicitly activated the tool you can check if the state changes.

        1 Reply Last reply Reply Quote 0
        • fuzzybroF Offline
          fuzzybro
          last edited by

          Maybe something is wrong, but I don't get any onToolStateChanged messages when using Orbit Tool. I do get them for a move tool though.

          [OctaneRender for SketchUp Overview and Demo Version(http://sketchucation.com/click.php?url)]

          Latest updates, tutorials and artwork
          facebook.com/octane4sketchup

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            Ah! Now that's annoying.

            You could use a timer to defer the event, so that you don't perform actions too quick and merge quick successive view update into one event.

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              Inside your own tool, you use the .resume and .suspend methods. suspend will tell you if the user has started using orbit or pan, and resume will tell you when you are back into your tool.

              http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool.php#resume

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • fuzzybroF Offline
                fuzzybro
                last edited by

                @chris fullmer said:

                Inside your own tool, you use the .resume and .suspend methods. suspend will tell you if the user has started using orbit or pan, and resume will tell you when you are back into your tool.

                http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool.php#resume

                Thanks! Tried that approach. Unfortunately one would need to .resume custom tool manually or by some specific event which I didn't manage to find so I sticked with the time solution.

                [OctaneRender for SketchUp Overview and Demo Version(http://sketchucation.com/click.php?url)]

                Latest updates, tutorials and artwork
                facebook.com/octane4sketchup

                1 Reply Last reply Reply Quote 0
                • fuzzybroF Offline
                  fuzzybro
                  last edited by

                  Thanks, Thom!

                  Solved it using timer to merge quick calls and camera.xaxis to determine if OrbitTool was used

                  
                  class MyViewObserver < Sketchup;;ViewObserver
                  
                    def initialize
                      #used to determine if camera has been rotated around z axis or not
                      @old_xaxis = nil
                      @update_timer_id = -1
                      @update_delay = 0.07 # seconds
                    end
                  
                    def onTimerDone
                      @update_timer_id = -1
                  
                      # DO UPDATE STUFF HERE
                    end
                  
                    def onViewChanged(view)
                      return if !view
                  
                      if camera.xaxis != @old_xaxis
                        UI.stop_timer(@update_timer_id) if @update_timer_id != -1
                        @update_timer_id = ;;UI.start_timer(@update_delay, false) {onTimerDone}
                        @old_xaxis = camera.xaxis
                      end
                  
                    end 
                  
                  end
                  
                  
                  

                  [OctaneRender for SketchUp Overview and Demo Version(http://sketchucation.com/click.php?url)]

                  Latest updates, tutorials and artwork
                  facebook.com/octane4sketchup

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @chris fullmer said:

                    ... suspend will tell you if the user has started using orbit or pan, ...

                    Really? That is news to me. (The API docs do not say this.)

                    AFAIK, a tool's suspend callback is called JUST BEFORE the tool becomes inactive, (so you can save stuff like your tool's state etc.,) and BEFORE the interruptor tool becomes active.

                    Also.. because the Sketchup::Tools collection does not have Enumerable mixed in (and an each method defined,) there is no way to non-destructively read the last tool on the stack, nor even iterate the stack.

                    I'm not here much anymore.

                    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