Example #1
0
    def remove(self, objs):
        """Remove a world object from the simulation.

        \param objs World objects to be simulated (given as names or objects)
        """
        #~ print "Removing...", objs
        objs = cmds.worldObjects(objs)
        for obj in objs:
            #~ print obj.name
            self._remove(obj)
Example #2
0
def remove(objs):
    objs = cmds.worldObjects(objs)
    
    for o in objs:
        for c in o.iterChilds():
            remove(c)
        for s in getScene().items:
            if type(s) == ODEDynamics:
                try: s.remove(o)
                except: pass
            if type(s) == cgkit._core.WorldObject:
                try: s.removeChild(o)
                except: pass
Example #3
0
    def add(self, objs, categorybits=None, collidebits=None):
        """Add a world object to the simulation.

        \param objs World objects to be simulated (given as names or objects)
        """
        objs = cmds.worldObjects(objs)
        for obj in objs:
            if obj.mass <= 0 and not isinstance(obj, cgkit.odedynamics.ODEJointBase):
                print "Using default mass=1 for " + str(obj)
                obj.mass = 1
            self._add(obj, categorybits, collidebits)
            if obj in self.body_dict:
                obj.odebody = self.body_dict[obj].odebody
                obj.odegeoms = self.body_dict[obj].odegeoms 
                manip = self.createBodyManipulator(obj)
                if manip != None:
                    obj.manip = manip