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