Ejemplo n.º 1
0
    def create(self):
        """Creates the instant character based on the available description. Attach a reasonable controller, if available."""
        app = wx.GetApp()

        try:
            wrappedController = PyUtils.wrapCopy(app.getController(0))
        except IndexError:
            wrappedController = None

        try:
            character = app.getCharacter(0)
            previousMass = character.getMass()
        except IndexError:
            previousMass = None

        app.deleteAllObjects()
        PyUtils.load("RigidBodies.FlatGround")
        character = self._characterDescription.createCharacter()
        character.computeMass()
        app.addCharacter(character)

        if wrappedController is not None:
            controller = wrappedController.createAndFillObject(None, character)
            if previousMass is not None:
                massRatio = character.getMass() / previousMass
                controller.scaleGains(massRatio)
            app.addController(controller)
            controller.setStance(Core.LEFT_STANCE)
            self.connectController()

        return character
    def create(self):
        """Creates the instant character based on the available description. Attach a reasonable controller, if available."""       
        app = wx.GetApp()
        
        try:
            wrappedController = PyUtils.wrapCopy( app.getController(0) )
        except IndexError:
            wrappedController = None
                
        try:
            character = app.getCharacter(0)
            previousMass = character.getMass()
        except IndexError:
            previousMass = None
        
        
        app.deleteAllObjects()
        PyUtils.load( "RigidBodies.FlatGround" )
        character = self._characterDescription.createCharacter()
        character.computeMass()
        app.addCharacter(character)

        if wrappedController is not None:
            controller = wrappedController.createAndFillObject(None, character)
            if previousMass is not None:
                massRatio = character.getMass() / previousMass
                controller.scaleGains( massRatio )
            app.addController(controller)
            controller.setStance( Core.LEFT_STANCE )
            self.connectController()
        
        return character
    def __init__(self, parentBranch):
        """Takes a shot of a world, add it to the specified branch."""
        super(Snapshot,self).__init__()

        self._time = time.localtime()
        
        # Save the world
        world = Physics.world()
        self._worldState = Utils.DynamicArrayDouble() 
        world.getState( self._worldState )
        
        # Save the controllers
        app = wx.GetApp()        
        self._controllers = []
        for i in range(app.getControllerCount()):
            controller = app.getController(i)
            controllerState = Core.SimBiControllerState()
            controller.getControllerState( controllerState )
            self._controllers.append( (controllerState, PyUtils.wrapCopy( controller )) )

        self._parentBranch = parentBranch
        self._childBranches = []
        self._activeIndex = -1                
Ejemplo n.º 4
0
    def __init__(self, parentBranch):
        """Takes a shot of a world, add it to the specified branch."""
        super(Snapshot, self).__init__()

        self._time = time.localtime()

        # Save the world
        world = Physics.world()
        self._worldState = Utils.DynamicArrayDouble()
        world.getState(self._worldState)

        # Save the controllers
        app = wx.GetApp()
        self._controllers = []
        for i in range(app.getControllerCount()):
            controller = app.getController(i)
            controllerState = Core.SimBiControllerState()
            controller.getControllerState(controllerState)
            self._controllers.append(
                (controllerState, PyUtils.wrapCopy(controller)))

        self._parentBranch = parentBranch
        self._childBranches = []
        self._activeIndex = -1