Beispiel #1
0
    def run(self):
        self.wait_time = int(self.config.get("wait_time", 60))
        yield "doing login"
        self.timer_start()
        r.startLoginOpensim(user, pwd, server)
        yield "waiting for connection"
        conn = None
        while not self.elapsed(self.wait_time):
            conn = r.getServerConnection()
            if conn and conn.IsConnected():
                break
            else:
                yield None
        else:
            return
        yield "waiting for avatar to appear"
        ent = None
        while not self.elapsed(self.wait_time):
            try:
                ent = naali.getUserAvatar()
            except ValueError:
                yield None
            else:
                break

        if not ent:
            yield "failure, avatar didn't appear"
            return

        for i in range(100):
            for x in self.do_api_calls():
                yield x
            break
        r.exit()
        yield "success"
Beispiel #2
0
    def run(self):
        self.wait_time = int(self.config.get("wait_time", 60))
        yield "doing login"
        self.timer_start()
        r.startLoginOpensim(user, pwd, server)
        yield "waiting for connection"
        conn = None
        while not self.elapsed(self.wait_time):
            conn = r.getServerConnection()
            if conn and conn.IsConnected():
                break
            else:
                yield None
        else:
            return
        yield "waiting for avatar to appear"
        ent = None
        while not self.elapsed(self.wait_time):
            try:
                ent = naali.getUserAvatar()
            except ValueError:
                yield None
            else:
                break
        
        if not ent:
            yield "failure, avatar didn't appear"
            return

        for i in range(100):
            for x in self.do_api_calls():
                yield x
            break
        r.exit()
        yield "success"
Beispiel #3
0
    def createObject(self):
        avatar = naali.getUserAvatar()
        pos = avatar.placeable.position

        # TODO determine what is right in front of avatar and use that instead
        start_x = pos.x() + .7
        start_y = pos.y() + .7
        start_z = pos.z()
Beispiel #4
0
 def validId(self, id):
     if id != 0 and id > 50:  #terrain seems to be 3 and scene objects always big numbers, so > 50 should be good, though randomly created local entities can get over 50...
         if id != naali.getUserAvatar(
         ).id:  #XXX add other avatar id's check
             if not self.manipulator.compareIds(
                     id):  #and id != self.selection_box.id:
                 return True
     return False
Beispiel #5
0
    def createObject(self):
        avatar = naali.getUserAvatar()
        pos = avatar.placeable.position

        # TODO determine what is right in front of avatar and use that instead
        start_x = pos.x() + .7
        start_y = pos.y() + .7
        start_z = pos.z()
Beispiel #6
0
    def createObject(self):
        avatar = naali.getUserAvatar()
        pos = avatar.placeable.Position

        # TODO determine what is right in front of avatar and use that instead
        start_x = pos.x() + .7
        start_y = pos.y() + .7
        start_z = pos.z()

        self.worldstream.SendObjectAddPacket(start_x, start_y, start_z)
Beispiel #7
0
    def createObject(self):
        avatar = naali.getUserAvatar()
        pos = avatar.placeable.Position

        # TODO determine what is right in front of avatar and use that instead
        start_x = pos.x() + .7
        start_y = pos.y() + .7
        start_z = pos.z()

        self.worldstream.SendObjectAddPacket(start_x, start_y, start_z)
Beispiel #8
0
    def run(self):
        self.wait_time = int(self.config.get("wait_time", 60))
        yield "doing login"
        self.timer_start()
        r.startLoginOpensim(user, pwd, server)
        yield "waiting for connection"
        conn = None
        while not self.elapsed(self.wait_time):
            conn = r.getServerConnection()
            if conn and conn.IsConnected():
                break
            else:
                yield None
        else:
            return
        yield "waiting for avatar to appear"
        ent = None
        while not self.elapsed(self.wait_time):
            try:
                ent = naali.getUserAvatar()
            except ValueError:
                yield None
            else:
                break
        
        if not ent:
            yield "failure, avatar didn't appear"
            return

        print 'dynamic property stuff:'
        ent.GetOrCreateComponentRaw("EC_DynamicComponent")
        print ent, type(ent)
        d = ent.qent.EC_DynamicComponent
        val = 42.0
        d.CreateAttribute("real", val)
        d.ComponentChanged(0)
        assert val == d.GetAttribute("real")

        val = 8.5
        d.SetAttribute("real", val)
        d.ComponentChanged(0)
        assert val == d.GetAttribute("real")
        d.RemoveAttribute("real")
        d.ComponentChanged(0)

        yield "created, changed and removed attribute"
        r.exit()
        yield "success"
