Interacting with Physx

This example shows how you can use a simulation event to interact with Physx rigid bodies.

import Atoms
import AtomsCore
import AtomsMath
import AtomsMaya
import os

class PhysxSimEvent(Atoms.SimulationEvent):
    eventName = 'PhysxSimEvent'

    def __init__(self):
        Atoms.SimulationEvent.__init__(self)
        self.setName(self.eventName)

    def load(self):
        pass

    def unload(self):
        pass

    def initSimulation(self):
        pass

    def initFrame(self):
        pass

    def computeFrame(self):
        physx = AtomsMaya.getPhysics("tcAtomsSolver")
        for id in physx.rigidBodyIds():
            print id
            rb = physx.rigidBody(id)
            rb.addImpulse(AtomsMath.V3f(0,10,0))

    def endFrame(self):
        pass

    def endSimulation(self):
        pass

    def resetSimulation(self):
        pass

Copyright © 2017, Toolchefs LTD.