Exemple #1
0
 def dragStarted(self, mouseinfo):
     width, height = r.getScreenSize()
     normalized_width = 1 / width
     normalized_height = 1 / height
     mouse_abs_x = normalized_width * mouseinfo.x
     mouse_abs_y = normalized_height * mouseinfo.y
     self.prev_mouse_abs_x = mouse_abs_x
     self.prev_mouse_abs_y = mouse_abs_y
Exemple #2
0
 def dragStarted(self, mouseinfo):
     width, height = r.getScreenSize()
     normalized_width = 1/width
     normalized_height = 1/height
     mouse_abs_x = normalized_width * mouseinfo.x
     mouse_abs_y = normalized_height * mouseinfo.y
     self.prev_mouse_abs_x = mouse_abs_x
     self.prev_mouse_abs_y = mouse_abs_y
Exemple #3
0
    def on_mousedrag(self, move_id, mouseinfo, callback):
        """dragging objects around - now free movement based on view,
        dragging different axis etc in the manipulator to be added."""
        #print "mousedrag:", move_id, mouseinfo
        if self.windowActive:
            width, height = r.getScreenSize()

            normalized_width = 1 / width
            normalized_height = 1 / height
            mouse_abs_x = normalized_width * mouseinfo.x
            mouse_abs_y = normalized_height * mouseinfo.y

            movedx = mouse_abs_x - self.prev_mouse_abs_x
            movedy = mouse_abs_y - self.prev_mouse_abs_y

            if self.left_button_down:
                if self.selection_rect_startpos is not None:  # and self.active is None:
                    rectx, recty, rectwidth, rectheight = self.selectionRectDimensions(
                        mouseinfo)
                    self.selection_rect.setGeometry(rectx, recty, rectwidth,
                                                    rectheight)
                    self.selection_rect.show()  #XXX change?

                    #r.logInfo("The selection rect was at: (" +str(rectx) + ", " +str(recty) + ") and size was: (" +str(rectwidth) +", "+str(rectheight)+")")
                    rect = self.selection_rect.rect  #0,0 - x, y
                    rect.translate(mouseinfo.x, mouseinfo.y)
                    #print rect.left(), rect.top(), rect.right(), rect.bottom()
                    rend = r.getQRenderer()
                    hits = rend.FrustumQuery(rect)  #the wish
                    #hits = r.frustumQuery(rect.left(), rect.top(), rect.right(), rect.bottom()) #current workaround
                    print hits

                else:
                    if self.duplicateDragStart:
                        for ent in self.sels:
                            self.worldstream.SendObjectDuplicatePacket(
                                ent.id, ent.prim.UpdateFlags, 0, 0,
                                0)  #nasty hardcoded offset
                        self.duplicateDragStart = False

                    ent = self.active
                    #print "on_mousemove + hold:", mouseinfo
                    if ent is not None and self.sel_activated and self.canmove:
                        self.dragging = True

                        self.manipulator.manipulate(self.sels, movedx, movedy)

                        self.prev_mouse_abs_x = mouse_abs_x
                        self.prev_mouse_abs_y = mouse_abs_y

                        self.window.update_guivals(ent)
Exemple #4
0
    def on_mousedrag(self, move_id, mouseinfo, callback):
        """dragging objects around - now free movement based on view,
        dragging different axis etc in the manipulator to be added."""
        #print "mousedrag:", move_id, mouseinfo
        if self.windowActive:
            width, height = r.getScreenSize()
            
            normalized_width = 1/width
            normalized_height = 1/height
            mouse_abs_x = normalized_width * mouseinfo.x
            mouse_abs_y = normalized_height * mouseinfo.y
                                
            movedx = mouse_abs_x - self.prev_mouse_abs_x
            movedy = mouse_abs_y - self.prev_mouse_abs_y
            
            if self.left_button_down:
                if self.selection_rect_startpos is not None:# and self.active is None:
                    rectx, recty, rectwidth, rectheight = self.selectionRectDimensions(mouseinfo)
                    self.selection_rect.setGeometry(rectx, recty, rectwidth, rectheight)
                    self.selection_rect.show() #XXX change?
                    
                    #r.logInfo("The selection rect was at: (" +str(rectx) + ", " +str(recty) + ") and size was: (" +str(rectwidth) +", "+str(rectheight)+")")
                    rect = self.selection_rect.rect #0,0 - x, y
                    rect.translate(mouseinfo.x, mouseinfo.y)
                    #print rect.left(), rect.top(), rect.right(), rect.bottom()
                    rend = r.getQRenderer()
                    hits = rend.FrustumQuery(rect) #the wish
                    #hits = r.frustumQuery(rect.left(), rect.top(), rect.right(), rect.bottom()) #current workaround
                    print hits

                else:
                    if self.duplicateDragStart:
                        for ent in self.sels:
                            self.worldstream.SendObjectDuplicatePacket(ent.id, ent.prim.UpdateFlags, 0, 0, 0) #nasty hardcoded offset
                        self.duplicateDragStart = False
                            
                    ent = self.active
                    #print "on_mousemove + hold:", mouseinfo
                    if ent is not None and self.sel_activated and self.canmove:
                        self.dragging = True

                        self.manipulator.manipulate(self.sels, movedx, movedy)
                        
                        self.prev_mouse_abs_x = mouse_abs_x
                        self.prev_mouse_abs_y = mouse_abs_y
                        
                        self.window.update_guivals(ent)
Exemple #5
0
    def on_mousedrag(self, move_id, mouseinfo, callback):
        """dragging objects around - now free movement based on view,
        dragging different axis etc in the manipulator to be added."""
        # print "mousedrag:", move_id, mouseinfo
        if self.windowActive:
            width, height = r.getScreenSize()

            normalized_width = 1 / width
            normalized_height = 1 / height
            mouse_abs_x = normalized_width * mouseinfo.x
            mouse_abs_y = normalized_height * mouseinfo.y

            movedx = mouse_abs_x - self.prev_mouse_abs_x
            movedy = mouse_abs_y - self.prev_mouse_abs_y

            if self.left_button_down:
                if self.selection_rect_startpos is not None:  # and self.active is None:
                    rectx, recty, rectwidth, rectheight = self.selectionRectDimensions(mouseinfo)
                    # print rectwidth, rectheight
                    self.selection_rect.setGeometry(rectx, recty, rectwidth, rectheight)
                    self.selection_rect.show()  # XXX change?
                else:
                    if self.duplicateDragStart:
                        for ent in self.sels:
                            self.worldstream.SendObjectDuplicatePacket(
                                ent.id, ent.prim.UpdateFlags, 0, 0, 0
                            )  # nasty hardcoded offset
                        self.duplicateDragStart = False

                    ent = self.active
                    # print "on_mousemove + hold:", mouseinfo
                    if ent is not None and self.sel_activated and self.canmove:
                        self.dragging = True

                        self.manipulator.manipulate(self.sels, movedx, movedy)

                        self.prev_mouse_abs_x = mouse_abs_x
                        self.prev_mouse_abs_y = mouse_abs_y

                        self.window.update_guivals(ent)
Exemple #6
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)
Exemple #7
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)
Exemple #8
0
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

    #print campos, entpos, length, fov, width, height
    
    ent1 = r.createEntity("cruncah.mesh")
    ent1.pos = pos.x, pos.y+worldwidth/2, pos.z
Exemple #9
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

    #print campos, entpos, length, fov, width, height

    ent1 = r.createEntity("cruncah.mesh")
    ent1.pos = pos.x, pos.y + worldwidth / 2, pos.z