Exemplo n.º 1
0
    def onChanged(self):
        v = self.comp.GetAttribute('timepos')

        #copy-paste from door.py which also had a onClick handler
        if not self.inworld_inited:
            try:
                ent = r.getEntity(self.comp.GetParentEntityId())
            except ValueError:
                return

            try:
                t = ent.touchable
            except AttributeError:
                print "no touchable in animsynced obj? it doesn't persist yet? adding..", ent.id
                print ent.createComponent("EC_Touchable")
                t = ent.touchable
            else:
                print "touchable pre-existed in animated character for animsync."
            t.connect('Clicked()', self.showgui)
            self.inworld_inited = True

        if self.proxywidget is None and self.widget is not None:
            #if self.widget is None:
            #    self.initgui()
            print "AnimSync DynamicComponent handler registering to GUI"
            self.registergui()

        #print "onChanged",
        comp = self.comp
        if comp is not None:
            #print comp.GetAttribute()
            try:
                ent = r.getEntity(comp.GetParentEntityId())
            except ValueError:
                print "No entity"
                return

            try:
                a = ent.animationcontroller
            except AttributeError:
                print "ent with DynamicComponent doesn't have animation"
                return

            #print a
            a.SetAnimationTimePosition("Wave", v)
            self.widget.value = v * 100  #needs changetypes to work well, i guess

        else:
            print "- don't know what :o"
Exemplo n.º 2
0
    def onChanged(self):
        v = self.comp.GetAttribute('timepos')

        #copy-paste from door.py which also had a onClick handler
        if not self.inworld_inited:
            try:
                ent = r.getEntity(self.comp.GetParentEntityId())
            except ValueError:
                return

            try:
                t = ent.touchable
            except AttributeError:
                print "no touchable in animsynced obj? it doesn't persist yet? adding..", ent.id
                print ent.createComponent("EC_Touchable")
                t = ent.touchable
            else:
                print "touchable pre-existed in animated character for animsync."
            t.connect('Clicked()', self.showgui)
            self.inworld_inited = True        

        if self.proxywidget is None and self.widget is not None:
            #if self.widget is None:
            #    self.initgui()
            print "AnimSync DynamicComponent handler registering to GUI"
            self.registergui()

        #print "onChanged",
        comp = self.comp
        if comp is not None:
            #print comp.GetAttribute()
            try:
                ent = r.getEntity(comp.GetParentEntityId())
            except ValueError:
                print "No entity"
                return

            try:
                a = ent.animationcontroller
            except AttributeError:
                print "ent with DynamicComponent doesn't have animation"
                return

            #print a
            a.SetAnimationTimePosition("Wave", v)
            self.widget.value = v * 100 #needs changetypes to work well, i guess
            
        else:
            print "- don't know what :o"
Exemplo n.º 3
0
    def RightMousePressed(self, mouseinfo):
        #r.logInfo("rightmouse down")
        if self.windowActive:
            self.right_button_down = True

            results = []
            results = r.rayCast(mouseinfo.x, mouseinfo.y)

            ent = None

            if results is not None and results[0] != 0:
                id = results[0]
                ent = r.getEntity(id)

            found = False
            if ent is not None:
                #print "Got entity:", ent.id
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True  #clicked on an already selected entity
                        #print "multiselect clicked entity is already in selection"

                #if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed
                if self.validId(ent.id):
                    if not found:
                        #print "new ent to add to multiselect found:", ent.id
                        self.multiselect(ent)
                    else:  #remove this entity which was previously in the selection
                        self.deselect(ent)
                    self.canmove = True
Exemplo n.º 4
0
def apply_js(jssrc, comp):
    jscode = loadjs(jssrc)

    #print jscode

    ctx = {
        #'entity'/'this': self.entity
        'component': comp
    }

    ent = r.getEntity(comp.GetParentEntityId())
    try:
        ent.touchable
    except AttributeError:
        pass
    else:
        ctx['touchable'] = ent.touchable
    try:
        ent.placeable
    except:
        pass
    else:
        ctx['placeable'] = ent.placeable

    naali.runjs(jscode, ctx)
Exemplo n.º 5
0
    def parentalCheck(self, ent):
        children = []

        while 1:
            try:
                qprim = ent.prim
            except AttributeError:
                # we come here when parent has no EC_opensimprim component
                break

            if qprim.ParentId != 0:
                #~ r.logInfo("Entity had a parent, lets pick that instead!")
                # get the parent entity, and if it is editable set it to ent.
                # on next loop we get prim from it and from that we get children.
                temp_ent = r.getEntity(qprim.ParentId)
                if not editable(temp_ent):
                    # not a prim, so not selecting all children
                    break
                else:
                    ent = temp_ent
            else:
                #~ r.logInfo("Entity had no parent, maybe it has children?")
                # either we get children or not :) But this is the 'parent' in either case
                children = qprim.GetChildren()
                break
        return ent, children
