Browse Source

draft version

Dave Schuyler 21 years ago
parent
commit
0434436a24

+ 33 - 0
direct/src/directbase/TestStart.py

@@ -0,0 +1,33 @@
+print 'TestStart: Starting up test environment.'
+
+from pandac.PandaModules import *
+
+from direct.showbase.PythonUtil import *
+from direct.showbase import ShowBase
+ShowBase.ShowBase()
+
+# Put an axis in the world:
+loader.loadModelCopy("models/misc/xyzAxis").reparentTo(render)
+
+if 0:
+    # Hack:
+    # Enable drive mode but turn it off, and reset the camera
+    # This is here because ShowBase sets up a drive interface, this
+    # can be removed if ShowBase is changed to not set that up.
+    base.useDrive()
+    base.disableMouse()
+    if base.mouseInterface:
+        base.mouseInterface.reparentTo(base.dataUnused)
+    if base.mouse2cam:
+        base.mouse2cam.reparentTo(base.dataUnused)
+    # end of hack.
+
+camera.setPosHpr(0, -10.0, 0, 0, 0, 0)
+base.camLens.setFov(52.0)
+base.camLens.setNearFar(1.0, 10000.0)
+
+globalClock.setMaxDt(0.2)
+base.enableParticles()
+
+# Force the screen to update:
+base.graphicsEngine.renderFrame()

+ 35 - 0
direct/src/directbase/ThreeUpStart.py

@@ -0,0 +1,35 @@
+
+print 'ThreeUpStart: Starting up environment.'
+
+from pandac.PandaModules import *
+
+from direct.showbase.PythonUtil import *
+from direct.showbase import ThreeUpShow
+ThreeUpShow.ThreeUpShow()
+
+# Put an axis in the world:
+loader.loadModelCopy("models/misc/xyzAxis").reparentTo(render)
+
+if 0:
+    # Hack:
+    # Enable drive mode but turn it off, and reset the camera
+    # This is here because ShowBase sets up a drive interface, this
+    # can be removed if ShowBase is changed to not set that up.
+    base.useDrive()
+    base.disableMouse()
+    if base.mouseInterface:
+        base.mouseInterface.reparentTo(base.dataUnused)
+    if base.mouse2cam:
+        base.mouse2cam.reparentTo(base.dataUnused)
+    # end of hack.
+
+camera.setPosHpr(0, -10.0, 0, 0, 0, 0)
+base.camLens.setFov(52.0)
+base.camLens.setNearFar(1.0, 10000.0)
+
+globalClock.setMaxDt(0.2)
+base.enableParticles()
+base.addAngularIntegrator()
+
+# Force the screen to update:
+base.graphicsEngine.renderFrame()

+ 84 - 0
direct/src/physics/FallTest.py

@@ -0,0 +1,84 @@
+from direct.directbase.ThreeUpStart import *
+
+class FallTest(NodePath):
+    def __init__(self):
+        NodePath.__init__(self, "FallTest")
+
+    def setup(self):
+        # Connect to Physics Manager:
+        self.actorNode=ActorNode("FallTestActorNode")
+        #self.actorNode.getPhysicsObject().setOriented(1)
+        #self.actorNode.getPhysical(0).setViscosity(0.1)
+        
+        actorNodePath=self.attachNewNode(self.actorNode)
+        #self.setPos(avatarNodePath, Vec3(0))
+        #self.setHpr(avatarNodePath, Vec3(0))
+
+        avatarNodePath=loader.loadModelCopy("models/misc/smiley")
+        assert not avatarNodePath.isEmpty()
+        
+        camLL=render.find("**/camLL")
+        camLL.reparentTo(avatarNodePath)
+        camLL.setPosHpr(0, -10, 0, 0, 0, 0)
+        avatarNodePath.reparentTo(actorNodePath)
+        #avatarNodePath.setPos(Vec3(0))
+        #avatarNodePath.setHpr(Vec3(0))
+        #avatarNodePath.assign(physicsActor)
+        #self.phys=PhysicsManager()
+        self.phys=base.physicsMgr
+
+        if 1:
+            fn=ForceNode("FallTest gravity")
+            fnp=NodePath(fn)
+            fnp.reparentTo(self)
+            fnp.reparentTo(render)
+            gravity=LinearVectorForce(0.0, 0.0, -.5)
+            fn.addForce(gravity)
+            self.phys.addLinearForce(gravity)
+            self.gravity = gravity
+
+        if 0:
+            fn=ForceNode("FallTest viscosity")
+            fnp=NodePath(fn)
+            fnp.reparentTo(self)
+            fnp.reparentTo(render)
+            self.avatarViscosity=LinearFrictionForce(0.0, 1.0, 0)
+            #self.avatarViscosity.setCoef(0.9)
+            fn.addForce(self.avatarViscosity)
+            self.phys.addLinearForce(self.avatarViscosity)
+
+        if 0:
+            self.phys.attachLinearIntegrator(LinearEulerIntegrator())
+        if 0:
+            self.phys.attachAngularIntegrator(AngularEulerIntegrator())
+        #self.phys.attachPhysicalnode(self.node())
+        self.phys.attachPhysicalnode(self.actorNode)
+
+        if 0:
+            self.momentumForce=LinearVectorForce(0.0, 0.0, 0.0)
+            fn=ForceNode("FallTest momentum")
+            fnp=NodePath(fn)
+            fnp.reparentTo(render)
+            fn.addForce(self.momentumForce)
+            self.phys.addLinearForce(self.momentumForce)
+
+        if 0:
+            self.acForce=LinearVectorForce(0.0, 0.0, 0.0)
+            fn=ForceNode("FallTest avatarControls")
+            fnp=NodePath(fn)
+            fnp.reparentTo(render)
+            fn.addForce(self.acForce)
+            self.phys.addLinearForce(self.acForce)
+            #self.phys.removeLinearForce(self.acForce)
+            #fnp.remove()
+
+        #avatarNodePath.reparentTo(render)
+        self.avatarNodePath = avatarNodePath
+        #self.actorNode.getPhysicsObject().resetPosition(self.avatarNodePath.getPos())
+        #self.actorNode.updateTransform()
+
+test=FallTest()
+test.reparentTo(render)
+test.setup()
+camera.setY(-10.0)
+run()

