Beispiel #1
0
 def onImprovedTerseObjectUpdate(self, packet):
     client = self.manager.client
     for packet_ObjectData in packet['ObjectData']:
         data = packet_ObjectData['Data']
         localID = struct.unpack("<I", data[0:4])[0]
         naaliProto = False
         if len(data) == 30:
             is_avatar = True
             naaliProto = True
             idx = 4
         else:
             attachPoint = struct.unpack("<b", data[4])[0]
             is_avatar = struct.unpack("<?", data[5])[0]
             idx = 6
             if is_avatar:
                 collisionPlane = Quaternion(data[idx:idx + 16])
                 idx += 16
             minlen = idx + 12 + 6 + 6 + 6 + 8
             if is_avatar:
                 minlen += 16
             if len(data) < minlen:
                 data = data + ('\0' * (minlen - len(data)))
         pos = Vector3(data[idx:idx + 12])
         idx += 12
         vel = unpack_v3(data, idx, -128.0, 128.0)
         idx += 6
         if not naaliProto:
             accel = unpack_v3(data, idx, -64.0, 64.0)
             idx += 6
         rot = unpack_q(data, idx)
         idx += 8
         if not naaliProto:
             angular_vel = unpack_v3(data, idx, -64.0, 64.0)
         if is_avatar:
             obj = client.region.objects.get_avatar_from_store(
                 LocalID=localID)
             if not obj:
                 print("cant find avatar!!")
         else:
             obj = client.region.objects.get_object_from_store(
                 LocalID=localID)
         # print("onImprovedTerseObjectUpdate", localID, pos, vel, accel, obj)
         if obj:
             if self._eatupdates[obj.LocalID]:
                 self._eatupdates[obj.LocalID] -= 1
                 return
             obj_uuid = str(obj.FullID)
             obj.pos = v3_to_list(pos)
             obj.rot = q_to_list(rot)
             if obj_uuid and obj.pos and obj.rot:
                 self.out_queue.put(
                     ['pos', obj_uuid,
                      v3_to_list(pos),
                      q_to_list(rot)])
             else:
                 print("not avatar update")
         else:
             print("cant find object")
Beispiel #2
0
 def onImprovedTerseObjectUpdate(self, packet):
     client = self.manager.client
     for packet_ObjectData in packet['ObjectData']:
         data = packet_ObjectData['Data']
         localID = struct.unpack("<I", data[0:4])[0]
         naaliProto = False
         if len(data) == 30:
             is_avatar = True
             naaliProto = True
             idx = 4
         else:
             attachPoint = struct.unpack("<b", data[4])[0]
             is_avatar = struct.unpack("<?", data[5])[0]
             idx = 6
             if is_avatar:
                 collisionPlane = Quaternion(data[idx:idx+16])
                 idx += 16
             minlen = idx+12+6+6+6+8
             if is_avatar:
                 minlen += 16
             if len(data) < minlen:
                 data = data + ('\0'*(minlen-len(data)))
         pos = Vector3(data[idx:idx+12])
         idx += 12
         vel = unpack_v3(data, idx, -128.0, 128.0)
         idx += 6
         if not naaliProto:
             accel = unpack_v3(data, idx, -64.0, 64.0)
             idx += 6
         rot = unpack_q(data, idx)
         idx += 8
         if not naaliProto:
             angular_vel = unpack_v3(data, idx, -64.0, 64.0)
         if is_avatar:
             obj = client.region.objects.get_avatar_from_store(LocalID = localID)
             if not obj:
                 print("cant find avatar!!")
         else:
             obj = client.region.objects.get_object_from_store(LocalID = localID)
         # print("onImprovedTerseObjectUpdate", localID, pos, vel, accel, obj)
         if obj:
             if self._eatupdates[obj.LocalID]:
                 self._eatupdates[obj.LocalID]-= 1
                 return
             obj_uuid = str(obj.FullID)
             obj.pos = v3_to_list(pos)
             obj.rot = q_to_list(rot)
             if obj_uuid and obj.pos and obj.rot:
                 self.out_queue.put(['pos', obj_uuid, v3_to_list(pos), q_to_list(rot)])
             else:
                 print("not avatar update")
         else:
             print("cant find object")
Beispiel #3
0
    def finishObjectUpdate(self, obj_uuid, pars, objdata, parent_id):
        if not 'ParentID' in pars:
            parent = self.client.region.objects.get_object_from_store(
                LocalID=parent_id)
            pars["ParentID"] = str(parent.FullID)

        obj = self.client.region.objects.get_object_from_store(FullID=obj_uuid)
        out_queue = self.out_queue
        out_queue.put(['props', obj_uuid, pars])
        if len(objdata) == 48:
            pos_vector = Vector3(objdata)
            vel = Vector3(objdata[12:])
            acc = Vector3(objdata[24:])
            rot = Quaternion(objdata[36:])
            if obj:
                obj.pos = v3_to_list(pos_vector)
                obj.rot = q_to_list(rot)
            out_queue.put(
                ['pos', obj_uuid,
                 v3_to_list(pos_vector),
                 q_to_list(rot)])
        elif len(objdata) == 12:
            if True:
                # position only packed as 3 floats
                pos = Vector3(objdata)
                if obj:
                    obj.pos = v3_to_list(pos)
                out_queue.put(['pos', obj_uuid, v3_to_list(pos)])
            elif ObjectData_block.Type in [4, 20, 12, 28]:
                # position only packed as 3 floats
                scale = Vector3(objdata)
                out_queue.put(['scale', obj_uuid, v3_to_list(scale)])
            elif ObjectData_block.Type in [2, 10]:
                # rotation only packed as 3 floats
                rot = Quaternion(objdata)
                out_queue.put(['rot', obj_uuid, q_to_list(rot)])

        else:
            # missing sizes: 28, 40, 44, 64
            self.logger.debug("Unparsed update of size " + str(len(objdata)))
Beispiel #4
0
    def finishObjectUpdate(self, obj_uuid, pars, objdata, parent_id):
       if not 'ParentID' in pars:
           parent =  self.client.region.objects.get_object_from_store(LocalID=parent_id)
           pars["ParentID"] = str(parent.FullID)
 
       obj = self.client.region.objects.get_object_from_store(FullID=obj_uuid)
       out_queue = self.out_queue
       out_queue.put(['props', obj_uuid, pars])
       if len(objdata) == 48:
           pos_vector = Vector3(objdata)
           vel = Vector3(objdata[12:])
           acc = Vector3(objdata[24:])
           rot = Quaternion(objdata[36:])
           if obj:
               obj.pos = v3_to_list(pos_vector)
               obj.rot = q_to_list(rot)
           out_queue.put(['pos', obj_uuid, v3_to_list(pos_vector),
                          q_to_list(rot)])
       elif len(objdata) == 12:
           if True:
               # position only packed as 3 floats
               pos = Vector3(objdata)
               if obj:
                  obj.pos = v3_to_list(pos)
               out_queue.put(['pos', obj_uuid, v3_to_list(pos)])
           elif ObjectData_block.Type in [4, 20, 12, 28]:
               # position only packed as 3 floats
               scale = Vector3(objdata)
               out_queue.put(['scale', obj_uuid, v3_to_list(scale)])
           elif ObjectData_block.Type in [2, 10]:
               # rotation only packed as 3 floats
               rot = Quaternion(objdata)
               out_queue.put(['rot', obj_uuid, q_to_list(rot)])
     
       else:
            # missing sizes: 28, 40, 44, 64
            self.logger.debug("Unparsed update of size "+str(len(objdata)))