Exemplo n.º 6
0
 def RightMousePressed(self, mouseinfo):
     #r.logInfo("rightmouse down")
     if self.windowActive:
         self.right_button_down = True
         
         results = []
         results = r.rayCast(mouseinfo.x, mouseinfo.y)
         
         ent = None
         
         if results is not None and results[0] != 0:
             id = results[0]
             ent = r.getEntity(id)
             
         found = False
         if ent is not None:                
             #print "Got entity:", ent.id
             for entity in self.sels:
                 if entity.id == ent.id:
                     found = True #clicked on an already selected entity
                     #print "multiselect clicked entity is already in selection"
             
             #if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed  
             if self.validId(ent.id):
                 if not found:
                     #print "new ent to add to multiselect found:", ent.id
                     self.multiselect(ent)
                 else: #remove this entity which was previously in the selection
                     self.deselect(ent)
                 self.canmove = True
Exemplo n.º 7
0
 def _manipulate(self, ent, amountx, amounty, lengthx, lengthy):
     if self.grabbed:
         qscale = ent.placeable.Scale
         scale = list((qscale.x(), qscale.y(), qscale.z()))
         rightvec = Vector3(r.getCameraRight())
         upvec = Vector3(r.getCameraUp())
         
         if self.grabbed_axis == self.AXIS_BLUE:
             mov = lengthy
             scale[self.grabbed_axis] -= mov
         else:
             mov = lengthx
             div = abs(rightvec[self.grabbed_axis])
             if div == 0:
                 div = 0.01 #not the best of ideas but...
             mov *= rightvec[self.grabbed_axis]/div
             scale[self.grabbed_axis] += mov
         
         newscale = Vec(scale[0], scale[1], scale[2])
         ent.placeable.Scale = newscale
         self.controller.updateSelectionBox(ent) 
         qprim = ent.prim
         if qprim is not None:
             children = qprim.GetChildren()
             for child_id in children:
                 child = r.getEntity(int(child_id))
                 child.placeable.Scale = newscale
Exemplo n.º 8
0
    def _manipulate(self, ent, amountx, amounty, lengthx, lengthy):
        if self.grabbed:
            qscale = ent.placeable.Scale
            scale = list((qscale.x(), qscale.y(), qscale.z()))
            rightvec = Vector3(r.getCameraRight())
            upvec = Vector3(r.getCameraUp())

            if self.grabbed_axis == self.AXIS_BLUE:
                mov = lengthy
                scale[self.grabbed_axis] -= mov
            else:
                mov = lengthx
                div = abs(rightvec[self.grabbed_axis])
                if div == 0:
                    div = 0.01  #not the best of ideas but...
                mov *= rightvec[self.grabbed_axis] / div
                scale[self.grabbed_axis] += mov

            newscale = Vec(scale[0], scale[1], scale[2])
            ent.placeable.Scale = newscale
            self.controller.updateSelectionBox(ent)
            qprim = ent.prim
            if qprim is not None:
                children = qprim.GetChildren()
                for child_id in children:
                    child = r.getEntity(int(child_id))
                    child.placeable.Scale = newscale
Exemplo n.º 9
0
 def on_entity_visuals_modified(self, entid):
     #print "MediaURLHandler got Visual Modified for:", entid 
     for texture_uuid, mediaurlview in self.texture2mediaurlview.iteritems():
         if mediaurlview is None:
             continue
         submeshes = r.getSubmeshesWithTexture(entid, texture_uuid)
         if submeshes:
             # This doesent work. Seems to be right in theory but some entitys textures are not updated
             # especially when there are multiple entitys with same mediurl texture
             """
             # Don't reapply if submeshes are the same for this entity
             try:
                 if mediaurlview.entid_to_submeshes[entid] == submeshes:
                     print "Already have submeshes for ", str(entid)
                     print " >> Present: ", mediaurlview.entid_to_submeshes[entid]
                     print " >> Found  : ", submeshes
                     return
             except KeyError, e:
                 print " Adding new submeshes to ent id to map for ", str(entid)
                 print " >> ", submeshes
                 mediaurlview.entid_to_submeshes[entid] = submeshes
             """
             
             # Check if we need to create the playback widget
             if mediaurlview.playback_widget == None:
                 mediaurlview.create_playback_widget()
                 r.applyUICanvasToSubmeshes(entid, submeshes, mediaurlview.playback_widget, mediaurlview.refreshrate)
                 mediaurlview.load_url()
             else:
                 r.applyUICanvasToSubmeshes(entid, submeshes, mediaurlview.playback_widget, mediaurlview.refreshrate)
             # Get entity for id and hook to Touchable signals
             entity = r.getEntity(entid)
             self.connect_touchable(mediaurlview, entity)
