# DizziCamera v1.2 # Rotate/Translate the current camera # X/Y-rotate the currently selected camera when pressing Shift and moving the mouse # X/Y-translate the currently selected camera when pressing Control/Command and moving the mouse # Z-translate the currently selected camera when pressing Shift + Control/Command and moving the mouse # - Python coding by Dizzi import poser import wx.aui class DizziCamera(wx.Window): def __init__(self, parent, title, pane, name): wx.Window.__init__(self, parent, name=name) self.managedWindow=parent self.SetEvents() 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 EvtMouse(self, event): type=event.GetEventType() obj=event.GetEventObject() if type in wx.EVT_MOTION.evtType: position=obj.ClientToScreen(event.GetPosition()) doWork=event.CmdDown() or event.ShiftDown() if doWork: if self.lastPosition: x=position.x-self.lastPosition.x y=position.y-self.lastPosition.y if event.CmdDown() and event.ShiftDown(): type1=None type2=poser.kParmCodeZTRAN multi1=0.01 multi2=-0.01 elif event.CmdDown(): type1=poser.kParmCodeXTRAN type2=poser.kParmCodeYTRAN multi1=-0.01 multi2=0.01 elif event.ShiftDown(): type1=poser.kParmCodeYROT type2=poser.kParmCodeXROT multi1=0.2 multi2=0.2 try: cam=poser.Scene().CurrentCamera() if type1: param=cam.ParameterByCode(type1) param.SetValue(param.Value()-x*multi1) if type2: param=cam.ParameterByCode(type2) param.SetValue(param.Value()-y*multi2) except: pass if not self.HasCapture(): self.CaptureMouse() self.lastPosition=position if doWork: return elif not (type in wx.EVT_ENTER_WINDOW.evtType or type in wx.EVT_LEAVE_WINDOW.evtType) and self.HasCapture(): self.ReleaseMouse() event.Skip() def __del__(self): self.RemoveEvents() def RemoveEvents(self): for win in self.GetBindWindows(): win.Unbind(wx.EVT_KEY_DOWN) win.Unbind(wx.EVT_MOUSE_EVENTS) def SetEvents(self): for win in self.GetBindWindows(): win.Bind(wx.EVT_KEY_DOWN, self.EvtKeyDown) win.Bind(wx.EVT_MOUSE_EVENTS, self.EvtMouse) def GetBindWindows(self): l=[self] for child in self.managedWindow.Children: if child.Name=='ScenePalette': self.GetBindWindowsRec(child, l) return l def GetBindWindowsRec(self, win, l): for child in win.Children: if child.Name=='PoserGLCanvas': l.append(child) else: self.GetBindWindowsRec(child, l) def Exists(win, name): for child in win.Children: if child.Name==name: return True return False name = "Dizzi's Camera" man = poser.WxAuiManager() root = man.GetManagedWindow() if not Exists(root, name): 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, name) man.AddPane(win, pane) man.Update()