Dave Schuyler 20 years ago
parent
commit
c367444488
1 changed files with 8 additions and 71 deletions
  1. 8 71
      direct/src/controls/GravityWalker.py

+ 8 - 71
direct/src/controls/GravityWalker.py

@@ -517,42 +517,6 @@ class GravityWalker(DirectObject.DirectObject):
                           Vec3.right() * slideDistance)
                           Vec3.right() * slideDistance)
             if self.vel != Vec3.zero() or self.priorParent != Vec3.zero():
             if self.vel != Vec3.zero() or self.priorParent != Vec3.zero():
                 if 0:
                 if 0:
-                    # rotMat is the rotation matrix corresponding to
-                    # our previous heading.
-                    rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
-                    step=(self.priorParent * dt) + rotMat.xform(self.vel)
-                    self.avatarNodePath.setFluidPos(Point3(
-                            self.avatarNodePath.getPos()+step))
-                if 0:
-                    # rotMat is the rotation matrix corresponding to
-                    # our previous heading.
-                    rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), self.lifter.getContactNormal())
-                    step=rotMat.xform(self.vel) + (self.priorParent * dt)
-                    self.avatarNodePath.setFluidPos(Point3(
-                            self.avatarNodePath.getPos()+step))
-                if 0:
-                    # rotMat is the rotation matrix corresponding to
-                    # our previous heading.
-                    rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
-                    forward = Vec3(rotMat.xform(Vec3.forward()))
-                    up      = Vec3(rotMat.xform(self.lifter.getContactNormal()))
-                    rotMat2=Mat3()
-                    headsUp(rotMat2, forward, up)
-                    #rotMat2=Mat3.rotateMatNormaxis(0.0, )
-                    step=rotMat2.xform(self.vel) + (self.priorParent * dt)
-                    if 0:
-                        onScreenDebug.add("a getH()", self.avatarNodePath.getH())
-                        onScreenDebug.add("a forward", forward.pPrintValues())
-                        onScreenDebug.add("a up", up.pPrintValues())
-                        onScreenDebug.add("a Vec3.forward()", Vec3.forward().pPrintValues())
-                        onScreenDebug.add("a Vec3.up()", Vec3.up().pPrintValues())
-                        onScreenDebug.add("a Vec3.right()", Vec3.right().pPrintValues())
-                        onScreenDebug.add("a contactNormal()", self.lifter.getContactNormal().pPrintValues())
-                        onScreenDebug.add("a rotMat", rotMat.pPrintValues())
-                        onScreenDebug.add("a rotMat2", rotMat2.pPrintValues())
-                    self.avatarNodePath.setFluidPos(Point3(
-                            self.avatarNodePath.getPos()+step))
-                if 1:
                     # rotMat is the rotation matrix corresponding to
                     # rotMat is the rotation matrix corresponding to
                     # our previous heading.
                     # our previous heading.
                     rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
                     rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
@@ -564,47 +528,20 @@ class GravityWalker(DirectObject.DirectObject):
                     step=self.vel + (self.priorParent * dt)
                     step=self.vel + (self.priorParent * dt)
                     self.avatarNodePath.setFluidPos(Point3(
                     self.avatarNodePath.setFluidPos(Point3(
                             self.avatarNodePath.getPos()+step))
                             self.avatarNodePath.getPos()+step))
-                if 0:
+                if 1:
                     # rotMat is the rotation matrix corresponding to
                     # rotMat is the rotation matrix corresponding to
                     # our previous heading.
                     # our previous heading.
                     rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
                     rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
-                    forward = Vec3(rotMat.xform(Vec3.forward()))
-                    right   = Vec3(rotMat.xform(Vec3.right()))
-                    up      = Vec3(rotMat.xform(self.lifter.getContactNormal()))
-                    rotMat2=Mat3()
-                    headsUp(rotMat2, up, right)
-                    newForward = Vec3(rotMat2.xform(Vec3.right()))
-                    newRight = Vec3(rotMat2.xform(Vec3.up()))
-                    if 1:
-                        onScreenDebug.add("a getH()", self.avatarNodePath.getH())
-                        onScreenDebug.add("a forward", forward.pPrintValues())
-                        onScreenDebug.add("a up", up.pPrintValues())
-                        onScreenDebug.add("a Vec3.forward()", Vec3.forward().pPrintValues())
-                        onScreenDebug.add("a Vec3.up()", Vec3.up().pPrintValues())
-                        onScreenDebug.add("a Vec3.right()", Vec3.right().pPrintValues())
-                        onScreenDebug.add("a contactNormal()", self.lifter.getContactNormal().pPrintValues())
-                        onScreenDebug.add("a rotMat", rotMat.pPrintValues())
-                        onScreenDebug.add("a rotMat2", rotMat2.pPrintValues())
-                        onScreenDebug.add("b newForward", newForward.pPrintValues())
-                        onScreenDebug.add("b newRight", newRight.pPrintValues())
-                    self.vel=Vec3(newForward * distance +
-                                newRight * slideDistance)
+                    forward = self.lifter.getContactNormal().cross(Vec3.right())
+                    forward = Vec3(rotMat.xform(forward))
+                    self.vel=Vec3(forward * distance)
+                    if slideDistance:
+                        right   = forward.cross(self.lifter.getContactNormal())
+                        right   = Vec3(rotMat.xform(Vec3.right()))
+                        self.vel=Vec3(self.vel + right * slideDistance)
                     step=self.vel + (self.priorParent * dt)
                     step=self.vel + (self.priorParent * dt)
                     self.avatarNodePath.setFluidPos(Point3(
                     self.avatarNodePath.setFluidPos(Point3(
                             self.avatarNodePath.getPos()+step))
                             self.avatarNodePath.getPos()+step))
-                if 0:
-                    # rotMat is the rotation matrix corresponding to
-                    # our previous heading.
-                    rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
-                    forward = Vec3(rotMat.xform(Vec3.forward()))
-                    up      = Vec3(rotMat.xform(self.lifter.getContactNormal()))
-                    rotMat2=Mat3()
-                    forward.setZ(forward.getZ() * up.getZ())
-                    #rotMat2=Mat3.rotateMatNormaxis(0.0, )
-                    #step=rotMat2.xform(self.vel) + (self.priorParent * dt)
-                    step=rotMat.xform(self.vel) + (self.priorParent * dt)
-                    self.avatarNodePath.setFluidPos(Point3(
-                            self.avatarNodePath.getPos()+step))
             self.avatarNodePath.setH(self.avatarNodePath.getH()+rotation)
             self.avatarNodePath.setH(self.avatarNodePath.getH()+rotation)
         else:
         else:
             self.vel.set(0.0, 0.0, 0.0)
             self.vel.set(0.0, 0.0, 0.0)