Exemplo n.º 10
0
def apply_js(jssrc, comp):
    jscode = loadjs(jssrc)

    # print jscode

    ctx = {
        #'entity'/'this': self.entity
        "component": comp
    }

    ent = r.getEntity(comp.GetParentEntityId())
    try:
        ent.touchable
    except AttributeError:
        pass
    else:
        ctx["touchable"] = ent.touchable
    try:
        ent.placeable
    except:
        pass
    else:
        ctx["placeable"] = ent.placeable

    naali.runjs(jscode, ctx)
Exemplo n.º 11
0
 def loadEstate(self):
     self.worldstream = r.getServerConnection()
     if self.worldstream == None:
         self.queue.put(
             ("displayerror",
              "No worldstream, check if you're connected to server"))
     else:
         self.estatesettings = EstateSettings(self.worldstream, self)
         s = naali.getScene("World")
         ids = s.GetEntityIdsWithComponent("EC_OpenSimPresence")
         self.ents = [r.getEntity(id) for id in ids]
         self.window.setRegionUsers(self.ents)
         #self.worldstream.SendEstateInfoRequestpacket() #!!
         self.worldstream.SendEstateOwnerMessage("getinfo", ())
         self.updateSavedUsers()
         #self.updateSavedUsersTab()
         #test if rights to modify access
         cap = self.worldstream.GetCapability(
             'EstateRegionSettingsModification')
         if cap == None or cap == "":
             self.window.setNoCapInfo()
         else:
             self.estatesettings.fetchEstates()
             self.window.resetCapInfo()
         pass
Exemplo n.º 12
0
    def parentalCheck(self, ent):
        children = []
        
        while 1:
            try:
                qprim = ent.prim
            except AttributeError:
                # we come here when parent has no EC_opensimprim component
                break

            if qprim.ParentId != 0:
                #~ r.logInfo("Entity had a parent, lets pick that instead!")
                # get the parent entity, and if it is editable set it to ent.
                # on next loop we get prim from it and from that we get children.
                temp_ent = r.getEntity(qprim.ParentId)
                if not editable(temp_ent):
                    # not a prim, so not selecting all children
                    break
                else:
                    ent = temp_ent
            else:
                #~ r.logInfo("Entity had no parent, maybe it has children?")
                # either we get children or not :) But this is the 'parent' in either case
                children = qprim.GetChildren()
                break
        return ent, children
Exemplo n.º 13
0
Arquivo: door.py Projeto: Chiru/naali
    def update(self, t):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError: #the entity has been removed or something
            return # nothing useful to do anyway

        if self.forcepos is not None:
                ent.placeable.Position = self.forcepos
Exemplo n.º 14
0
    def update(self, t):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError:  #the entity has been removed or something
            return  # nothing useful to do anyway

        if self.forcepos is not None:
            ent.placeable.Position = self.forcepos
Exemplo n.º 15
0
def runtests():
    #e = viewer.scenes['World'].entities[1] #the id for testdummy, or by name?
    #note: now is directly in viewer as GetEntity, defaulting to 'World' scene
    
    e = r.getEntity(idnum)
    test_move(e)
    test_scale(e)
    test_orientation(e)
    test_text(e)
    test_errors(e)
Exemplo n.º 16
0
def runtests():
    #e = viewer.scenes['World'].entities[1] #the id for testdummy, or by name?
    #note: now is directly in viewer as GetEntity, defaulting to 'World' scene
    
    e = r.getEntity(idnum)
    test_move(e)
    test_scale(e)
    test_orientation(e)
    test_text(e)
    test_errors(e)
Exemplo n.º 17
0
    def LeftMousePressed(self, mouseinfo):
        #r.logDebug("LeftMousePressed") #, mouseinfo, mouseinfo.x, mouseinfo.y
        #r.logDebug("point " + str(mouseinfo.x) + "," + str(mouseinfo.y))

        self.dragStarted(
            mouseinfo)  #need to call this to enable working dragging

        #         if self.selection_box is None:
        #             self.selection_box = r.createEntity("Selection.mesh", -10000)

        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None

        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()

        self.manipulator.initManipulation(ent, results)

        if ent is not None:
            #print "Got entity:", ent, ent.editable
            if not self.manipulator.compareIds(
                    ent.id
            ) and ent.editable:  #ent.id != self.selection_box.id and
                #if self.sel is not ent: #XXX wrappers are not reused - there may now be multiple wrappers for same entity

                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True

                if self.active is None or self.active.id != ent.id:  #a diff ent than prev sel was changed
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif self.active.id == ent.id:  #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True

        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            #print "canmove:", self.canmove
            self.canmove = False
            self.deselect_all()
