def create_naali_meshentity(self): self.naali_ent = rexviewer.createEntity( 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. XXX this could skip all conversions, like quat now, by dotscene.py doing the qt types directly""" p = e.placeable #p.Position = Vec(*self.position) mp = self.position #p.Position = Vec(-mp[0], mp[2], mp[1]) #p.Position = Vec(mp[0]+127, mp[1]+127, mp[2]+200) p.Position = Vec(mp[0] + 127, mp[1] + 127, mp[2] + 25) #print p.Position.toString(), self.position #print p.Orientation.toString(), self.orientation mo = self.orientation #mock to where dotscene was read o = Quat(mo.w, mo.x, mo.y, mo.z) #print dir(o) o.__imul__(Quat(1, 1, 0, 0)) #o.__imul__(Quat(1, 0, 1, 0)) p.Orientation = o #print p.Orientation.toString(), o.toString() p.Scale = Vec(*self.scale)
def create_naali_meshentity(self): self.naali_ent = rexviewer.createEntity(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. XXX this could skip all conversions, like quat now, by dotscene.py doing the qt types directly""" p = e.placeable #p.Position = Vec(*self.position) mp = self.position #p.Position = Vec(-mp[0], mp[2], mp[1]) #p.Position = Vec(mp[0]+127, mp[1]+127, mp[2]+200) p.Position = Vec(mp[0]+127, mp[1]+127, mp[2]+25) #print p.Position.toString(), self.position #print p.Orientation.toString(), self.orientation mo = self.orientation #mock to where dotscene was read o = Quat(mo.w, mo.x, mo.y, mo.z) #print dir(o) o.__imul__(Quat(1, 1, 0, 0)) #o.__imul__(Quat(1, 0, 1, 0)) p.Orientation = o #print p.Orientation.toString(), o.toString() p.Scale = Vec(*self.scale)
def newclient(self, clientid, pos): # self.clients.add() ent = r.createEntity("Jack.mesh", self.previd) self.previd += 1 ent.placeable.Position = Vec3(pos[0], pos[1], SPAWNPOS[2]) print "New entity for web socket presence at", ent.placeable.Position self.clientavs[clientid] = ent
def newclient(self, clientid, pos): #self.clients.add() ent = r.createEntity("Jack.mesh", self.previd) self.previd += 1 ent.placeable.Position = Vec3(pos[0], pos[1], SPAWNPOS[2]) print "New entity for web socket presence at", ent.placeable.Position self.clientavs[clientid] = ent
def addpiece(self, x, y, piece, mesh, scale, rot): ent = r.createEntity(mesh, self.entidcount) self.entidcount += 1 #make the api func use next available id XXX p = ent.placeable p.Position = worldpos(x, y) p.Scale = scale if rot is not None: ort = p.Orientation #is a copy(?) so much get and assign the new one ort *= rot p.Orientation = rot self.pos2piece[(x, y)] = ent
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()
print rend.GetWindowWidth(), rend.GetWindowHeight() if 0: #didn't port the above vec getters now to current x = 613 y = 345 normalized_width = 1/width normalized_height = 1/height #print x * normalized_width length = (campos-entpos).length worldwidth = (math.tan(fov/2)*length) * 2 #print campos, entpos, length, fov, width, height ent1 = r.createEntity("cruncah.mesh") ent1.pos = pos.x, pos.y+worldwidth/2, pos.z ent2 = r.createEntity("cruncah.mesh") ent2.pos = pos.x, pos.y+worldwidth/2, pos.z #~ newpos = #~ print newpos if 0: #bounding box tests. not ported to naali.Entity now, is not used anymore by obedit either? #robo 1749872183 #ogrehead 1749872798 ent = r.getEntity(1749871222)#naali.getUserAvatar() from editgui.vector3 import Vector3 as V3 #~ print ent.boundingbox bb = list(ent.boundingbox) print bb
#m.dispatch_event('on_chat', "input", "testing") #print viewer._event_stack if 0: #create entity #not safe now: """ New entity created:16:39:22 [Foundation] Error: Can't create entity with given i d because it's already used: 9999999 Assertion failed: px != 0, file D:\k2\rex\viewer\trunk\external_libs\include\boo st/shared_ptr.hpp, line 419 """ print "Testing entity creation" meshname = "axes.mesh" avatar = r.getEntity(r.getUserAvatarId()) ent = r.createEntity(meshname) #print "New entity created:", ent, ent.pos ent.pos = avatar.pos ent.scale = 0.0, 0.0, 0.0 #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."
def createManipulator(self): if self.manipulator is None and self.usesManipulator: ent = r.createEntity(self.MANIPULATOR_MESH_NAME, 606847240) return ent
print rend.GetWindowWidth(), rend.GetWindowHeight() if 0: #didn't port the above vec getters now to current x = 613 y = 345 normalized_width = 1 / width normalized_height = 1 / height #print x * normalized_width length = (campos - entpos).length worldwidth = (math.tan(fov / 2) * length) * 2 #print campos, entpos, length, fov, width, height ent1 = r.createEntity("cruncah.mesh") ent1.pos = pos.x, pos.y + worldwidth / 2, pos.z ent2 = r.createEntity("cruncah.mesh") ent2.pos = pos.x, pos.y + worldwidth / 2, pos.z #~ newpos = #~ print newpos if 0: #bounding box tests. not ported to naali.Entity now, is not used anymore by obedit either? #robo 1749872183 #ogrehead 1749872798 ent = r.getEntity(1749871222) #naali.getUserAvatar() from editgui.vector3 import Vector3 as V3 #~ print ent.boundingbox bb = list(ent.boundingbox) print bb #~ scale = list(ent.scale)