+ 94 - 0
direct/src/physics/RotationTest.py

@@ -0,0 +1,94 @@
+from direct.directbase.ThreeUpStart import *
+
+class RotationTest(NodePath):
+    def __init__(self):
+        NodePath.__init__(self, "RotationTest")
+
+    def setup(self):
+        # Connect to Physics Manager:
+        self.actorNode=ActorNode("RotationTestActorNode")
+        #self.actorNode.getPhysicsObject().setOriented(1)
+        #self.actorNode.getPhysical(0).setViscosity(0.1)
+        
+        actorNodePath=self.attachNewNode(self.actorNode)
+        #self.setPos(avatarNodePath, Vec3(0))
+        #self.setHpr(avatarNodePath, Vec3(0))
+
+        avatarNodePath=loader.loadModelCopy("models/misc/smiley")
+        assert not avatarNodePath.isEmpty()
+        
+        camLL=render.find("**/camLL")
+        camLL.reparentTo(avatarNodePath)
+        camLL.setPosHpr(0, -10, 0, 0, 0, 0)
+        avatarNodePath.reparentTo(actorNodePath)
+        #avatarNodePath.setPos(Vec3(0))
+        #avatarNodePath.setHpr(Vec3(0))
+        #avatarNodePath.assign(physicsActor)
+        #self.phys=PhysicsManager()
+        self.phys=base.physicsMgr
+
+        if 0:
+            fn=ForceNode("RotationTest gravity")
+            fnp=NodePath(fn)
+            fnp.reparentTo(self)
+            fnp.reparentTo(render)
+            gravity=LinearVectorForce(0.0, 0.0, -.5)
+            fn.addForce(gravity)
+            self.phys.addLinearForce(gravity)
+            self.gravity = gravity
+
+        if 1:
+            fn=ForceNode("RotationTest spin")
+            fnp=NodePath(fn)
+            fnp.reparentTo(self)
+            fnp.reparentTo(render)
+            spin=AngularVectorForce(0.0, 0.0, 0.5)
+            fn.addForce(spin)
+            self.phys.addAngularForce(spin)
+            self.spin = spin
+
+        if 0:
+            fn=ForceNode("RotationTest viscosity")
+            fnp=NodePath(fn)
+            fnp.reparentTo(self)
+            fnp.reparentTo(render)
+            self.avatarViscosity=LinearFrictionForce(0.0, 1.0, 0)
+            #self.avatarViscosity.setCoef(0.9)
+            fn.addForce(self.avatarViscosity)
+            self.phys.addLinearForce(self.avatarViscosity)
+
+        if 0:
+            self.phys.attachLinearIntegrator(LinearEulerIntegrator())
+        if 0:
+            self.phys.attachAngularIntegrator(AngularEulerIntegrator())
+        #self.phys.attachPhysicalnode(self.node())
+        self.phys.attachPhysicalnode(self.actorNode)
+
+        if 0:
+            self.momentumForce=LinearVectorForce(0.0, 0.0, 0.0)
+            fn=ForceNode("RotationTest momentum")
+            fnp=NodePath(fn)
+            fnp.reparentTo(render)
+            fn.addForce(self.momentumForce)
+            self.phys.addLinearForce(self.momentumForce)
+
+        if 0:
+            self.acForce=LinearVectorForce(0.0, 0.0, 0.0)
+            fn=ForceNode("RotationTest avatarControls")
+            fnp=NodePath(fn)
+            fnp.reparentTo(render)
+            fn.addForce(self.acForce)
+            self.phys.addLinearForce(self.acForce)
+            #self.phys.removeLinearForce(self.acForce)
+            #fnp.remove()
+
+        #avatarNodePath.reparentTo(render)
+        self.avatarNodePath = avatarNodePath
+        #self.actorNode.getPhysicsObject().resetPosition(self.avatarNodePath.getPos())
+        #self.actorNode.updateTransform()
+
+test=RotationTest()
+test.reparentTo(render)
+test.setup()
+camera.setY(-10.0)
+run()

+ 0 - 0
direct/src/physics/__init__.py