Example #1
0
 def manipulate(self, ents, movedx, movedy):
     if ents is not None:
         lengthx = 0
         lengthy = 0
         fov = r.getCameraFOV()
         width, height = r.getScreenSize()
         campos = Vector3(r.getCameraPosition())
         ent = ents[-1]
         qpos = ent.placeable.Position
         entpos = Vector3(qpos.x(), qpos.y(), qpos.z())
         length = (campos-entpos).length
             
         worldwidth = (math.tan(fov/2)*length) * 2
         worldheight = (height*worldwidth) / width
             
         #used in freemoving to get the size of movement right
         amountx = (worldwidth * movedx)
         amounty = (worldheight * movedy)
         
         if self.usesManipulator and self.grabbed_axis is not None:
             rightvec = Vector3(r.getCameraRight())
             upvec = Vector3(r.getCameraUp())
             temp = [0,0,0]
             temp[self.grabbed_axis] = 1
             axis_vec = Vector3(temp)
             #print amountx, amounty
             mousey_on_arrow_projection = upvec.dot(axis_vec) * axis_vec
             lengthy = mousey_on_arrow_projection.length * amounty
             mousex_on_arrow_projection = rightvec.dot(axis_vec) * axis_vec
             lengthx = mousex_on_arrow_projection.length * amountx
         
         for ent in ents:
             self._manipulate(ent, amountx, amounty, lengthx, lengthy)
             
         if self.usesManipulator:
             self.moveTo(ents)
Example #2
0
    def manipulate(self, ents, movedx, movedy):
        if ents is not None:
            lengthx = 0
            lengthy = 0
            fov = r.getCameraFOV()
            width, height = r.getScreenSize()
            campos = Vector3(r.getCameraPosition())
            ent = ents[-1]
            qpos = ent.placeable.Position
            entpos = Vector3(qpos.x(), qpos.y(), qpos.z())
            length = (campos - entpos).length

            worldwidth = (math.tan(fov / 2) * length) * 2
            worldheight = (height * worldwidth) / width

            #used in freemoving to get the size of movement right
            amountx = (worldwidth * movedx)
            amounty = (worldheight * movedy)

            if self.usesManipulator and self.grabbed_axis is not None:
                rightvec = Vector3(r.getCameraRight())
                upvec = Vector3(r.getCameraUp())
                temp = [0, 0, 0]
                temp[self.grabbed_axis] = 1
                axis_vec = Vector3(temp)
                #print amountx, amounty
                mousey_on_arrow_projection = upvec.dot(axis_vec) * axis_vec
                lengthy = mousey_on_arrow_projection.length * amounty
                mousex_on_arrow_projection = rightvec.dot(axis_vec) * axis_vec
                lengthx = mousex_on_arrow_projection.length * amountx

            for ent in ents:
                self._manipulate(ent, amountx, amounty, lengthx, lengthy)

            if self.usesManipulator:
                self.moveTo(ents)
Example #3
0
    
if 0: #getting args from outside to run tests automatically
    import os
    naaliargs = os.getenv('NAALIARGS')
    print naaliargs

if 0:
    #print r.c.widget.move_button, dir(r.c.widget.move_button)
    #r.c.canvas.Show()
    print r.c.widget.move_button.isChecked(), r.c.widget.rotate_button.isChecked(), r.c.widget.scale_button.isChecked()
    #print  dir(r.c.widget.move_button)
    r.c.widget.move_button.setChecked(False)
    
if 0:
    from editgui.vector3 import Vector3 as V3
    fov = r.getCameraFOV()
    rightvec = V3(r.getCameraRight())
    campos = V3(r.getCameraPosition())
    ent = r.getEntity(r.getUserAvatarId())
    entpos = V3(ent.pos)
    width, height = r.getScreenSize()
    
    x = 613
    y = 345
    normalized_width = 1/width
    normalized_height = 1/height
    
    #print x * normalized_width
    
    length = (campos-entpos).length
    worldwidth = (math.tan(fov/2)*length) * 2
Example #4
0
    import os
    naaliargs = os.getenv('NAALIARGS')
    print naaliargs

if 0:
    #print r.c.widget.move_button, dir(r.c.widget.move_button)
    #r.c.canvas.Show()
    print r.c.widget.move_button.isChecked(
    ), r.c.widget.rotate_button.isChecked(), r.c.widget.scale_button.isChecked(
    )
    #print  dir(r.c.widget.move_button)
    r.c.widget.move_button.setChecked(False)

if 0:
    from editgui.vector3 import Vector3 as V3
    fov = r.getCameraFOV()
    rightvec = V3(r.getCameraRight())
    campos = V3(r.getCameraPosition())
    ent = r.getEntity(r.getUserAvatarId())
    entpos = V3(ent.pos)
    width, height = r.getScreenSize()

    x = 613
    y = 345
    normalized_width = 1 / width
    normalized_height = 1 / height

    #print x * normalized_width

    length = (campos - entpos).length
    worldwidth = (math.tan(fov / 2) * length) * 2