Hi,
I'd like to give some more hints about this possibility to drive mental ray Standalone in kind of interactive mode.
Operating systems support so called named pipes (Windows), or named fifo buffers (Unix, Mac), for communication between applications which support reading and writing files. Such named pipes appear as files on disk, but they actually don't store data on disk. Instead, such a pipe is reading data from its (standard) input and immediately passing it through to its (standard) output, with some temporary buffering.
mental ray Standalone can be run on such a named pipe to render the .mi stream it will receive, while another process may constantly feed this pipe with .mi text input. As long as the .mi stream is not closed, and valid .mi syntax is passed (mental ray will stop on serious syntax errors) , the renderer will continue until stopped explicitly.
Here is a code snippet for a command line version (Unix, Mac) :
This would start mental ray in a background process to read scene data from a file mi_file first, then continue to read from the ray_pipe pipe until end-of-file. In the same shell we start a terminal input in the foreground, where we enter .mi text directly that is passed on to the pipe. As soon as this data has been copied through the pipe by the operating system mental ray will read it and execute the commands. In the example it would trigger a second rendering. The whole pipeline can be stopped by pressing Ctrl+D, as end-of-file.Code:> mkfifo ray_pipe > ray -v on mi_file.mi ray_pipe & > cat - >>ray_pipe render "world" "camera" "options" ^D
There is one small caveat, especially with small text snippets like the above which are not passed through immediately when typed. That is because there are buffers involved, not only in the operating system but also in mental ray. mental ray keeps a .mi input buffer of 4096 characters. The buffer in the OS may be turned off, but the mental ray buffer is not controllable. That means, to get small text pieces pushed through, they should be followed by enough 'space' characters to make it a block of >4k characters. Update for mental ray 3.9 and beyond: with the introduction of compressed .mi stream support the internal buffers are now larger in size of approx. 16KB.
I hope this helps,
Steve


Reply With Quote
