比較バージョン

キー

  • この行は追加されました。
  • この行は削除されました。
  • 書式設定が変更されました。

Welcome to Atoms Crowd blog! In this blog we are going to post some interesting articles to show you how you can work with Atoms.

...

  1. Copy the xbox.pyd inside your python path. (i.e. <drive>:\Documents and Settings\<username>\My Documents\maya\<Version>\scripts )
  2. Open the Atoms UI, create a new behaviour module and copy the content of the Xbox controller module in the editor. Click register.
  3. Create a new agent group, add a gridLayout module, a stateMachine module and the XBoxControllerModule .
  4. Set the time line frame range to 1 - 2000 .
  5. Copy the content of the Xbox module recorder in the script editor and run it.
  6. Click "Start".
  7. Use the Xbox controller to drive the agent.
  8. Click "Stop".

...

This is a simple PySide UI for starting/stopping the recording. Please make sure to have the agent group transform selected before running this script.

コード ブロック
languagepy
linenumberstrue
import AtomsMaya
import maya


from PySide2 import QtWidgets, QtCore, QtGui

class XboxControllerModuleWidget(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(XboxControllerModuleWidget, self).__init__(parent)
        self.ag_name = maya.cmds.ls(sl=1,dag=1,lf=1,shapes=1)[0]
        self.v_layout = QtWidgets.QVBoxLayout()
        self.start = QtWidgets.QPushButton("Start")
        self.stop = QtWidgets.QPushButton("Stop")
        self.v_layout.addWidget(self.start)
        self.v_layout.addWidget(self.stop)        
        self.setLayout(self.v_layout)
        
        self.start.clicked.connect(self._start)
        self.stop.clicked.connect(self._stop)
        self.start.setEnabled(True)
        self.stop.setEnabled(False)
        
    def _start(self):
        ag_name = self.ag_name
        maya.cmds.setAttr(ag_name + ".atoms_XBoxControllerModule_record",1)
        maya.mel.eval("playButtonStart;")
        maya.mel.eval("playButtonForward;")
        self.start.setEnabled(False)
        self.stop.setEnabled(True)
        
    def _stop(self):
        ag_name = self.ag_name
        ag = AtomsMaya.getAgentGroup(ag_name)
        mod = ag.behaviourModule("XBoxControllerModule")
        mod.endSimulation(ag.agents(), ag)
        maya.cmds.setAttr(ag_name + ".atoms_XBoxControllerModule_record",0)
        maya.mel.eval("playButtonForward;")
        self.start.setEnabled(True)
        self.stop.setEnabled(False)
        
w = XboxControllerModuleWidget()
w.show()        

...