Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
    import time; time.sleep(1)
    r.ShowCurrentWorldView()

if 0: #worldstream
    worldstream = r.getServerConnection()
    print "send drop bomb:", worldstream.SendGenericMessage("DropBomb", ["here", "soon", "BIG"])

if 0: #scene, aka. SceneManager
    import naali
    s = naali.getScene("World")
    print s

if 0: #javascript service
    import naali
    from naali import runjs
    runjs('print("Hello from JS! " + x)', {'x': naali.renderer})
    runjs('print("Another hello from JS! " + x)', {'x': naali.inputcontext})
    runjs('print("Some camera! " + x)', {'x': naali.getCamera()})
    runjs('print("Some camera, using naali :O ! " + x.getCamera())', {'x': naali})
    runjs('print("Camera Entity " + x)', {'x': naali.getCameraEntity()})
    #runjs('var a = {"a": true, "b": 2};')
    #runjs('print(a.a + ", " + a.b)')
    #runjs('print(JSON.stringify(a))')
    #runjs('print("1 + 1 == " + 1 + 1)')
    #runjs('print("1 - 1 == " + 1 - 1)')
    print ", done."

    if 0:
        runjs('var b = new QPushButton;')
        runjs('b.text = "hep";')
        runjs('b.show();')
Beispiel #4
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 #5
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 #6
0
    r.ShowCurrentWorldView()

if 0:  #worldstream
    worldstream = r.getServerConnection()
    print "send drop bomb:", worldstream.SendGenericMessage(
        "DropBomb", ["here", "soon", "BIG"])

if 0:  #scene, aka. SceneManager
    import naali
    s = naali.getScene("World")
    print s

if 0:  #javascript service
    import naali
    from naali import runjs
    runjs('print("Hello from JS! " + x)', {'x': naali.renderer})
    runjs('print("Another hello from JS! " + x)', {'x': naali.inputcontext})
    runjs('print("Some camera! " + x)', {'x': naali.getCamera()})
    runjs('print("Some camera, using naali :O ! " + x.getCamera())',
          {'x': naali})
    runjs('print("Camera Entity " + x)', {'x': naali.getCameraEntity()})
    #runjs('var a = {"a": true, "b": 2};')
    #runjs('print(a.a + ", " + a.b)')
    #runjs('print(JSON.stringify(a))')
    #runjs('print("1 + 1 == " + 1 + 1)')
    #runjs('print("1 - 1 == " + 1 - 1)')
    print ", done."

    if 0:
        runjs('var b = new QPushButton;')
        runjs('b.text = "hep";')
Beispiel #7
0
    r.ShowCurrentWorldView()

if 0: #worldstream
    worldstream = r.getServerConnection()
    print "send drop bomb:", worldstream.SendGenericMessage("DropBomb", ["here", "soon", "BIG"])

if 0: #scene, aka. SceneManager
    import naali
    s = naali.getScene("World")
    print s

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

    if 0:
        runjs('var b = new QPushButton;')