Beispiel #9
0
    def run(self):
        self.wait_time = int(self.config.get("wait_time", 60))
        yield "doing login"
        self.timer_start()
        r.startLoginOpensim(user, pwd, server)
        yield "waiting for connection"
        conn = None
        while not self.elapsed(self.wait_time):
            conn = r.getServerConnection()
            if conn and conn.IsConnected():
                break
            else:
                yield None
        else:
            return
        yield "waiting for avatar to appear"
        ent = None
        while not self.elapsed(self.wait_time):
            try:
                ent = naali.getUserAvatar()
            except ValueError:
                yield None
            else:
                break

        if not ent:
            yield "failure, avatar didn't appear"
            return

        print 'dynamic property stuff:'
        ent.GetOrCreateComponentRaw("EC_DynamicComponent")
        print ent, type(ent)
        d = ent.qent.EC_DynamicComponent
        val = 42.0
        d.CreateAttribute("real", val)
        d.ComponentChanged(0)
        assert val == d.GetAttribute("real")

        val = 8.5
        d.SetAttribute("real", val)
        d.ComponentChanged(0)
        assert val == d.GetAttribute("real")
        d.RemoveAttribute("real")
        d.ComponentChanged(0)

        yield "created, changed and removed attribute"
        r.exit()
        yield "success"
Beispiel #10
0
    def testBillboard(self):
        avatar = naali.getUserAvatar()
        avatar_pos = avatar.GetComponentRaw("EC_Placeable")

        self.pixmap_label = QLabel()
        self.pixmap_label.size = QSize(200, 200)
        self.pixmap_label.scaledContents = True
        self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png'))

        self.text_label = QLabel()
        self.text_label.size = QSize(300, 50)
        self.text_label.text = "Hello world"

        self.my_widget = QWidget()
        self.my_widget.setLayout(QVBoxLayout())
        self.my_widget.layout().addWidget(self.pixmap_label)
        self.my_widget.layout().addWidget(self.text_label)

        if self.my_widget is None:
            print("Cannot find image file.")
            return

        self.my_entity = naali.createEntity()
        position = self.my_entity.GetOrCreateComponentRaw(
            "EC_Placeable", "pos",
            PythonQt.private.AttributeChange.Disconnected, False)
        position.position = avatar_pos.position

        self.ec_billboard = self.my_entity.GetOrCreateComponentRaw(
            "EC_BillboardWidget", "test",
            PythonQt.private.AttributeChange.Disconnected, False)
        if self.ec_billboard is None:
            print("Cannot create EC_Billboard component.")
            return

        self.ec_billboard.SetPosition(0, 0, 1)
        self.ec_billboard.SetWidth(1)
        self.ec_billboard.SetHeight(1)
        self.ec_billboard.SetWidget(self.my_widget)

        self.size_timer = QTimer()
        self.size_timer.connect("timeout()", self.animateSize)
        self.size_timer.start(100)

        self.text_timer = QTimer()
        self.text_timer.connect("timeout()", self.animateText)
        self.text_timer.start(1000)
