Beispiel #1
0
    def create_naali_meshentity(self):
        self.naali_ent = naali.createMeshEntity(self.object.mesh, 100002) #XXX handle name too. what about id?

        e = self.naali_ent
        print "Created naali entity:", e, e.id
            
        """apply pos, rot & scale. 
        dotscene.py uses qt types now directly"""
        p = e.placeable
        mp = self.position
        p.Position = self.position
            
        o = self.orientation
        # XXX IMO this is wrong: content creators should export their assets correctly, instead of doing
        # this kind of rotations during import. But I guess this is old problem and similar rotations
        # are being done elsewhere too.
        # looks like objects are often exported wrong, so rotate along x axis
        #p.Orientation = o * Quat(1,1,0,0)
        # XXX if artists want rotate along x axis they can do it so now by checking flip z-y checkbox
        # at the moment it looks like, its needed to rotate each node 180 degrees along z axis to get it right
        #p.Orientation = o * Quat(1,0,0,1) * Quat(1,0,0,1)
        #p.Orientation = o * Quat(math.sqrt(0.5),0,0,math.sqrt(0.5)) * Quat(math.sqrt(0.5),0,0,math.sqrt(0.5))
        rotate90z = Quat(1,0,0,1)
        rotate90z.normalize() # ekvivalent of sqrt Quat above, (this fixes collisions)
        p.Orientation = o * rotate90z* rotate90z
        
        p.Scale = self.scale
Beispiel #2
0
 def createManipulator(self):
     if self.manipulator is None and self.usesManipulator:
         # create a local temporary entity, we dont want to sync this at least for now
         # as there is no deletion code when you leave the server!
         ent = naali.createMeshEntity(self.MANIPULATOR_MESH_NAME, 606847240, ["EC_Gizmo", "EC_Ruler"], localonly = True, temporary = True)
         ent.SetName(self.NAME)
         ent.ruler.SetVisible(False)
         ent.ruler.SetType(self.MANIPULATOR_RULER_TYPE)
         ent.ruler.UpdateRuler()
         return ent
Beispiel #3
0
 def createManipulator(self):
     if self.manipulator is None and self.usesManipulator:
         ent = naali.createMeshEntity(self.MANIPULATOR_MESH_NAME, 606847240) 
         gizmo = ent.GetOrCreateComponentRaw("EC_Gizmo")
         ruler = ent.GetOrCreateComponentRaw("EC_Ruler")
         ruler.SetVisible(False)
         #r.logInfo("hide ruler createManipulator")
         ruler.SetType(self.MANIPULATOR_RULER_TYPE)
         ruler.UpdateRuler()
         return ent 
Beispiel #4
0
 def createManipulator(self):
     if self.manipulator is None and self.usesManipulator:
         # create a local temporary entity, we dont want to sync this at least for now
         # as there is no deletion code when you leave the server!
         ent = naali.createMeshEntity(self.MANIPULATOR_MESH_NAME,
                                      606847240, ["EC_Gizmo", "EC_Ruler"],
                                      localonly=True,
                                      temporary=True)
         ent.SetName(self.NAME)
         ent.ruler.SetVisible(False)
         ent.ruler.SetType(self.MANIPULATOR_RULER_TYPE)
         ent.ruler.UpdateRuler()
         return ent
Beispiel #5
0
    
    #mm.INPUT_EVENT(r.MoveForwardPressed)
    
    #a chat message again now too
    #mm.RexNetMsgChatFromSimulator("Bob", "- that's me, Bob.")
    
    #previous pyglet stuff, was an ncoming chat msg event
    #m.dispatch_event('on_chat', "input", "testing")
    #print viewer._event_stack

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
Beispiel #6
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 #7
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 #8
0
    #mm.INPUT_EVENT(r.MoveForwardPressed)

    #a chat message again now too
    #mm.RexNetMsgChatFromSimulator("Bob", "- that's me, Bob.")

    #previous pyglet stuff, was an ncoming chat msg event
    #m.dispatch_event('on_chat', "input", "testing")
    #print viewer._event_stack

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
Beispiel #9
0
    
    #mm.INPUT_EVENT(r.MoveForwardPressed)
    
    #a chat message again now too
    #mm.RexNetMsgChatFromSimulator("Bob", "- that's me, Bob.")
    
    #previous pyglet stuff, was an ncoming chat msg event
    #m.dispatch_event('on_chat', "input", "testing")
    #print viewer._event_stack

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