def processUIAction(self, action, state): s = pymjin2.State() if (action == "ToggleMove"): self.enableRotation = state s.set("mouse.visible", "0" if self.enableRotation else "1") # Disable all movement. if (not self.enableRotation): s.set("camera.moveBackward", "0") s.set("camera.moveDown", "0") s.set("camera.moveForward", "0") s.set("camera.moveLeft", "0") s.set("camera.moveRight", "0") s.set("camera.moveUp", "0") if (self.enableRotation): postfix = None if (action == "MoveBackward"): postfix = "Backward" elif (action == "MoveDown"): postfix = "Down" elif (action == "MoveForward"): postfix = "Forward" elif (action == "MoveLeft"): postfix = "Left" elif (action == "MoveRight"): postfix = "Right" elif (action == "MoveUp"): postfix = "Up" if (postfix): s.set("camera.move" + postfix , "1" if state else "0") self.core.wnd.setState(s)
def step(self, dt): st = pymjin2.State() st.set("script.{0}.customDelay.active".format(self.groupName), "1") print "RunCustomDelay. 01.launching CustomDelay" self.action.setState(st) print "RunCustomDelay. 02.launching CustomDelay" return False
def centerMouse(self): s = pymjin2.State() s.set("mouse.position", self.center) v = self.center.split(" ") self.lastX = int(v[0]) self.lastY = int(v[1]) self.parent.core.wnd.setState(s)
def sync(self, value=None): newValue = value if (newValue is None): st = self.core.dscene.state([self.key]) newValue = st.value(self.key)[0] st = pymjin2.State() st.add("uniforms.lightPos", newValue) self.core.mainCompositor.setState(st)
def step(self, dt): self.calls = self.calls + 1 materialID = self.calls % 3 st = pymjin2.State() key = "node.{0}.{1}.material".format(self.sceneName, self.nodeName) value = self.materials[materialID] #print key, value st.set(key, value) self.scene.setState(st) return False
def syncNodeWithCamera(self, posValue = None, rotValue = None): # Position. newPosValue = posValue if (newPosValue is None): st = self.core.dscene.state([self.keyPos]) newPosValue = st.value(self.keyPos)[0] # Rotation. newRotValue = rotValue if (newRotValue is None): st = self.core.dscene.state([self.keyRot]) newRotValue = st.value(self.keyRot)[0] st = pymjin2.State() st.add(self.keyPos, newPosValue) st.add(self.keyRot, newRotValue) self.ignoreCameraSync = True self.core.dscene.setState(st) self.ignoreCameraSync = False
def selectNode(self, nodeName): print "Main: node selected. BEGIN", nodeName if (nodeName == self.nodeName): print "Main: PARENT node selected. Do nothing. END", nodeName return # st = pymjin2.State() # key = "node.{0}.{1}.script".format(self.sceneName, nodeName) # st.set(key, "scripts/TrackNodeLifeTime.py") # self.scene.setState(st) print "Main: launching 'fastMain' action" st = pymjin2.State() st.set("speed.default.fastMain.active", "1") # print "Main: changing 'script' property" # st.set("script.default.printAnything.script", "scripts/actions/PrintEverything.py") # self.action.setState(st) print "Main: node selected. END", nodeName
def syncCameraWithNode(self, posValue = None, rotValue = None): if (self.ignoreCameraSync): return; # Position. newPosValue = posValue if (newPosValue is None): st = self.core.dscene.state([self.keyPos]) newPosValue = st.value(self.keyPos)[0] # Rotation. newRotValue = rotValue if (newRotValue is None): st = self.core.dscene.state([self.keyRot]) newRotValue = st.value(self.keyRot)[0] # Application. st = pymjin2.State() st.add("camera.position", newPosValue) st.add("camera.rotationq", newRotValue) self.core.wnd.setState(st)