Exemplo n.º 18
0
    def LeftMousePressed(self, mouseinfo):
        # r.logDebug("LeftMousePressed") #, mouseinfo, mouseinfo.x, mouseinfo.y
        # r.logDebug("point " + str(mouseinfo.x) + "," + str(mouseinfo.y))

        self.dragStarted(mouseinfo)  # need to call this to enable working dragging

        if self.selection_box is None:
            self.selection_box = r.createEntity("Selection.mesh", -10000)

        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None

        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()

        self.manipulator.initManipulation(ent, results)

        if ent is not None:
            # print "Got entity:", ent, ent.editable
            if not self.manipulator.compareIds(ent.id) and ent.id != self.selection_box.id and ent.editable:
                # if self.sel is not ent: #XXX wrappers are not reused - there may now be multiple wrappers for same entity

                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True

                if self.active is None or self.active.id != ent.id:  # a diff ent than prev sel was changed
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif (
                    self.active.id == ent.id
                ):  # canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True

        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            # print "canmove:", self.canmove
            self.canmove = False
            self.deselect_all()
Exemplo n.º 19
0
    def createObject(self):
        avatar_id = r.getUserAvatarId()
        avatar = r.getEntity(avatar_id)
        pos = avatar.placeable.Position#r.getUserAvatarPos()

        start_x = pos.x()
        start_y = pos.y()
        start_z = pos.z()
        end_x = start_x
        end_y = start_y
        end_z = start_z

        r.sendObjectAddPacket(start_x, start_y, start_z, end_x, end_y, end_z)
Exemplo n.º 20
0
    def createObject(self):
        avatar_id = r.getUserAvatarId()
        avatar = r.getEntity(avatar_id)
        pos = avatar.placeable.Position  #r.getUserAvatarPos()

        start_x = pos.x()
        start_y = pos.y()
        start_z = pos.z()
        end_x = start_x
        end_y = start_y
        end_z = start_z

        r.sendObjectAddPacket(start_x, start_y, start_z, end_x, end_y, end_z)
Exemplo n.º 21
0
    def on_mouseleftpressed(self, mouseinfo):
        if not self.windowActive:
            return
        if mouseinfo.IsItemUnderMouse():
            return
        if mouseinfo.HasShiftModifier() and not mouseinfo.HasCtrlModifier(
        ) and not mouseinfo.HasAltModifier():
            self.on_multiselect(mouseinfo)
            return

        self.dragStarted(
            mouseinfo)  #need to call this to enable working dragging
        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None
        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()
        self.manipulator.initManipulation(ent, results)
        self.usingManipulator = True

        if ent is not None:
            if not self.manipulator.compareIds(ent.id) and editable(
                    ent):  #ent.id != self.selection_box.id and
                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True

                if self.active is None or self.active.id != ent.id:  #a diff ent than prev sel was changed
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif self.active.id == ent.id:  #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True

        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            self.canmove = False
            self.deselect_all()
Exemplo n.º 22
0
    def on_mouseleftpressed(self, mouseinfo):
        if not self.windowActive:
            return
        if mouseinfo.IsItemUnderMouse():
            return
        if mouseinfo.HasShiftModifier() and not mouseinfo.HasCtrlModifier() and not mouseinfo.HasAltModifier():
            self.on_multiselect(mouseinfo)
            return
            
        self.dragStarted(mouseinfo) #need to call this to enable working dragging
        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None
        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()
        self.manipulator.initManipulation(ent, results)
        self.usingManipulator = True

        if ent is not None:
            if not self.manipulator.compareIds(ent.id) and editable(ent): #ent.id != self.selection_box.id and 
                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True
               
                if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed  
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif self.active.id == ent.id: #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True
                    
        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            self.canmove = False
            self.deselect_all()
Exemplo n.º 23
0
 def deleteObject(self):
     if self.active is not None:
         for ent in self.sels:
             #r.logInfo("deleting " + str(ent.id))
             ent, children = self.parentalCheck(ent)
             for child_id in children:
                 child = r.getEntity(int(child_id))
                 #~ self.worldstream.SendObjectDeRezPacket(child.id, r.getTrashFolderId())
             #~ if len(children) == 0:
             self.worldstream.SendObjectDeRezPacket(ent.id, r.getTrashFolderId())
             #~ else:
                 #~ r.logInfo("trying to delete a parent, need to fix this!")
         
         self.manipulator.hideManipulator()
         #self.hideSelector()        
         self.deselect_all()
         self.sels = []
