def on_sceneadded(self, name): #XXX port to SceneAPI SceneAdded signal if self.scene is not None: #XXX what to do with scene changes? aren't supposed to happen on server i guess? print "IRC: WARNING -- reiniting with new scene, not really written for scene changing though!" self.scene = naali.getScene(name) self.scene.connect( "EntityCreated(Scene::Entity*, AttributeChange::Type)", self.onNewEntity)
def on_sceneadded(self, name): #print "Scene added:", name#, s = naali.getScene(name) #s.connect("ComponentInitialized(Foundation::ComponentInterface*)", self.onComponentInitialized) s.connect("ComponentAdded(Scene::Entity*, IComponent*, AttributeChange::Type)", self.onComponentAdded) s.connect("ComponentRemoved(Scene::Entity*, IComponent*, AttributeChange::Type)", self.onComponentRemoved)
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
def on_sceneadded(self, name): #print "Scene added:", name#, s = naali.getScene(name) #s.connect("ComponentInitialized(Foundation::ComponentInterface*)", self.onComponentInitialized) s.connect( "ComponentAdded(Scene::Entity*, Foundation::ComponentInterface*, AttributeChange::Type)", self.onComponentAdded)
def sceneadded(self, name): #r.logInfo("CreateDestroy sceneadded called") self.scene = naali.getScene(name) self.scene.connect( "EntityCreated(Scene::Entity*, AttributeChange::Type)", self.handle_entity_created) r.logInfo("EntityCreated callback registered")
def on_sceneadded(self, name): '''Connects to various signal when scene is added''' self.scene = naali.getScene(name) self.scene.connect("AttributeChanged(IComponent*, IAttribute*, AttributeChange::Type)", onAttributeChanged) self.scene.connect("EntityCreated(Scene::Entity*, AttributeChange::Type)", onNewEntity) self.scene.connect("ComponentAdded(Scene::Entity*, IComponent*, AttributeChange::Type)", onComponentAdded) self.scene.connect("EntityRemoved(Scene::Entity*, AttributeChange::Type)", onEntityRemoved)
def on_sceneadded(self, name): '''Connects to various signal when scene is added''' self.scene = naali.getScene(name) self.scene.connect( "AttributeChanged(IComponent*, IAttribute*, AttributeChange::Type)", onAttributeChanged) self.scene.connect( "EntityCreated(Scene::Entity*, AttributeChange::Type)", onNewEntity) self.scene.connect( "ComponentAdded(Scene::Entity*, IComponent*, AttributeChange::Type)", onComponentAdded) self.scene.connect( "EntityRemoved(Scene::Entity*, AttributeChange::Type)", onEntityRemoved)
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") self.ents = s.GetEntitiesWithComponentRaw("EC_OpenSimPresence") 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
import naali print naali.renderer r = naali.renderer r.HideCurrentWorldView() r.Render() 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)')
def on_sceneadded(self, name): #XXX port to SceneAPI SceneAdded signal if self.scene is not None: #XXX what to do with scene changes? aren't supposed to happen on server i guess? print "IRC: WARNING -- reiniting with new scene, not really written for scene changing though!" self.scene = naali.getScene(name) self.scene.connect("EntityCreated(Scene::Entity*, AttributeChange::Type)", self.onNewEntity)
def sceneadded(self, name): #r.logInfo("CreateDestroy sceneadded called") self.scene = naali.getScene(name)
def onSceneAdded(self, scenename): self.scene = naali.getScene(scenename) self.scene.connect( "EntityCreated(Scene::Entity*, AttributeChange::Type)", self.onNewEntity)
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
r = naali.renderer r.HideCurrentWorldView() r.Render() 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)')
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
def sceneadded(self, name): #r.logInfo("CreateDestroy sceneadded called") self.scene = naali.getScene(name) self.scene.connect("EntityCreated(Scene::Entity*, AttributeChange::Type)", self.handle_entity_created) r.logInfo("EntityCreated callback registered")
def onSceneAdded(self, scenename): self.scene = naali.getScene(scenename) self.scene.connect("EntityCreated(Scene::Entity*, AttributeChange::Type)", self.onNewEntity)
def on_sceneadded(self, name): #camera is only created upon login when the scene is created .. or a bit after :p self.scene = naali.getScene(name)
def on_sceneadded(self, name): # camera is only created upon login when the scene is created .. or a bit after :p self.scene = naali.getScene(name)