Пример #1
0
    def mouseDelta(self, dx, dy):
        camPos = base.camera.getPos() - self._pos
        r, theta, phi = g2scoord(camPos)

        if self._invert:
            dy = -dy
        dx = -dx

        theta += dy * self._sensitivity
        phi += dx * self._sensitivity

        while theta > pi:
            theta = pi - 0.0001
        while theta < 0:
            theta = 0.0001

        while phi > pi2:
            phi -= pi2

        while phi < 0:
            phi += pi2

        x, y, z = s2gcoord(r, theta, phi)

        base.camera.setPos(Point3(x, y, z) + self._pos)
        base.camera.lookAt(self._pos)

        self._cameraMoved = True
Пример #2
0
  def mouseDelta(self, dx, dy):
    camPos = base.camera.getPos() - self._pos
    r, theta, phi = g2scoord(camPos)

    if self._invert:
      dy = -dy
    dx = -dx

    theta += dy * self._sensitivity
    phi += dx * self._sensitivity

    while theta > pi:
      theta = pi - 0.0001
    while theta < 0:
      theta = 0.0001

    while phi > pi2:
      phi -= pi2

    while phi < 0:
      phi += pi2

    x, y, z = s2gcoord(r, theta, phi)

    base.camera.setPos(Point3(x, y, z) + self._pos)
    base.camera.lookAt(self._pos)

    self._cameraMoved = True
Пример #3
0
    def recalculatePosition(self):
        camPos = base.camera.getPos() - self._pos
        _, theta, phi = g2scoord(camPos)
        x, y, z = s2gcoord(self._distance, theta, phi)

        base.camera.setPos(Point3(x, y, z) + self._pos)
        base.camera.lookAt(self._pos)
        self._cameraMoved = True
Пример #4
0
  def recalculatePosition(self):
    camPos = base.camera.getPos() - self._pos
    _, theta, phi = g2scoord(camPos)
    x, y, z = s2gcoord(self._distance, theta, phi)

    base.camera.setPos(Point3(x, y, z) + self._pos)
    base.camera.lookAt(self._pos)
    self._cameraMoved = True
Пример #5
0
    def setPos(self, pos=None, reset=False, withoutMoving=False):
        if pos:
            if isinstance(pos, tuple):
                pos = Point3(pos)
            if reset:
                theta, phi = pi / 4, pi * 1.25
            else:
                _, theta, phi = g2scoord(base.camera.getPos() - self._pos)
                if withoutMoving:
                    x, y, z = (base.camera.getPos() - pos)
                    self._distance = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2))

            newPos = s2gcoord(self._distance, theta, phi)
            base.camera.setPos(Point3(newPos) + pos)
            base.camera.lookAt(pos)
            self._pos = pos
            self._cameraMoved = True
Пример #6
0
  def setPos(self, pos=None, reset=False, withoutMoving=False):
    if pos:
      if isinstance(pos, tuple):
        pos = Point3(pos)
      if reset:
        theta, phi = pi / 4, pi * 1.25
      else:
        _, theta, phi = g2scoord(base.camera.getPos() - self._pos)
        if withoutMoving:
          x, y, z = (base.camera.getPos() - pos)
          self._distance = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2))

      newPos = s2gcoord(self._distance, theta, phi)
      base.camera.setPos(Point3(newPos) + pos)
      base.camera.lookAt(pos)
      self._pos = pos
      self._cameraMoved = True