Exemplo n.º 24
0
    def deleteObject(self):
        if self.active is not None:
            for ent in self.sels:
                #r.logInfo("deleting " + str(ent.id))
                ent, children = self.parentalCheck(ent)
                for child_id in children:
                    child = r.getEntity(int(child_id))
                    #~ self.worldstream.SendObjectDeRezPacket(child.id, r.getTrashFolderId())
                #~ if len(children) == 0:
                self.worldstream.SendObjectDeRezPacket(ent.id,
                                                       r.getTrashFolderId())
                #~ else:
                #~ r.logInfo("trying to delete a parent, need to fix this!")

            self.manipulator.hideManipulator()
            #self.hideSelector()
            self.deselect_all()
            self.sels = []
Exemplo n.º 25
0
    def _manipulate(self, ent, amountx, amounty, changevec):
        if self.grabbed:
            if self.grabbed_axis == self.AXIS_BLUE:
                changevec.setX(0)
                changevec.setY(0)
            elif self.grabbed_axis == self.AXIS_RED:
                changevec.setZ(0)
                changevec.setY(0)
            elif self.grabbed_axis == self.AXIS_GREEN:
                changevec.setX(0)
                changevec.setZ(0)

            ent.placeable.Scale += changevec
            qprim = ent.prim
            if qprim is not None:
                children = qprim.GetChildren()
                for child_id in children:  #XXX this might not be the wanted behaviour with linksets! .. when just scaling the rootpart.
                    child = r.getEntity(int(child_id))
                    child.placeable.Scale += changevec
Exemplo n.º 26
0
Arquivo: door.py Projeto: Chiru/naali
    def onChanged(self):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError: #the entity has been removed or something
            return

        print "door data changed"

        if not self.inworld_inited:
            #if hasattr(self.comp, 'touchable')
            try:
                t = ent.touchable
            except AttributeError:
                print "no touchable in door? it doesn't persist yet? adding..", ent.id
                ent.createComponent("EC_Touchable")
                t = ent.touchable
            else:
                print "touchable pre-existed in door."
            t.connect('Clicked()', self.open)
            t.connect('MouseHoverIn()', self.hover_in)
            t.connect('MouseHoverOut()', self.hover_out)
            self.inworld_inited = True

        opened = self.opened
        locked = self.locked

        newpos = OPENPOS if opened else CLOSEPOS
        ent.placeable.Position = newpos        
        #print opened, type(opened), ent.placeable.Position

        self.openbut.text = "Close" if opened else "Open"
        self.lockbut.text = "Unlock" if locked else "Lock"
        if locked and not opened:
            self.openbut.enabled = False
        else:
            self.openbut.enabled = True
        
        """NOTE:
        this code doesn't now sync the normal ob pos to server
        at all. the object is moved in all clients only.
        when logging back to a server, wasn't seeing the right positions,
        probably because server send pos update after the comp sync."""
        self.forcepos = ent.placeable.Position
Exemplo n.º 27
0
 def _manipulate(self, ent, amountx, amounty, changevec):
     if self.grabbed:
         if self.grabbed_axis == self.AXIS_BLUE:
             changevec.setX(0)
             changevec.setY(0)
         elif self.grabbed_axis == self.AXIS_RED:
             changevec.setZ(0)
             changevec.setY(0)
         elif self.grabbed_axis == self.AXIS_GREEN:
             changevec.setX(0)
             changevec.setZ(0)
         
         ent.placeable.Scale += changevec
         qprim = ent.prim
         if qprim is not None:
             children = qprim.GetChildren()
             for child_id in children: #XXX this might not be the wanted behaviour with linksets! .. when just scaling the rootpart.
                 child = r.getEntity(int(child_id))
                 child.placeable.Scale += changevec
Exemplo n.º 28
0
    def onChanged(self):
        try:
            ent = r.getEntity(self.comp.GetParentEntityId())
        except ValueError:  #the entity has been removed or something
            return

        print "door data changed"

        if not self.inworld_inited:
            #if hasattr(self.comp, 'touchable')
            try:
                t = ent.touchable
            except AttributeError:
                print "no touchable in door? it doesn't persist yet? adding..", ent.id
                ent.createComponent("EC_Touchable")
                t = ent.touchable
            else:
                print "touchable pre-existed in door."
            t.connect('Clicked()', self.open)
            t.connect('MouseHoverIn()', self.hover_in)
            t.connect('MouseHoverOut()', self.hover_out)
            self.inworld_inited = True

        opened = self.opened
        locked = self.locked

        newpos = OPENPOS if opened else CLOSEPOS
        ent.placeable.Position = newpos
        #print opened, type(opened), ent.placeable.Position

        self.openbut.text = "Close" if opened else "Open"
        self.lockbut.text = "Unlock" if locked else "Lock"
        if locked and not opened:
            self.openbut.enabled = False
        else:
            self.openbut.enabled = True
        """NOTE:
        this code doesn't now sync the normal ob pos to server
        at all. the object is moved in all clients only.
        when logging back to a server, wasn't seeing the right positions,
        probably because server send pos update after the comp sync."""
        self.forcepos = ent.placeable.Position
