コード例 #1
0
ファイル: transform.py プロジェクト: etradewind/Tundra2
 def _rotateEachEntWithQuaternion(self, q, ents, angle):
     for ent in ents:
         ort = ent.placeable.orientation
         euler = mu.quat_to_euler(ort)
         if self.grabbed_axis == self.AXIS_RED:  #rotate around x-axis
             #print euler[0]
             #print math.radians(angle)
             euler[0] += math.radians(angle)
         elif self.grabbed_axis == self.AXIS_GREEN:  #rotate around y-axis
             #print euler[1]
             #print math.radians(angle)
             euler[1] += math.radians(angle)
         elif self.grabbed_axis == self.AXIS_BLUE:  #rotate around z-axis
             #print euler[2]
             #print math.radians(angle)
             euler[2] += math.radians(angle)
         ort = mu.euler_to_quat(euler)
         ent.placeable.orientation = ort
         #ent.network.Orientation = ort
     pass
コード例 #2
0
ファイル: transform.py プロジェクト: A-K/naali
 def _rotateEachEntWithQuaternion(self, q, ents, angle):
     for ent in ents:
         ort = ent.placeable.orientation
         euler = mu.quat_to_euler(ort)
         if self.grabbed_axis == self.AXIS_RED: #rotate around x-axis
             #print euler[0] 
             #print math.radians(angle)
             euler[0] += math.radians(angle)
         elif self.grabbed_axis == self.AXIS_GREEN: #rotate around y-axis
             #print euler[1] 
             #print math.radians(angle)
             euler[1] += math.radians(angle)
         elif self.grabbed_axis == self.AXIS_BLUE: #rotate around z-axis
             #print euler[2] 
             #print math.radians(angle)
             euler[2] += math.radians(angle)
         ort = mu.euler_to_quat(euler)
         ent.placeable.orientation = ort
         #ent.network.Orientation = ort
     pass
コード例 #3
0
ファイル: manipulator.py プロジェクト: etradewind/Tundra2
    def _manipulate(self, ent, amountx, amounty, changevec):
        if self.grabbed and self.grabbed_axis is not None:
            local = self.controller.useLocalTransform
            mov = changevec.length() * 30
            ort = ent.placeable.Orientation

            if amountx < 0 and amounty < 0:
                dir = -1
            elif amountx < 0 and amounty >= 0:
                dir = 1
                if not local and self.grabbed_axis == self.AXIS_BLUE:
                    dir *= -1
            elif amountx >= 0 and amounty < 0:
                dir = -1
            elif amountx >= 0 and amounty >= 0:
                dir = 1

            mov *= dir

            if local:
                if self.grabbed_axis == self.AXIS_RED:
                    axis = QVector3D(1, 0, 0)
                elif self.grabbed_axis == self.AXIS_GREEN:
                    axis = QVector3D(0, 1, 0)
                elif self.grabbed_axis == self.AXIS_BLUE:
                    axis = QVector3D(0, 0, 1)

                ort = ort * QQuaternion.fromAxisAndAngle(axis, mov)
            else:
                euler = mu.quat_to_euler(ort)
                if self.grabbed_axis == self.AXIS_RED: #rotate around x-axis
                    euler[0] -= math.radians(mov)
                elif self.grabbed_axis == self.AXIS_GREEN: #rotate around y-axis
                    euler[1] += math.radians(mov)
                elif self.grabbed_axis == self.AXIS_BLUE: #rotate around z-axis
                    euler[2] += math.radians(mov)

                ort = mu.euler_to_quat(euler)

            ent.placeable.Orientation = ort
            ent.network.Orientation = ort
コード例 #4
0
ファイル: webcontroller.py プロジェクト: etradewind/Tundra2
    def render(self, camposx=None, camposy=None, camposz=None, camang=None):
#, camortx=None, camorty=None, camortz=None, camortw=None):
        cament = naali.getCamera()
        p = cament.placeable

        if camposx is not None:
            pos = Vec(*(float(v) for v in [camposx, camposy, camposz]))
            p.position = pos

        if camang is not None:
            ort = p.orientation
            start = Quat(0, 0, -0.707, -0.707)
            rot = Quat.fromAxisAndAngle(Vec(0, 1, 0), -float(camang))
            new = start * rot
            p.orientation = new

        #if camortx is not None:
        #    ort = Quat(*(float(v) for v in [camortw, camortx, camorty, camortz]))
        #    p.orientation = ort

        #return str(p.position), str(p.orientation) #self.render1()
        baseurl, imgname = save_screenshot()
        imgurl = baseurl + imgname

        pos = p.position
        ort = p.orientation
        #vec, ang = toAngleAxis(p.orientation)
        #print vec, ang
        euler = mu.quat_to_euler(ort)
        ang = euler[0]
        if ang < 0:
            ang = 360 + ang

        return abshtml % (imgurl,
                          ang,
                          pos.x(), pos.y(), pos.z()
                          #ort.scalar(), ort.x(), ort.y(), ort.z(),
                          )
コード例 #5
0
        ang = 2.0 * math.acos(quat.scalar())

        invlen = lensq ** 0.5
        vec = PythonQt.QtGui.QVector3D(quat.x() * invlen,
                                       quat.y() * invlen,
                                       quat.z() * invlen)

        return vec, ang

    cament = naali.getCamera()
    p = cament.placeable

    #print toAngleAxis(p.orientation)

    ort = p.orientation
    euler = mu.quat_to_euler(ort)
    #print euler
    start = QQuaternion(0, 0, -0.707, -0.707)
    #print start
    rot = QQuaternion.fromAxisAndAngle(QVector3D(0, 1, 0), -10)
    new = start * rot
    print ort
    print new
    #p.orientation = new
    #print mu.euler_to_quat(euler), ort
        
if 0: #avatar set yaw (turn)
    #a = -1.0
    a = 0
    print "setting avatar yaw with %f" % a
    r.setAvatarYaw(a)