Ejemplo n.º 1
0
    def RotateSelected(self, yaw, pitch, roll):
        slimItems = self.GetSelObjects()
        if len(slimItems) == 0:
            return
        nq = trinity.TriQuaternion()
        nq.SetYawPitchRoll(yaw / 180.0 * pi, pitch / 180.0 * pi,
                           roll / 180.0 * pi)
        posCtr = trinity.TriVector()
        for slimItem in slimItems:
            posCtr += trinity.TriVector(slimItem.dunX, slimItem.dunY,
                                        slimItem.dunZ)

        posCtr.Scale(1.0 / len(slimItems))
        for slimItem in slimItems:
            q = trinity.TriQuaternion()
            rot = getattr(slimItem, 'dunRotation', None)
            if rot is not None:
                yaw, pitch, roll = rot
                q.SetYawPitchRoll(yaw / 180.0 * pi, pitch / 180.0 * pi,
                                  roll / 180.0 * pi)
            q.Multiply(nq)
            y, p, r = q.GetYawPitchRoll()
            y = y / pi * 180.0
            p = p / pi * 180.0
            r = r / pi * 180.0
            translation = trinity.TriVector(slimItem.dunX, slimItem.dunY,
                                            slimItem.dunZ)
            translation -= posCtr
            translation.TransformQuaternion(nq)
            translation += posCtr
            dungeonHelper.SetObjectPosition(slimItem.dunObjectID,
                                            translation.x, translation.y,
                                            translation.z)
            dungeonHelper.SetObjectRotation(slimItem.dunObjectID, y, p, r)
Ejemplo n.º 2
0
 def JitterRotationSelection(self, yaw, pitch, roll):
     slimItems = self.GetSelObjects()
     if len(slimItems) == 0:
         return
     commandArgs = []
     for slimItem in slimItems:
         oYaw, oPitch, oRoll = dungeonHelper.GetObjectRotation(
             slimItem.dunObjectID)
         oYaw += yaw * random.random() * 2 - yaw
         oPitch += pitch * random.random() * 2 - pitch
         oRoll += roll * random.random() * 2 - roll
         dungeonHelper.SetObjectRotation(slimItem.dunObjectID, oYaw, oPitch,
                                         oRoll)
Ejemplo n.º 3
0
    def RotateSelected(self, yaw, pitch, roll):
        slimItems = self.GetSelObjects()
        if len(slimItems) == 0:
            return
        yawRad = yaw / 180.0 * math.pi
        pitchRad = pitch / 180.0 * math.pi
        rollRad = roll / 180.0 * math.pi
        rotationToAdd = geo2.QuaternionRotationSetYawPitchRoll(
            yawRad, pitchRad, rollRad)
        posCtr = geo2.VectorD(0, 0, 0)
        for slimItem in slimItems:
            posCtr += geo2.VectorD(slimItem.dunX, slimItem.dunY, slimItem.dunZ)

        geo2.Scale(posCtr, 1.0 / len(slimItems))
        for slimItem in slimItems:
            rot = getattr(slimItem, 'dunRotation', None)
            slimItemRotation = geo2.QuaternionIdentity()
            if rot is not None:
                yaw, pitch, roll = rot
                slimItemRotation = geo2.QuaternionRotationSetYawPitchRoll(
                    yaw / 180.0 * math.pi, pitch / 180.0 * math.pi,
                    roll / 180.0 * math.pi)
            y, p, r = geo2.QuaternionRotationGetYawPitchRoll(slimItemRotation)
            slimItemRotation = geo2.QuaternionMultiply(rotationToAdd,
                                                       slimItemRotation)
            y, p, r = geo2.QuaternionRotationGetYawPitchRoll(slimItemRotation)
            y = y / math.pi * 180.0
            p = p / math.pi * 180.0
            r = r / math.pi * 180.0
            translation = geo2.VectorD(slimItem.dunX, slimItem.dunY,
                                       slimItem.dunZ)
            translation -= posCtr
            geo2.QuaternionTransformVector(rotationToAdd, translation)
            translation += posCtr
            dungeonHelper.SetObjectPosition(slimItem.dunObjectID,
                                            translation.x, translation.y,
                                            translation.z)
            dungeonHelper.SetObjectRotation(slimItem.dunObjectID, y, p, r)
Ejemplo n.º 4
0
 def SetRotate(self, y, p, r):
     slimItems = self.GetSelObjects()
     if len(slimItems) == 0:
         return
     for slimItem in slimItems:
         dungeonHelper.SetObjectRotation(slimItem.dunObjectID, y, p, r)