コード例 #1
0
 def __init__(self, canRender=0):
     self.canRender = canRender
     self.world = OdeWorld()
     self.space = OdeSimpleSpace()
     self.contactgroup = OdeJointGroup()
     self.bodyList = []
     self.geomList = []
     self.massList = []
     self.rayList = []
     self.showContacts = 0
     self.jointMarkers = []
     self.jointMarkerCount = 64
     self.meshDataList = []
     self.geomDataList = []
     self.commonObjectInfoDict = {}
     self.maxColCount = 0
     if self.canRender:
         self.odePandaRelationList = self.bodyList
         self.root = render.attachNewNode('physics root node')
     else:
         self.root = NodePath('physics root node')
     self.placerNode = self.root.attachNewNode('Placer')
     self.subPlacerNode = self.placerNode.attachNewNode('Placer Sub Node')
     self.commonObjectDict = {}
     self.commonId = 0
     self.worldAttach = self.root.attachNewNode('physics geom attach point')
     self.timingCycleLength = 10.0
     self.timingCycleOffset = 0.0
     self.timingSimTime = 0.0
     self.FPS = 60.0
     self.DTAStep = 1.0 / self.FPS
     self.DTA = 0
     self.useQuickStep = False
     self.deterministic = True
     self.numStepsInSimulateTask = 0
コード例 #2
0
    def __init__(self):
        ShowBase.__init__(self)

        dlight = DirectionalLight('dlight')
        dlight.setColor(VBase4(0.8, 0.8, 0.5, 1))
        dlnp = self.render.attachNewNode(dlight)
        dlnp.setHpr(0, -60, 0)
        self.render.setLight(dlnp)

        self.balls = [Ball(self) for x in range(NUMBALLS)]

        # Setup our physics world and the body
        self.world = OdeWorld()
        self.world.setGravity(0, 0, -9.81)
        if 0:
            self.body = OdeBody(self.world)
            M = OdeMass()
            M.setSphere(7874, 1.0)
            self.body.setMass(M)
            self.body.setPosition(self.sphere.getPos(self.render))
            self.body.setQuaternion(self.sphere.getQuat(self.render))

        ## Set the camera position
        self.disableMouse()
        self.angle = 0.0
        self.camera.setPos(1000, 1000, 1000)
        self.camera.lookAt(0, 0, 0)
        #self.enableMouse()
        # Create an accumulator to track the time since the sim
        # has been running
        self.deltaTimeAccumulator = 0.0
        # This stepSize makes the simulation run at 60 frames per second
        self.stepSize = 1.0 / 60.0

        taskMgr.doMethodLater(1.0, self.simulationTask, "Physics Simulation")
コード例 #3
0
    def setup_ODE(self):
        # Setup our physics world
        self.world = OdeWorld()
        self.world.setGravity(0, 0, -9.81)
        self.world.initSurfaceTable(1)
        self.world.setSurfaceEntry(0, 0, 200, 0.7, 0.2, 0.9, 0.00001, 0.0,
                                   0.002)

        self.space = OdeSimpleSpace()
        self.space.setAutoCollideWorld(self.world)
        self.contacts = OdeJointGroup()
        self.space.setAutoCollideJointGroup(self.contacts)
        self.space.setCollisionEvent("on_collision")
コード例 #4
0
    def ode_cols(self):
        world = OdeWorld()
        world.setGravity(0, 0, -9)
        world.initSurfaceTable(1)
        world.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002)

        # Create a space and add a contactgroup to it to add the contact joints
        space = OdeSimpleSpace()
        space.setAutoCollideWorld(world)
        contactgroup = OdeJointGroup()
        space.setAutoCollideJointGroup(contactgroup)
        space.autoCollide()

        #try ODE for collisions
        t_trimesh = OdeTriMeshData(self.terrain.getRoot(), True)
        t_geom = OdeTriMeshGeom(space, t_trimesh)
コード例 #5
0
    def __init__(self, world):
        self.world = world
        self.world.objs = []
        self.world.spheres = []
        self.world.joints = []

        self.world.myWorld = OdeWorld()

        zapolnenie(self.world, 15, 10, 15)

        self.world.deltaTimeAccumulator = 0.0
        self.world.stepSize = 1.0 / 90.0

        self.accept('g-up', self.up)
        self.accept('g', self.press)

        self.g_pressed = False
        self.world.taskMgr.doMethodLater(1.0, self.simulationTask,
                                         'Physics Simulation')
コード例 #6
0
    def setupODE(self,*args,**kw):
        if self.world is None :
            if panda3d is None :
                return
            from panda3d.core import loadPrcFileData            
            loadPrcFileData("", "window-type none" ) 
            # Make sure we don't need a graphics engine 
            #(Will also prevent X errors / Display errors when starting on linux without X server)
            loadPrcFileData("", "audio-library-name null" ) # Prevent ALSA errors 
#            loadPrcFileData('', 'bullet-enable-contact-events true')
#            loadPrcFileData('', 'bullet-max-objects 50')#10240
            
            import direct.directbase.DirectStart 
#            bullet.bullet-max-objects = 1024 * 10#sum of all predicted n Ingredient ?
#            self.worldNP = render.attachNewNode('World')            
            self.world = OdeWorld()
            self.world.setGravity(Vec3(0, 0, 0))
            self.static=[]
            self.moving = None
            self.rb_panda = []
            return self.world
コード例 #7
0
sphere_a = cm.gen_sphere(radius=radius)
sphere_a.set_pos([0, .3, -.3])
sphere_a.set_rgba([1, .2, .3, 1])
sphere_a.attach_to(base)

sphere_b = cm.gen_sphere(radius=radius)
sphere_b.set_pos([0, 1.25, -.7])
sphere_b.set_rgba([.3, .2, 1, 1])
sphere_b.attach_to(base)

gm.gen_linesegs([[np.zeros(3), sphere_a.get_pos()]], thickness=.05, rgba=[0, 1, 0, 1]).attach_to(base)
gm.gen_linesegs([[sphere_a.get_pos(), sphere_b.get_pos()]], thickness=.05, rgba=[0, 0, 1, 1]).attach_to(base)

# Setup our physics world and the body
world = OdeWorld()
world.setGravity(0, 0, -9.81)

body_sphere_a = OdeBody(world)
M = OdeMass()
M.setSphere(7874, radius)
body_sphere_a.setMass(M)
body_sphere_a.setPosition(da.npv3_to_pdv3(sphere_a.get_pos()))

body_sphere_b = OdeBody(world)
M = OdeMass()
M.setSphere(7874, radius)
body_sphere_b.setMass(M)
body_sphere_b.setPosition(da.npv3_to_pdv3(sphere_b.get_pos()))

# Create the joints