def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed and self.grabbed_axis is not None: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) ort = ent.placeable.Orientation euler = list((0, 0, 0)) if self.grabbed_axis == self.AXIS_GREEN: # rotate z-axis # print "green axis", self.grabbed_axis mov = amountx * 30 euler[2] += mov elif self.grabbed_axis == self.AXIS_BLUE: # rotate x-axis # print "blue axis", self.grabbed_axis mov = amountx * 30 euler[1] += mov elif self.grabbed_axis == self.AXIS_RED: # rotate y-axis # print "red axis", self.grabbed_axis mov = amounty * 30 euler[0] -= mov rotationQuat = list(euler_to_quat(euler)) ort.__imul__(Quat(rotationQuat[3], rotationQuat[0], rotationQuat[1], rotationQuat[2])) ent.placeable.Orientation = ort ent.network.Orientation = ort
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed: qscale = ent.placeable.Scale scale = list((qscale.x(), qscale.y(), qscale.z())) rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) if self.grabbed_axis == self.AXIS_BLUE: mov = lengthy scale[self.grabbed_axis] -= mov else: mov = lengthx div = abs(rightvec[self.grabbed_axis]) if div == 0: div = 0.01 #not the best of ideas but... mov *= rightvec[self.grabbed_axis]/div scale[self.grabbed_axis] += mov newscale = Vec(scale[0], scale[1], scale[2]) ent.placeable.Scale = newscale self.controller.updateSelectionBox(ent) qprim = ent.prim if qprim is not None: children = qprim.GetChildren() for child_id in children: child = r.getEntity(int(child_id)) child.placeable.Scale = newscale
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed and self.grabbed_axis is not None: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) ort = ent.placeable.Orientation euler = list((0, 0, 0)) if self.grabbed_axis == self.AXIS_GREEN: #rotate z-axis #print "green axis", self.grabbed_axis mov = amountx * 30 euler[2] += mov elif self.grabbed_axis == self.AXIS_BLUE: #rotate x-axis #print "blue axis", self.grabbed_axis mov = amountx * 30 euler[1] += mov elif self.grabbed_axis == self.AXIS_RED: #rotate y-axis #print "red axis", self.grabbed_axis mov = amounty * 30 euler[0] -= mov rotationQuat = list(euler_to_quat(euler)) ort.__imul__( Quat(rotationQuat[3], rotationQuat[0], rotationQuat[1], rotationQuat[2])) ent.placeable.Orientation = ort ent.network.Orientation = ort
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed: qscale = ent.placeable.Scale scale = list((qscale.x(), qscale.y(), qscale.z())) rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) if self.grabbed_axis == self.AXIS_BLUE: mov = lengthy scale[self.grabbed_axis] -= mov else: mov = lengthx div = abs(rightvec[self.grabbed_axis]) if div == 0: div = 0.01 #not the best of ideas but... mov *= rightvec[self.grabbed_axis] / div scale[self.grabbed_axis] += mov newscale = Vec(scale[0], scale[1], scale[2]) ent.placeable.Scale = newscale self.controller.updateSelectionBox(ent) qprim = ent.prim if qprim is not None: children = qprim.GetChildren() for child_id in children: child = r.getEntity(int(child_id)) child.placeable.Scale = newscale
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) changevec = (amountx * rightvec) - (amounty * upvec) qpos = ent.placeable.Position entpos = Vector3(qpos.x(), qpos.y(), qpos.z()) newpos = entpos + changevec newpos = Vec(newpos.x, newpos.y, newpos.z) ent.placeable.Position = newpos ent.network.Position = newpos
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) qpos = ent.placeable.Position if self.grabbed_axis == self.AXIS_BLUE: mov = lengthy qpos.setZ(qpos.z()-mov) else: mov = lengthx div = abs(rightvec[self.grabbed_axis]) if div == 0: div = 0.01 #not the best of ideas but... mov *= rightvec[self.grabbed_axis]/div if self.grabbed_axis == self.AXIS_GREEN: qpos.setX(qpos.x()+mov) else: qpos.setY(qpos.y()+mov) ent.placeable.Position = qpos ent.network.Position = qpos
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) qpos = ent.placeable.Position if self.grabbed_axis == self.AXIS_BLUE: mov = lengthy qpos.setZ(qpos.z() - mov) else: mov = lengthx div = abs(rightvec[self.grabbed_axis]) if div == 0: div = 0.01 #not the best of ideas but... mov *= rightvec[self.grabbed_axis] / div if self.grabbed_axis == self.AXIS_GREEN: qpos.setX(qpos.x() + mov) else: qpos.setY(qpos.y() + mov) ent.placeable.Position = qpos ent.network.Position = qpos
def manipulate(self, ents, movedx, movedy): if ents is not None: lengthx = 0 lengthy = 0 fov = r.getCameraFOV() width, height = r.getScreenSize() campos = Vector3(r.getCameraPosition()) ent = ents[-1] qpos = ent.placeable.Position entpos = Vector3(qpos.x(), qpos.y(), qpos.z()) length = (campos-entpos).length worldwidth = (math.tan(fov/2)*length) * 2 worldheight = (height*worldwidth) / width #used in freemoving to get the size of movement right amountx = (worldwidth * movedx) amounty = (worldheight * movedy) if self.usesManipulator and self.grabbed_axis is not None: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) temp = [0,0,0] temp[self.grabbed_axis] = 1 axis_vec = Vector3(temp) #print amountx, amounty mousey_on_arrow_projection = upvec.dot(axis_vec) * axis_vec lengthy = mousey_on_arrow_projection.length * amounty mousex_on_arrow_projection = rightvec.dot(axis_vec) * axis_vec lengthx = mousex_on_arrow_projection.length * amountx for ent in ents: self._manipulate(ent, amountx, amounty, lengthx, lengthy) if self.usesManipulator: self.moveTo(ents)
def manipulate(self, ents, movedx, movedy): if ents is not None: lengthx = 0 lengthy = 0 fov = r.getCameraFOV() width, height = r.getScreenSize() campos = Vector3(r.getCameraPosition()) ent = ents[-1] qpos = ent.placeable.Position entpos = Vector3(qpos.x(), qpos.y(), qpos.z()) length = (campos - entpos).length worldwidth = (math.tan(fov / 2) * length) * 2 worldheight = (height * worldwidth) / width #used in freemoving to get the size of movement right amountx = (worldwidth * movedx) amounty = (worldheight * movedy) if self.usesManipulator and self.grabbed_axis is not None: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) temp = [0, 0, 0] temp[self.grabbed_axis] = 1 axis_vec = Vector3(temp) #print amountx, amounty mousey_on_arrow_projection = upvec.dot(axis_vec) * axis_vec lengthy = mousey_on_arrow_projection.length * amounty mousex_on_arrow_projection = rightvec.dot(axis_vec) * axis_vec lengthx = mousex_on_arrow_projection.length * amountx for ent in ents: self._manipulate(ent, amountx, amounty, lengthx, lengthy) if self.usesManipulator: self.moveTo(ents)
print e start_x = e.pos[0] start_y = e.pos[1] start_z = e.pos[2] worldstream = r.getServerConnection() worldstream.SendObjectAddPacket(start_x, start_y, start_z) if 0: #getUserAvatar ent = naali.getUserAvatar() print "User's avatar_id:", ent.id #print "Avatar's mesh_name:", ent.mesh.GetMeshName(0) #ent.mesh = "cruncah1.mesh" if 0: print r.getCameraUp() print r.getCameraRight() if 0: #test changing the mesh asset a prim is using ent_id = 2088826433 #print arkku_id, type(arkku_id) ent = naali.getEntity(ent_id) print "Test entity:", ent print ent.mesh #ent.mesh = 1 #should raise an exception #ruukku = "681b1680-fab5-4203-83a7-c567571c6acf" #penkki = "04d335b6-8f0c-480e-a941-33517bf438d8" jack = "6b9cf239-d1ec-4290-8bc7-f5ac51288dea" #on w.r.o:9000 ent.mesh.SetMesh(jack) #"35da6174-8743-4026-a83e-18b23984120d" print "new mesh set:", ent.mesh
start_z = e.pos[2] end_x = e.pos[0] end_y = e.pos[1] end_z = e.pos[2] r.sendObjectAddPacket(start_x, start_y, start_z, end_x, end_y, end_z) if 0: id = r.getUserAvatarId() ent = r.getEntity(id) print "User's avatar_id:", id print "Avatar's mesh_name:", ent.mesh ent.mesh = "cruncah1.mesh" if 0: print r.getCameraUp() print r.getCameraRight() if 0: #test changing the mesh asset a prim is using ent_id = 1659586053 #penkki, arkku was: 2461025163 #print arkku_id, type(arkku_id) ent = r.getEntity(ent_id) print "Test entity:", ent print ent.mesh ent.mesh = 1 #should raise an exception ruukku = "681b1680-fab5-4203-83a7-c567571c6acf" penkki = "04d335b6-8f0c-480e-a941-33517bf438d8" ent.mesh = penkki #"35da6174-8743-4026-a83e-18b23984120d" print "new mesh set:", ent.mesh print "sending prim data update to server"
def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): if self.grabbed and self.grabbed_axis is not None: rightvec = Vector3(r.getCameraRight()) upvec = Vector3(r.getCameraUp()) ort = ent.placeable.Orientation euler = list((0, 0, 0)) if self.grabbed_axis == self.AXIS_GREEN: #rotate z-axis #print "green axis", self.grabbed_axis mov = amountx * 30 euler[2] += mov elif self.grabbed_axis == self.AXIS_BLUE: #rotate x-axis #print "blue axis", self.grabbed_axis mov = amountx * 30 euler[1] += mov elif self.grabbed_axis == self.AXIS_RED: #rotate y-axis #print "red axis", self.grabbed_axis mov = amounty * 30 euler[0] -= mov rotationQuat = list(euler_to_quat(euler)) ort.__imul__(Quat(rotationQuat[3], rotationQuat[0], rotationQuat[1], rotationQuat[2])) ent.placeable.Orientation = ort ent.network.Orientation = ort #~ def _manipulate(self, ent, amountx, amounty, lengthx, lengthy): #~ if self.grabbed and self.grabbed_axis is not None: #~ #print "rotating...", self.grabbed_axis #~ #print "amounts: ", amountx, amounty #~ #print "lengths: ", lengthx, lengthy #~ rightvec = Vector3(r.getCameraRight()) #~ upvec = Vector3(r.getCameraUp()) #~ x, y, z, w = ent.orientation #~ ort = Quat(w, x, y, z) #~ euler = list((0, 0, 0)) #~ if self.grabbed_axis == self.AXIS_GREEN: #rotate z-axis #~ #print "green axis", self.grabbed_axis #~ mov = amountx * 30 #~ euler[2] += mov #~ elif self.grabbed_axis == self.AXIS_BLUE: #rotate x-axis #~ #print "blue axis", self.grabbed_axis #~ mov = amountx * 30 #~ euler[1] += mov #~ elif self.grabbed_axis == self.AXIS_RED: #rotate y-axis #~ #print "red axis", self.grabbed_axis #~ mov = amounty * 30 #~ euler[0] -= mov #~ rotationQuat = list(euler_to_quat(euler)) #~ ort.__imul__(Quat(rotationQuat[3], rotationQuat[0], rotationQuat[1], rotationQuat[2])) #~ ent.orientation = ort.x(), ort.y(), ort.z(), ort.scalar()