Beispiel #11
0
	def testBillboard(self):	
		avatar = naali.getUserAvatar()
		avatar_pos = avatar.GetComponentRaw("EC_Placeable")
		
		self.pixmap_label = QLabel()
		self.pixmap_label.size = QSize(200,200)
		self.pixmap_label.scaledContents = True
		self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png'))

		self.text_label = QLabel()
		self.text_label.size = QSize(300,50)
		self.text_label.text = "Hello world"

		self.my_widget = QWidget()
		self.my_widget.setLayout(QVBoxLayout())
		self.my_widget.layout().addWidget(self.pixmap_label)
		self.my_widget.layout().addWidget(self.text_label)
		
		if self.my_widget is None:
			print("Cannot find image file.")
			return
			
		self.my_entity = naali.createEntity()
		position = self.my_entity.GetOrCreateComponentRaw("EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False)
		position.position = avatar_pos.position
		
		self.ec_billboard = self.my_entity.GetOrCreateComponentRaw("EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False)
		if self.ec_billboard is None:
			print("Cannot create EC_Billboard component.")
			return
	
		self.ec_billboard.SetPosition(0,0,1)
		self.ec_billboard.SetWidth(1)
		self.ec_billboard.SetHeight(1)
		self.ec_billboard.SetWidget(self.my_widget)
		
		self.size_timer = QTimer()
		self.size_timer.connect("timeout()", self.animateSize)
		self.size_timer.start(100)
		 
		self.text_timer = QTimer()
		self.text_timer.connect("timeout()", self.animateText)
		self.text_timer.start(1000)
Beispiel #12
0
    hmm = r.switchCameraState()
    #print hmm
    
if 0: #get entity
    #idnum = new_id
    idnum = naali.getCamera().id
    print "Getting entity id", idnum,
    e = naali.getEntity(idnum)
    print "got:", e
    #print dir(r)
    #rotate(e)
    #move(e)

if 0: #test avatartracking, works :)
    try:
        a = naali.getUserAvatar()
    except ValueError:
        print "could find the user avatar"
    else:
        print "<:::",
        print "Avatar pos:", a.placeable.Position,
        print ":::>"
        """
        perhaps some local script could track movement?
        make a sound of a nearby object of interest, 
        like when a pet or a friend moves?
        """
        
        if 0:
            #test what happens when we move the av
            #a.pos = a.pos[0] + 1, a.pos[1], a.pos[2]
Beispiel #13
0
 def validId(self, id):
     if id != 0 and id > 50: #terrain seems to be 3 and scene objects always big numbers, so > 50 should be good, though randomly created local entities can get over 50...
         if id != naali.getUserAvatar().id: #XXX add other avatar id's check
             if not self.manipulator.compareIds(id):  #and id != self.selection_box.id:
                 return True
     return False
Beispiel #14
0
    def do_api_calls(self):
        yield "createMeshEntity"
        e = naali.createMeshEntity("axes.mesh")

        from PythonQt.QtGui import QVector3D, QQuaternion
        e.placeable.position = QVector3D(128, 128, 60)
        e.placeable.Scale = QVector3D(5, 5, 5)
        e.placeable.Orientation = QQuaternion(0, 0, 0, 1)
        r.removeEntity(e.Id)

        yield "EC_Touchable & EC_Highlight"
        for longname, shortname in [("EC_Touchable", 'touchable'), ("EC_Highlight", 'highlight')]:
            e = naali.getUserAvatar()
            e.GetOrCreateComponentRaw(longname)
            x = getattr(e, shortname)
            x.Show()
            x.Hide()
            assert x.IsVisible() == False

        yield "naali.createEntity"
        ent = naali.createEntity()
        print "new entity created:", ent

        yield "get camera FOV"
        fov = naali.getCamera().camera.GetVerticalFov()
        
        yield "avatar position"
        p = naali.getUserAvatar().placeable.position

        yield "avatar animation controller"
        naali.getUserAvatar().animationcontroller.EnableAnimation("Walk")

        yield "test sendChat"
        r.sendChat("test chat")

        yield "test logInfo"
        r.logInfo("test log message")

        #XXX deprecate
        yield "test camera yaw/itch"
        r.setCameraYawPitch(.1, .5)
        r.getCameraYawPitch()
        
        yield "test webview"
        import PythonQt
        wv = PythonQt.QtWebKit.QWebView()
        wv.show()

        yield "test dotscene loading"
        from localscene import loader
        loader.load_dotscene("pymodules/localscene/test.scene")
    
        yield "test dynamic component"
        ent = naali.getUserAvatar()
        ent.GetOrCreateComponentRaw("EC_DynamicComponent")
        print ent, type(ent)
        d = ent.EC_DynamicComponent
        d.CreateAttribute("real", 42.0)
        d.ComponentChanged(0)
        d.SetAttribute("real", 8.5)
        d.ComponentChanged(0)
        d.RemoveAttribute("real")
        d.ComponentChanged(0)

        yield "test javascript"
        cam = naali.getCamera()
        naali.runjs('print("Hello from JS! " + x)', {'x': naali.renderer})
        naali.runjs('print("Another hello from JS! " + x)', {'x': naali.inputcontext})
        naali.runjs('print("Some camera! " + x)', {'x': cam.camera})
        #py objects are not qobjects. naali.runjs('print("Some camera, using naali :O ! " + x.getCamera())', {'x': naali})
        naali.runjs('print("Camera Entity " + x)', {'x': cam})
        naali.runjs('print("Camera placeable pos: " + pos)', {'pos': cam.placeable.position})
        #not exposed yet. naali.runjs('print("QVector3D: " + new QVector3D())', {})
        #naali.runjs('var a = {"a": true, "b": 2};')
        #naali.runjs('print(a.a + ", " + a.b)')
        #naali.runjs('print(JSON.stringify(a))')
        #naali.runjs('print("1 + 1 == " + 1 + 1)')
        #naali.runjs('print("1 - 1 == " + 1 - 1)')
        print ", done."

        if 0:
            runjs('var b = new QPushButton;')
            runjs('b.text = "hep";')
            runjs('b.show();')
Beispiel #15
0
    def do_api_calls(self):
        yield "createMeshEntity"
        e = naali.createMeshEntity("axes.mesh")

        from PythonQt.QtGui import QVector3D, QQuaternion
        e.placeable.position = QVector3D(128, 128, 60)
        e.placeable.Scale = QVector3D(5, 5, 5)
        e.placeable.Orientation = QQuaternion(0, 0, 0, 1)
        r.removeEntity(e.Id)

        yield "EC_Touchable & EC_Highlight"
        for longname, shortname in [("EC_Touchable", 'touchable'),
                                    ("EC_Highlight", 'highlight')]:
            e = naali.getUserAvatar()
            e.GetOrCreateComponentRaw(longname)
            x = getattr(e, shortname)
            x.Show()
            x.Hide()
            assert x.IsVisible() == False

        yield "naali.createEntity"
        ent = naali.createEntity()
        print "new entity created:", ent

        yield "get camera FOV"
        fov = naali.getCamera().camera.GetVerticalFov()

        yield "avatar position"
        p = naali.getUserAvatar().placeable.position

        yield "avatar animation controller"
        naali.getUserAvatar().animationcontroller.EnableAnimation("Walk")

        yield "test sendChat"
        r.sendChat("test chat")

        yield "test logInfo"
        r.logInfo("test log message")

        #XXX deprecate
        yield "test camera yaw/itch"
        r.setCameraYawPitch(.1, .5)
        r.getCameraYawPitch()

        yield "test webview"
        import PythonQt
        wv = PythonQt.QtWebKit.QWebView()
        wv.show()

        yield "test dotscene loading"
        from localscene import loader
        loader.load_dotscene("pymodules/localscene/test.scene")

        yield "test dynamic component"
        ent = naali.getUserAvatar()
        ent.GetOrCreateComponentRaw("EC_DynamicComponent")
        print ent, type(ent)
        d = ent.EC_DynamicComponent
        d.CreateAttribute("real", 42.0)
        d.ComponentChanged(0)
        d.SetAttribute("real", 8.5)
        d.ComponentChanged(0)
        d.RemoveAttribute("real")
        d.ComponentChanged(0)

        yield "test javascript"
        cam = naali.getCamera()
        naali.runjs('print("Hello from JS! " + x)', {'x': naali.renderer})
        naali.runjs('print("Another hello from JS! " + x)',
                    {'x': naali.inputcontext})
        naali.runjs('print("Some camera! " + x)', {'x': cam.camera})
        #py objects are not qobjects. naali.runjs('print("Some camera, using naali :O ! " + x.getCamera())', {'x': naali})
        naali.runjs('print("Camera Entity " + x)', {'x': cam})
        naali.runjs('print("Camera placeable pos: " + pos)',
                    {'pos': cam.placeable.position})
        #not exposed yet. naali.runjs('print("QVector3D: " + new QVector3D())', {})
        #naali.runjs('var a = {"a": true, "b": 2};')
        #naali.runjs('print(a.a + ", " + a.b)')
        #naali.runjs('print(JSON.stringify(a))')
        #naali.runjs('print("1 + 1 == " + 1 + 1)')
        #naali.runjs('print("1 - 1 == " + 1 - 1)')
        print ", done."

        if 0:
            runjs('var b = new QPushButton;')
            runjs('b.text = "hep";')
            runjs('b.show();')
Beispiel #16
0
    hmm = r.switchCameraState()
    #print hmm

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

if 0:  #test avatartracking, works :)
    try:
        a = naali.getUserAvatar()
    except ValueError:
        print "could find the user avatar"
    else:
        print "<:::",
        print "Avatar pos:", a.placeable.Position,
        print ":::>"
        """
        perhaps some local script could track movement?
        make a sound of a nearby object of interest, 
        like when a pet or a friend moves?
        """

        if 0:
            #test what happens when we move the av
            #a.pos = a.pos[0] + 1, a.pos[1], a.pos[2]