Exemplo n.º 29
0
 def on_multiselect(self, mouseinfo):
     if self.windowActive:           
         results = []
         results = r.rayCast(mouseinfo.x, mouseinfo.y)
         ent = None
         if results is not None and results[0] != 0:
             id = results[0]
             ent = r.getEntity(id)
             
         found = False
         if ent is not None:                
             for entity in self.sels:
                 if entity.id == ent.id:
                     found = True
             if self.validId(ent.id):
                 if not found:
                     self.multiselect(ent)
                 else:
                     self.deselect(ent)
                 self.canmove = True
Exemplo n.º 30
0
    def on_multiselect(self, mouseinfo):
        if self.windowActive:
            results = []
            results = r.rayCast(mouseinfo.x, mouseinfo.y)
            ent = None
            if results is not None and results[0] != 0:
                id = results[0]
                ent = r.getEntity(id)

            found = False
            if ent is not None:
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True
                if self.validId(ent.id):
                    if not found:
                        self.multiselect(ent)
                    else:
                        self.deselect(ent)
                    self.canmove = True
Exemplo n.º 31
0
 def parentalCheck(self, ent):
     exitLoop = False
     parent = False
     children = []
     
     while(not exitLoop):
         qprim = ent.prim
         if qprim is not None:
             if qprim.ParentId != 0:
                 #~ r.logInfo("Entity had a parent, lets pick that instead!")
                 ent = r.getEntity(qprim.ParentId)
             else:
                 #~ r.logInfo("Entity had no parent, maybe it has children?")
                 children = qprim.GetChildren()
                 if len(children)>0:
                     parent = True
                     
                 exitLoop = True
                 
     return ent, children
Exemplo n.º 32
0
    def parentalCheck(self, ent):
        exitLoop = False
        parent = False
        children = []

        while (not exitLoop):
            qprim = ent.prim
            if qprim is not None:
                if qprim.ParentId != 0:
                    #~ r.logInfo("Entity had a parent, lets pick that instead!")
                    ent = r.getEntity(qprim.ParentId)
                else:
                    #~ r.logInfo("Entity had no parent, maybe it has children?")
                    children = qprim.GetChildren()
                    if len(children) > 0:
                        parent = True

                    exitLoop = True

        return ent, children
Exemplo n.º 33
0
 def loadEstate(self):
     self.worldstream = r.getServerConnection()
     if self.worldstream==None:
         self.queue.put(("displayerror", "No worldstream, check if you're connected to server"))
     else:        
         self.estatesettings = EstateSettings(self.worldstream, self)
         s = naali.getScene("World")
         ids = s.GetEntityIdsWithComponent("EC_OpenSimPresence")
         self.ents = [r.getEntity(id) for id in ids]
         self.window.setRegionUsers(self.ents)
         #self.worldstream.SendEstateInfoRequestpacket() #!!
         self.worldstream.SendEstateOwnerMessage("getinfo", ())        
         self.updateSavedUsers()
         #self.updateSavedUsersTab()
         #test if rights to modify access
         cap = self.worldstream.GetCapability('EstateRegionSettingsModification')
         if cap==None or cap=="":
             self.window.setNoCapInfo()
         else:
             self.estatesettings.fetchEstates()
             self.window.resetCapInfo()
         pass
Exemplo n.º 34
0
    def on_entity_visuals_modified(self, entid):
        #print "MediaURLHandler got Visual Modified for:", entid
        for texture_uuid, mediaurlview in self.texture2mediaurlview.iteritems(
        ):
            if mediaurlview is None:
                continue
            submeshes = r.getSubmeshesWithTexture(entid, texture_uuid)
            if submeshes:
                # This doesent work. Seems to be right in theory but some entitys textures are not updated
                # especially when there are multiple entitys with same mediurl texture
                """
                # Don't reapply if submeshes are the same for this entity
                try:
                    if mediaurlview.entid_to_submeshes[entid] == submeshes:
                        print "Already have submeshes for ", str(entid)
                        print " >> Present: ", mediaurlview.entid_to_submeshes[entid]
                        print " >> Found  : ", submeshes
                        return
                except KeyError, e:
                    print " Adding new submeshes to ent id to map for ", str(entid)
                    print " >> ", submeshes
                    mediaurlview.entid_to_submeshes[entid] = submeshes
                """

                # Check if we need to create the playback widget
                if mediaurlview.playback_widget == None:
                    mediaurlview.create_playback_widget()
                    r.applyUICanvasToSubmeshes(entid, submeshes,
                                               mediaurlview.playback_widget,
                                               mediaurlview.refreshrate)
                    mediaurlview.load_url()
                else:
                    r.applyUICanvasToSubmeshes(entid, submeshes,
                                               mediaurlview.playback_widget,
                                               mediaurlview.refreshrate)
                # Get entity for id and hook to Touchable signals
                entity = r.getEntity(entid)
                self.connect_touchable(mediaurlview, entity)
