Esempio n. 1
0
    def runCommand(self, cmd):
        # serialize and create raw buffer
        serializer = mmapi.BinarySerializer()
        cmd.Store(serializer)
        commandBuf = serializer.buffer()
        #sendBuf = struct.pack("B"*len(commandBuf), *commandBuf)   # [RMS] not efficient!
        sendBuf = array.array('B',commandBuf)
        if self.debug_print:
            print "[mmRemote::runCommand] sending..."
        self.send_sock.sendto( sendBuf, (self.address, self.send_port) )
        if self.debug_print:
            print "[mmRemote::runCommand] waiting for response..."

        ready = select.select([self.receive_sock],[],[],7.0)
        if ready[0]:
            data, addr = self.receive_sock.recvfrom(1024*64)
        else:
            raise Exception('cannot connect to meshMixer')
        if self.debug_print:
            print "[mmRemote::runCommand] received result!..."
        # unpack result buffer into StoredCommands results
        #rcvList = struct.unpack("B"*len(data), data)
        rcvList = array.array('B', data)
        resultBuf = mmapi.vectorub(rcvList)
        serializer.setBuffer(resultBuf)
        cmd.Restore_Results(serializer)
Esempio n. 2
0
    def runCommand(self, cmd):
        # serialize and create raw buffer
        serializer = mmapi.BinarySerializer()
        cmd.Store(serializer)
        commandBuf = serializer.buffer()
        #sendBuf = struct.pack("B"*len(commandBuf), *commandBuf)   # [RMS] not efficient!
        sendBuf = array.array('B', commandBuf)
        if self.debug_print:
            print "[mmRemote::runCommand] sending..."
        self.send_sock.sendto(sendBuf, (self.address, self.send_port))
        if self.debug_print:
            print "[mmRemote::runCommand] waiting for response..."

        ready = select.select([self.receive_sock], [], [], 7.0)
        if ready[0]:
            data, addr = self.receive_sock.recvfrom(1024 * 64)
        else:
            raise Exception('cannot connect to meshMixer')
        if self.debug_print:
            print "[mmRemote::runCommand] received result!..."
        # unpack result buffer into StoredCommands results
        #rcvList = struct.unpack("B"*len(data), data)
        rcvList = array.array('B', data)
        resultBuf = mmapi.vectorub(rcvList)
        serializer.setBuffer(resultBuf)
        cmd.Restore_Results(serializer)
Esempio n. 3
0
def get_object_uuid(remote, object_id):
    """Return the string uuid of the scene object with the given ID"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_GetObjectUUID(object_id)
    remote.runCommand(cmd)
    byte_vec = mmapi.vectorub()
    cmd.GetSceneCommandResult_GetObjectUUID(cmd_key, byte_vec)
    return vectorub_to_string(byte_vec)
Esempio n. 4
0
def get_object_name(remote, object_id):
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_GetObjectName(object_id)
    remote.runCommand(cmd)
    obj_name_vec = mmapi.vectorub()
    cmd.GetSceneCommandResult_GetObjectName(cmd_key, obj_name_vec)
    obj_name = vectorub_to_string(obj_name_vec)
    return obj_name
Esempio n. 5
0
def get_object_name(remote, object_id):
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_GetObjectName(object_id)
    remote.runCommand(cmd)
    obj_name_vec = mmapi.vectorub()
    cmd.GetSceneCommandResult_GetObjectName(cmd_key, obj_name_vec)
    obj_name = vectorub_to_string(obj_name_vec)
    return obj_name
Esempio n. 6
0
def get_object_name(remote, object_id):
    """Return the string name of the scene object with the given ID"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_GetObjectName(object_id)
    remote.runCommand(cmd)
    obj_name_vec = mmapi.vectorub()
    cmd.GetSceneCommandResult_GetObjectName(cmd_key, obj_name_vec)
    obj_name = vectorub_to_string(obj_name_vec)
    return obj_name
Esempio n. 7
0
def get_object_name(remote, object_id):
    """Return the string name of the scene object with the given ID"""
    cmd = mmapi.StoredCommands()
    cmd_key = cmd.AppendSceneCommand_GetObjectName(object_id)
    remote.runCommand(cmd)
    obj_name_vec = mmapi.vectorub()
    cmd.GetSceneCommandResult_GetObjectName(cmd_key, obj_name_vec)
    obj_name = vectorub_to_string(obj_name_vec)
    return obj_name
Esempio n. 8
0
v1 = mesh.appendVertex( (0,0,0), n, (1,0,0) )
v2 = mesh.appendVertex( (15,0,0), n, (0,1,0) )
v3 = mesh.appendVertex( (15,0,15), n, (0,0,1) )
t = mesh.appendTriangle( (v1,v3,v2) )
mesh.write(TEST_FILE_PATH)

# create new scene object from this file
cmd1 = mmapi.StoredCommands()
create_key = cmd1.AppendSceneCommand_AppendPackedMeshFile(TEST_FILE_PATH);
remote.runCommand(cmd1)

# register a new livemesh object based on this file and read back livemesh portname
cmd2 = mmapi.StoredCommands()
create_key = cmd2.AppendSceneCommand_CreateLiveMeshObject(TEST_FILE_PATH);
remote.runCommand(cmd2)
port_name_vec = mmapi.vectorub()
obj_id = mmapi.any_result()
cmd2.GetSceneCommandResult_CreateLiveMeshObject(create_key, port_name_vec, obj_id)
port_name = mm.vectorub_to_string(port_name_vec)
portid = obj_id.i

# animate this mesh
for i in range(0,2500):
    mesh.vertices[0] = (0, 0+i*0.1, 0)

    cmd_lock = mmapi.StoredCommands()
    cmd_lock.AppendSceneCommand_RequestLiveMeshLock(port_name);
    remote.runCommand(cmd_lock);

    mesh.write(TEST_FILE_PATH)