# DizziCamera v1.1 # Rotate/Translate the current camera # X/Y-rotate the currently selected camera when pressing Control/Command and moving the mouse # X/Y-translate the currently selected camera when pressing Control/Command + Shift and moving the mouse # Z-translate the currently selected camera when pressing Control/Command + Alt and moving the mouse # - Python coding by Dizzi import poser import wx.aui class DizziCamera(wx.Window): def __init__(self, parent, title, pane): wx.Window.__init__(self, parent) self.manager=poser.WxAuiManager().GetManagedWindow() self.DoBind(self.manager,"") def EvtKeyDown(self, event): # if you want to disable the return key... uncomment the next line (remove the #) #if (event.KeyCode == wx.WXK_RETURN or event.KeyCode == wx.WXK_NUMPAD_ENTER): return # for keycodes see: http://wxpython.org/docs/api/wx.KeyEvent-class.html # you can also check for Modifier Keys: # event.CommandDown() - Control on PC, Command on MAC # event.ShiftDown() # event.AltDown() # event.MetaDown() - MAC # # uncomment the following line (remove #) to find out a keycode for anything else you want to stop... #print event.KeyCode event.Skip() lastPosition=None def EvtMotion(self, event): obj=event.GetEventObject() position=obj.ClientToScreen(event.GetPosition()) if event.CmdDown(): if self.lastPosition: x=position.x-self.lastPosition.x y=position.y-self.lastPosition.y if event.ShiftDown(): type1=poser.kParmCodeXTRAN type2=poser.kParmCodeYTRAN multi=0.01 elif event.AltDown(): type1=None type2=poser.kParmCodeZTRAN multi=0.01 else: type1=poser.kParmCodeYROT type2=poser.kParmCodeXROT multi=0.2 try: cam=poser.Scene().CurrentCamera() if type1: param=cam.ParameterByCode(type1) param.SetValue(param.Value()-x*multi) if type2: param=cam.ParameterByCode(type2) param.SetValue(param.Value()-y*multi) except: pass self.lastPosition=position # event.Skip() def __del__(self): self.RemoveEvents() def RemoveEvents(self): self.DoUnbind(self.manager) def DoBind(self, win, level): win.Bind(wx.EVT_KEY_DOWN, self.EvtKeyDown) win.Bind(wx.EVT_MOTION, self.EvtMotion) #print level+win.Name for child in win.Children: self.DoBind(child, level+">") def DoUnbind(self, win): if win: win.Unbind(wx.EVT_KEY_DOWN) win.Unbind(wx.EVT_MOTION) for child in win.Children: try: self.DoUnbind(child) except: pass try: dizziCamera.RemoveEvents() except: pass name = "Dizzi's Camera" man = poser.WxAuiManager() root = man.GetManagedWindow() pane = wx.aui.AuiPaneInfo() pane.Caption(name).CaptionVisible().CloseButton().Resizable().DestroyOnClose() pane.BestSize(wx.Size(50, 50)).Right().PinButton().Hide() win = DizziCamera(root, name, pane) man.AddPane(win, pane) man.Update()