Exemplo n.º 35
0
 def createComponent(self, typename):
     oldpyent = r.getEntity(self.id)
     oldpyent.createComponent(typename)
Exemplo n.º 36
0
Arquivo: naali.py Projeto: Chiru/naali
 def createComponent(self, typename):
     oldpyent = r.getEntity(self.id)
     oldpyent.createComponent(typename)
Exemplo n.º 37
0
def hello_world(ws):
    print 'START', ws
    myid = random.randrange(1, 10000)
    clients.add(ws)

    while True:

        try:
            msg = ws.wait()
        except socket.error:
            break
        print msg
        if msg is None:
            break
        try:
            function, params = json.loads(msg)
        except ValueError, error:
            print error

        if function == 'CONNECTED':
            ws.send(json.dumps(['initGraffa', {}]))
            #x = random.randrange(10, 180)
            #y = random.randrange(10, 180)
            x, y = SPAWNPOS[0], SPAWNPOS[1]
            NaaliWebsocketServer.instance.newclient(myid, (x, y))

            ws.send(json.dumps(['setId', {'id': myid}]))
            sendAll([
                'newAvatar', {
                    'id': myid,
                    'x': x,
                    'y': y,
                    'dx': 0,
                    'dy': 0,
                    'angle': 0,
                    'speed': 0
                }
            ])

        elif function == 'Naps':
            ws.send(json.dumps(['logMessage', {'message': 'Naps itelles!'}]))

        elif function == 'giev update':

            id = params.get('id')
            x = params.get('x')
            y = params.get('y')
            dx = params.get('dx')
            dy = params.get('dy')
            speed = params.get('speed')
            angle = params.get('angle')

            NaaliWebsocketServer.instance.updateclient(myid, (x, y))

            s = naali.getScene("World")
            ids = s.GetEntityIdsWithComponent("EC_OpenSimPresence")
            ents = [r.getEntity(id) for id in ids]

            for ent in ents:
                x = ent.placeable.Position.x()
                y = ent.placeable.Position.y()
                id = ent.id

                sendAll([
                    'updateAvatar', {
                        'id': id,
                        'angle': angle,
                        'x': x,
                        'y': y,
                        'dx': dx,
                        'dy': dy,
                        'speed': speed,
                    }
                ])

        elif function == 'setSize':
            y_max = params['height']
            x_max = params['width']

        elif function == 'reboot':
            break
Exemplo n.º 38
0
def hello_world(ws):
    print "START", ws
    myid = random.randrange(1, 10000)
    clients.add(ws)

    while True:

        try:
            msg = ws.wait()
        except socket.error:
            break
        print msg
        if msg is None:
            break
        try:
            function, params = json.loads(msg)
        except ValueError, error:
            print error

        if function == "CONNECTED":
            ws.send(json.dumps(["initGraffa", {}]))
            # x = random.randrange(10, 180)
            # y = random.randrange(10, 180)
            x, y = SPAWNPOS[0], SPAWNPOS[1]
            NaaliWebsocketServer.instance.newclient(myid, (x, y))

            ws.send(json.dumps(["setId", {"id": myid}]))
            sendAll(["newAvatar", {"id": myid, "x": x, "y": y, "dx": 0, "dy": 0, "angle": 0, "speed": 0}])

        elif function == "Naps":
            ws.send(json.dumps(["logMessage", {"message": "Naps itelles!"}]))

        elif function == "giev update":

            id = params.get("id")
            x = params.get("x")
            y = params.get("y")
            dx = params.get("dx")
            dy = params.get("dy")
            speed = params.get("speed")
            angle = params.get("angle")

            NaaliWebsocketServer.instance.updateclient(myid, (x, y))

            s = naali.getScene("World")
            ids = s.GetEntityIdsWithComponent("EC_OpenSimPresence")
            ents = [r.getEntity(id) for id in ids]

            for ent in ents:
                x = ent.placeable.Position.x()
                y = ent.placeable.Position.y()
                id = ent.id

                sendAll(
                    ["updateAvatar", {"id": id, "angle": angle, "x": x, "y": y, "dx": dx, "dy": dy, "speed": speed}]
                )

        elif function == "setSize":
            y_max = params["height"]
            x_max = params["width"]

        elif function == "reboot":
            break
