def on_mouseleftreleased(self, mouseinfo): self.left_button_down = False if self.active: #XXX something here? if self.sel_activated and self.dragging: for ent in self.sels: #~ print "LeftMouseReleased, networkUpdate call" parent, children = self.parentalCheck(ent) r.networkUpdate(ent.id) for child in children: child_id = int(child) r.networkUpdate(child_id) self.sel_activated = True if self.dragging: self.dragging = False self.manipulator.stopManipulating() self.manipulator.showManipulator(self.sels) self.usingManipulator = False if self.selection_rect_startpos is not None: self.selection_rect.hide() rectx, recty, rectwidth, rectheight = self.selectionRectDimensions( mouseinfo) if rectwidth != 0 and rectheight != 0: r.logInfo("The selection rect was at: (" + str(rectx) + ", " + str(recty) + ") and size was: (" + str(rectwidth) + ", " + str(rectheight) + ")") self.selection_rect.setGeometry(0, 0, 0, 0) self.selection_rect_startpos = None
def changescale(self, i, v): ent = self.active if ent is not None: qscale = ent.placeable.Scale oldscale = list((qscale.x(), qscale.y(), qscale.z())) scale = list((qscale.x(), qscale.y(), qscale.z())) if not self.float_equal(scale[i], v): scale[i] = v if self.window.mainTab.scale_lock.checked: #XXX BUG does wrong thing - the idea was to maintain aspect ratio diff = scale[i] - oldscale[i] for index in range(len(scale)): #print index, scale[index], index == i if index != i: scale[index] += diff ent.placeable.Scale = Vec(scale[0], scale[1], scale[2]) if not self.dragging: r.networkUpdate(ent.id) #self.window.update_scalevals(scale) self.modified = True
def changescale(self, i, v): ent = self.active if ent is not None: qscale = ent.placeable.Scale oldscale = list((qscale.x(), qscale.y(), qscale.z())) scale = list((qscale.x(), qscale.y(), qscale.z())) if not self.float_equal(scale[i],v): scale[i] = v if self.window.mainTab.scale_lock.checked: #XXX BUG does wrong thing - the idea was to maintain aspect ratio diff = scale[i] - oldscale[i] for index in range(len(scale)): #print index, scale[index], index == i if index != i: scale[index] += diff ent.placeable.Scale = Vec(scale[0], scale[1], scale[2]) if not self.dragging: r.networkUpdate(ent.id) #self.window.update_scalevals(scale) self.modified = True self.updateSelectionBox(ent)
def LeftMouseReleased(self, mouseinfo): self.left_button_down = False if self.active: #XXX something here? if self.sel_activated and self.dragging: for ent in self.sels: #~ print "LeftMouseReleased, networkUpdate call" parent, children = self.parentalCheck(ent) r.networkUpdate(ent.id) for child in children: child_id = int(child) r.networkUpdate(child_id) self.sel_activated = True if self.dragging: self.dragging = False self.manipulator.stopManipulating() self.duplicateDragStart = False #XXXchange? if self.selection_rect_startpos is not None: self.selection_rect.hide() rectx, recty, rectwidth, rectheight = self.selectionRectDimensions(mouseinfo) if rectwidth != 0 and rectheight != 0: r.logInfo("The selection rect was at: (" +str(rectx) + ", " +str(recty) + ") and size was: (" +str(rectwidth) +", "+str(rectheight)+")") self.selection_rect.setGeometry(0,0,0,0) self.selection_rect_startpos = None
def changerot(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere #print "pos index %i changed to: %f" % (i, v[i]) ent = self.active if ent is not None and not self.usingManipulator: ort = mu.euler_to_quat(v) ent.placeable.Orientation = ort ent.network.Orientation = ort if not self.dragging: r.networkUpdate(ent.id) self.modified = True
def changerot(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere #print "pos index %i changed to: %f" % (i, v[i]) ent = self.active if ent is not None and not self.usingManipulator: quat = conv.euler_to_quat(v) # convert between conversions.Quat tuple (x,y,z,w) format and QQuaternion (w,x,y,z) # TODO: it seems that visualisation compared to what we give/understand on ob edit # level is shifted. For now leave this 'shift' in, but need to investigate later. At # least visual changes triggered through ob edit window widgets seem to correspond # better to what one expects. ort = Quat(quat[3], quat[1], quat[2], quat[0]) ent.placeable.Orientation = ort ent.network.Orientation = ort if not self.dragging: r.networkUpdate(ent.id) self.modified = True
def changepos(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere ent = self.active if ent is not None: qpos = QVector3D(ent.placeable.Position) if i == 0: qpos.setX(v) elif i == 1: qpos.setY(v) elif i == 2: qpos.setZ(v) ent.placeable.Position = qpos ent.network.Position = qpos self.manipulator.moveTo(self.sels) if not self.dragging: r.networkUpdate(ent.id) self.modified = True
def changepos(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere ent = self.active if ent is not None: qpos = QVector3D(ent.placeable.Position) if i == 0: qpos.setX(v) elif i == 1: qpos.setY(v) elif i == 2: qpos.setZ(v) ent.placeable.Position = qpos ent.network.Position = qpos self.manipulator.moveTo(self.sels) self.modified = True if not self.dragging: r.networkUpdate(ent.id)
def changepos(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere #print "pos index %i changed to: %f" % (i, v) ent = self.active if ent is not None: qpos = ent.placeable.Position pos = list((qpos.x(), qpos.y(), qpos.z())) #should probably wrap Vector3, see test_move.py for refactoring notes. if not self.float_equal(pos[i],v): pos[i] = v #converted to list to have it mutable newpos = Vec(pos[0], pos[1], pos[2]) ent.placeable.Position = newpos ent.network.Position = newpos self.manipulator.moveTo(self.sels) self.modified = True if not self.dragging: r.networkUpdate(ent.id)
def changerot(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere #print "pos index %i changed to: %f" % (i, v) ent = self.active if ent is not None: qquat = ent.placeable.Orientation euler = list(quat_to_euler((qquat.x(), qquat.y(), qquat.z(), qquat.scalar()))) if not self.float_equal(euler[i],v): euler[i] = v ort = euler_to_quat(euler) #print euler, ort #print euler, ort ort = Quat(ort[3], ort[0], ort[1], ort[2]) ent.placeable.Orientation = ort ent.network.Orientation = ort if not self.dragging: r.networkUpdate(ent.id) self.modified = True
def changerot(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere #print "pos index %i changed to: %f" % (i, v) ent = self.active if ent is not None: qquat = ent.placeable.Orientation euler = list( quat_to_euler( (qquat.x(), qquat.y(), qquat.z(), qquat.scalar()))) if not self.float_equal(euler[i], v): euler[i] = v ort = euler_to_quat(euler) #print euler, ort #print euler, ort ort = Quat(ort[3], ort[0], ort[1], ort[2]) ent.placeable.Orientation = ort ent.network.Orientation = ort if not self.dragging: r.networkUpdate(ent.id) self.modified = True
def changepos(self, i, v): #XXX NOTE / API TODO: exceptions in qt slots (like this) are now eaten silently #.. apparently they get shown upon viewer exit. must add some qt exc thing somewhere #print "pos index %i changed to: %f" % (i, v) ent = self.active if ent is not None: qpos = ent.placeable.Position pos = list( (qpos.x(), qpos.y(), qpos.z()) ) #should probably wrap Vector3, see test_move.py for refactoring notes. if not self.float_equal(pos[i], v): pos[i] = v #converted to list to have it mutable newpos = Vec(pos[0], pos[1], pos[2]) ent.placeable.Position = newpos ent.network.Position = newpos self.manipulator.moveTo(self.sels) self.modified = True if not self.dragging: r.networkUpdate(ent.id)
id1 = 1250116908 id2 = 1250116909 ids = [id1, id2] worldstream.SendObjectLinkPacket(ids) #~ worldstream.SendObjectDelinkPacket(ids) if 0: #position as a qvec3d prop of placeable component import PythonQt.QtGui id = 2703563778 ent = naali.getEntity(id) changevec = PythonQt.QtGui.QVector3D(0, 0, 1) print ent.placeable.Position, ent.placeable.Orientation, changevec ent.placeable.Position = ent.placeable.Position + changevec print ent.placeable.Position, ent.placeable.Orientation, changevec r.networkUpdate(id) if 0: import PythonQt.QtGui a = PythonQt.QtGui.QVector3D(5, 5, 1) b = PythonQt.QtGui.QVector3D(5, 5, 0) print a == b, a.toString(), b.toString() if 0: e = naali.getUserAvatar() try: e.sound except AttributeError: print e.createComponent("EC_AttachedSound") print "created a new Sound component"
ids = [id1, id2] worldstream.SendObjectLinkPacket(ids) #~ worldstream.SendObjectDelinkPacket(ids) if 0: import PythonQt.QtGui id = 2302910681 ent = r.getEntity(id) pos = PythonQt.QtGui.QVector3D(0, 0, 1) print ent.placeable.Position.toString( ), ent.placeable.Orientation.toString(), pos.toString() ent.placeable.Position = ent.placeable.Position.__add__(pos) print ent.placeable.Position.toString( ), ent.placeable.Orientation.toString(), pos.toString() r.networkUpdate(id) if 0: import PythonQt.QtGui a = PythonQt.QtGui.QVector3D(5, 5, 1) b = PythonQt.QtGui.QVector3D(5, 5, 0) print a == b, a.toString(), b.toString() if 0: ent = r.getEntity(1876645602) mesh = ent.mesh if mesh is not None: print "swoot" if 0: #create a new component, hilight e = r.getEntity(1876645543)