Exemplo n.º 39
0
if 0:  #create entity
    print "Testing entity creation"
    meshname = "axes.mesh"

    avatar = naali.getUserAvatar()
    ent = naali.createMeshEntity(meshname)
    #print "New entity created:", ent, ent.placeable.Position
    ent.placeable.Position = avatar.placeable.Position

    #from PythonQt.QtGui import QVector3D as Vec
    #ent.placeable.Scale = Vec(0.1, 0.1, 0.1)
    #print "new pos", ent.pos, ent.scale

if 0:  #placeable and text tests
    print "Testing..."
    e = r.getEntity(8880005)

    #~ try:
    #~ e.pos = 1
    #~ except Exception, e:
    #~ print e

    #e.orientation = "well this ain't a quarternion."
    #e.scale = ("does", "this", "work")
    def test():
        print "this ain't a string..."

    e.text = "swoot"
    e.text = 1
    e.text = ("swoot", "ness")
    e.text = (1, 2)
Exemplo n.º 40
0
    hmm = r.takeScreenshot(path, pic)

if 0:
    print "Testing event sending, camera for now..."  #   , r.SwitchCameraState
    hmm = r.sendEvent(r.SwitchCameraState)
    print "test done?", hmm

if 0:
    print "Testing camera swap..."
    hmm = r.switchCameraState()
    #print hmm

if 0:  #get entity
    #idnum = new_id
    print "Getting entity id", idnum,
    e = r.getEntity(idnum)
    print "got:", e
    #print dir(r)
    rotate(e)
    #move(e)

if 0:  #test avatartracking, works :)
    av_entid = 2628869553
    print "<:::",
    try:
        a = r.getEntity(av_entid)
    except:
        print "could find the avatar with the given id", av_entid
    else:
        print "Avatar pos:", a.pos,
        print ":::>"
Exemplo n.º 41
0
 def highlightChildren(self, children):
     for child_id in children:
         child = r.getEntity(int(child_id))
         self.window.addToList(child)
         self.window.highlightEntityFromList(child)
         self.highlight(child)
Exemplo n.º 42
0
if 0: #create entity
    print "Testing entity creation"
    meshname = "axes.mesh"
    
    avatar = naali.getUserAvatar()
    ent = naali.createMeshEntity(meshname)
    #print "New entity created:", ent, ent.placeable.Position
    ent.placeable.Position = avatar.placeable.Position

    #from PythonQt.QtGui import QVector3D as Vec
    #ent.placeable.Scale = Vec(0.1, 0.1, 0.1)
    #print "new pos", ent.pos, ent.scale

if 0: #placeable and text tests
    print "Testing..."
    e = r.getEntity(8880005)    

    #~ try:
        #~ e.pos = 1
    #~ except Exception, e:
        #~ print e
        
    #e.orientation = "well this ain't a quarternion."
    #e.scale = ("does", "this", "work")
    def test():
        print "this ain't a string..."
    
    e.text = "swoot"
    e.text = 1
    e.text = ("swoot", "ness")
    e.text = (1, 2)
Exemplo n.º 43
0
    def __init__(self):
        Component.__init__(self)

        #XXX should done this only after connecting or something
        self.target = r.getEntity(idnum)
        print "MouseControl inited with target", self.target
Exemplo n.º 44
0
    hmm = r.takeScreenshot(path, pic)
    
if 0:
    print "Testing event sending, camera for now..."#   , r.SwitchCameraState
    hmm = r.sendEvent(r.SwitchCameraState)
    print "test done?", hmm

if 0:
    print "Testing camera swap..."
    hmm = r.switchCameraState()
    #print hmm
    
if 0: #get entity
    #idnum = new_id
    print "Getting entity id", idnum,
    e = r.getEntity(idnum)
    print "got:", e
    #print dir(r)
    rotate(e)
    #move(e)

if 0: #test avatar tracking, works :)
    av_entid = 2628869553
    print "<:::",
    try:
        a = r.getEntity(av_entid)
    except:
        print "could find the avatar with the given id", av_entid
    else:
        print "Avatar pos:", a.pos,
        print ":::>"
Exemplo n.º 45
0
 def __init__(self):
     Component.__init__(self)
     
     #XXX should done this only after connecting or something
     self.target = r.getEntity(idnum)
     print "MouseControl inited with target", self.target
Exemplo n.º 46
0
 def highlightChildren(self, children):
     for child_id in children:
         child = r.getEntity(int(child_id))
         self.highlight(child)
         self.soundRuler(child)
Exemplo n.º 47
0
 def highlightChildren(self, children):
     for child_id in children:
         child = r.getEntity(int(child_id))
         self.window.addToList(child)
         self.window.highlightEntityFromList(child)
         self.highlight(child)
Exemplo n.º 48
0
 def highlightChildren(self, children):
     for child_id in children:
         child = r.getEntity(int(child_id))
         self.highlight(child)
         self.soundRuler(child)