sekme-89
whitesmoke
600
#dd3333
# Compatibility with Python 2.7.
from __future__ import print_function
# The directory containing the vray shared object should be
# present in the PYTHONPATH environment variable.
# Try to import the vray module from VRAY_SDK/python, if it is not in PYTHONPATH
import sys, os
VRAY_SDK = os.environ.get('VRAY_SDK')
if VRAY_SDK:
sys.path.append(os.path.join(VRAY_SDK, 'python'))
import vray
SCENE_PATH = os.path.join(VRAY_SDK, 'scenes')
# Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
os.chdir(SCENE_PATH)
# Create an instance of VRayRenderer with default options.
# The renderer is automatically closed after the `with` block.
with vray.VRayRenderer() as renderer:
# Register a simple log callback. Always useful for debugging.
def dumpMsg(renderer, message, level, instant):
if level == vray.LOGLEVEL_ERROR:
print("[ERROR]", message)
elif level == vray.LOGLEVEL_WARNING:
print("[Warning]", message)
elif level == vray.LOGLEVEL_INFO:
print("[info]", message)
# Uncomment for testing, but you might want to ignore these in real code
# else: print("[debug]", message)
renderer.setOnLogMessage(dumpMsg)
globalExportSettings = {}
# Enable compression of large data arrays.
globalExportSettings["hexArrays"] = True
globalExportSettings["compressed"] = True
# Keep transforms in human readable format
globalExportSettings["hexTransforms"] = False
# Print header to the export file
globalExportSettings["printHeader"] = True
# Export only the current frame.
globalExportSettings["currentFrameOnly"] = True
# Keep incremental off for the first frame so all plugins are exporeted properly.
globalExportSettings["incremental"] = False
# Separate the views and nodes in different files
viewSubFileInfo = {"type": 'view', "suffix": 'view'}
nodeSubFileInfo = {"type": 'nodes', "suffix": 'nodes'}
globalExportSettings["subFileInfos"] = [viewSubFileInfo, nodeSubFileInfo]
firstFrame = True
def stateChanged(renderer, oldState, newState, instant):
global firstFrame
global globalExportSettings
if newState == vray.RENDERER_STATE_IDLE_FRAME_DONE:
renderer.export("export.vrscene", globalExportSettings)
print("Frame", renderer.frame, "exported")
if firstFrame:
globalExportSettings["incremental"] = True
firstFrame = False
renderer.continueSequence()
renderer.setOnStateChanged(stateChanged)
# Load scene from a file.
renderer.load(os.path.join(SCENE_PATH, "animation.vrscene"))
# Maximum paths per pixel for interactive mode. Set a low sample level to complete rendering faster.
renderer.setInteractiveSampleLevel(5)
# Export just the plugins associated with the cube.
settings = {}
settings["pluginExportList"] = [
renderer.plugins['pCubeShape1@node'],
renderer.plugins['pCubeShape1@mesh5'],
renderer.plugins['VRayMtl1@material'],
renderer.plugins['VRayMtl1@diffuse']]
renderer.export("export_cube.vrscene", settings)
# Start the sequence.
renderer.renderSequence()
# Wait for the renderer to finish.
renderer.waitForSequenceEnd()
#define VRAY_RUNTIME_LOAD_PRIMARY
#include "vraysdk.hpp"
#include "vrayplugins.hpp"
#include "utils.h"
using namespace VRay;
using namespace VRay::Plugins;
using namespace std;
const char *BASE_PATH = getenv("VRAY_SDK");
string SCENE_PATH = (BASE_PATH ? string(BASE_PATH) : string(".")) + PATH_DELIMITER + "scenes";
VRayExportSettings globalExportSettings;
void stateChanged(VRayRenderer &renderer, RendererState oldState, RendererState newState, double instant, void* data){
if (newState == RendererState::IDLE_FRAME_DONE) {
static bool firstFrame = true;
// Export the current frame
renderer.exportScene("export.vrscene", globalExportSettings);
printf("Frame %d exported\
", renderer.getCurrentFrame());
// Turn the incremental option on to append each frame to the same file.
if (firstFrame) {
globalExportSettings.incremental = true;
firstFrame = false;
}
renderer.continueSequence();
}
}
int main() {
// Change process working directory to SCENE_PATH in order to be able to
// load relative scene resources.
changeCurrentDir(SCENE_PATH.c_str());
// Load V-Ray SDK library.
VRayInit init(NULL, true);
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed at the end of the current scope.
VRayRenderer renderer;
// It's recommended to always have a console log
renderer.setOnLogMessage(logMessage);
// Enable compression of large data arrays.
globalExportSettings.hexArrays = true;
globalExportSettings.compressed = true;
// Keep transforms in human readable format
globalExportSettings.hexTransforms = false;
// Print header to the export file
globalExportSettings.printHeader = true;
// Export only the current frame.
globalExportSettings.currentFrameOnly = true;
// Keep incremental off for the first frame so all plugins are exported properly.
globalExportSettings.incremental = false;
// Separate the views and nodes in different files
SubFileInfo views = { "view", "view" };
globalExportSettings.subFileInfos.push_back(views);
SubFileInfo nodes = { "nodes", "nodes" };
globalExportSettings.subFileInfos.push_back(nodes);
renderer.setOnStateChanged(stateChanged);
// Load scene from a file.
renderer.load("animation.vrscene");
// Maximum paths per pixel for interactive mode. Set a low sample level to complete rendering faster.
renderer.setInteractiveSampleLevel(5);
// Export just the plugins associated with the cube.
VRayExportSettings settings;
settings.pluginExportList.push_back(renderer.getPlugin("pCubeShape1@node"));
settings.pluginExportList.push_back(renderer.getPlugin("pCubeShape1@mesh5"));
settings.pluginExportList.push_back(renderer.getPlugin("VRayMtl1@material"));
settings.pluginExportList.push_back(renderer.getPlugin("VRayMtl1@diffuse"));
renderer.exportScene("export_cube.vrscene", settings);
// Start the sequence.
renderer.renderSequence();
// Wait for the renderer to finish.
renderer.waitForSequenceEnd();
return 0;
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VRay;
class Program
{
static void Main(string[] args)
{
string SCENE_PATH = Path.Combine(Environment.GetEnvironmentVariable("VRAY_SDK"), "scenes");
ExportSettings globalExportSettings = new ExportSettings();
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
Directory.SetCurrentDirectory(SCENE_PATH);
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed after the `using` block.
using (VRayRenderer renderer = new VRayRenderer())
{
// Add a listener for any type of log message.
renderer.LogMessage += new EventHandler<MessageEventArgs>((source, e) =>
{
// You can remove the if for testing, but you might want to ignore Debug in real code
if (e.LogLevel != LogLevelType.Debug)
{
Console.WriteLine(String.Format("[{0}] {1}", e.LogLevel.ToString(), e.Message));
}
});
// Enable compression of large data arrays.
globalExportSettings.HexArrays = true;
globalExportSettings.Compressed = true;
// Keep transforms in human readable format
globalExportSettings.HexTransforms = false;
// Print header to the export file
globalExportSettings.PrintHeader = true;
// Export only the current frame.
globalExportSettings.CurrentFrameOnly = true;
// Keep incremental off for the first frame so all plugins are exporeted properly.
globalExportSettings.Incremental = false;
// Separate the views and nodes in different files
SubFileInfo views = new SubFileInfo(SubFileInfo.PluginType.View, "views");
globalExportSettings.AddSubFileInfo(views);
SubFileInfo nodes = new SubFileInfo(SubFileInfo.PluginType.Node, "nodes");
globalExportSettings.AddSubFileInfo(nodes);
bool firstFrame = true;
renderer.StateChanged += new EventHandler<StateChangedEventArgs>((source, e) =>
{
if(e.NewState == VRayRenderer.RendererState.IDLE_FRAME_DONE)
{
// Export the current frame
renderer.Export("export.vrscene", globalExportSettings);
Console.WriteLine("Frame {0} exported\
", renderer.Frame);
// Turn the incremental option on to append each frame to the same file.
if (firstFrame)
{
globalExportSettings.Incremental = true;
firstFrame = false;
}
renderer.ContinueSequence();
}
});
// Load scene from a file.
renderer.Load("animation.vrscene");
// Maximum paths per pixel for interactive mode. Set a low sample level to complete rendering faster.
renderer.SetInteractiveSampleLevel(5);
// Export just the plugins associated with the cube.
ExportSettings settings = new ExportSettings();
settings.PluginExportList.Add(renderer.GetPlugin("pCubeShape1@node"));
settings.PluginExportList.Add(renderer.GetPlugin("pCubeShape1@mesh5"));
settings.PluginExportList.Add(renderer.GetPlugin("VRayMtl1@material"));
settings.PluginExportList.Add(renderer.GetPlugin("VRayMtl1@diffuse"));
renderer.Export("export_cube.vrscene", settings);
// Start the sequence.
renderer.RenderSequence();
// Wait for the renderer to finish.
renderer.WaitForSequenceEnd();
}
}
}
var path = require("path");
var vray = require(path.join(process.env.VRAY_SDK, "node", "vray"));
var SCENE_PATH = path.join(process.env.VRAY_SDK, "scenes");
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
process.chdir(SCENE_PATH);
// Create an instance of VRayRenderer with default options.
var renderer = vray.VRayRenderer();
// It's recommended to always have a console log callback
renderer.on("logMessage", function(message, level, instant) {
if (level == vray.LOGLEVEL_ERROR)
console.log("[ERROR] ", message);
else if (level == vray.LOGLEVEL_WARNING)
console.log("[Warning] ", message);
else if (level == vray.LOGLEVEL_INFO)
console.log("[info] ", message);
// Uncomment for testing, but you might want to ignore these in real code
//else console.log("[debug] ", message);
});
var globalExportSettings = {};
// Enable compression of large data arrays.
globalExportSettings.hexArrays = true;
globalExportSettings.compressed = true;
// Keep transforms in human readable format
globalExportSettings.hexTransforms = false;
// Print header to the export file
globalExportSettings.printHeader = true;
// Export only the current frame.
globalExportSettings.currentFrameOnly = true;
// Keep incremental off for the first frame so all plugins are exporeted properly.
globalExportSettings.incremental = false;
// Separate the views and nodes in different files
var viewSubFileInfo = {type: "view", suffix: "view"};
var nodeSubFileInfo = {type: "nodes", suffix: "nodes"};
globalExportSettings.subFileInfos = [viewSubFileInfo, nodeSubFileInfo];
var firstFrame = true;
renderer.on("stateChanged", function(oldState, newState, instant) {
if (newState == 'idleFrameDone') {
// Export the current frame
renderer.export("export.vrscene", globalExportSettings, function(err) {
if (err) throw err;
console.log("Frame ", renderer.frame, " exported");
if(firstFrame) {
globalExportSettings.incremental = true;
firstFrame = false;
}
renderer.continueSequence();
});
}
});
// Load scene from a file.
renderer.load("animation.vrscene", function(err){
if (err) throw err;
// Maximum paths per pixel for interactive mode. Set a low sample level to complete rendering faster.
renderer.setInteractiveSampleLevel(5);
// Export just the plugins associated with the cube.
var settings = {};
settings.pluginExportList = [
renderer.plugins["pCubeShape1@node"],
renderer.plugins["pCubeShape1@mesh5"],
renderer.plugins["VRayMtl1@material"],
renderer.plugins["VRayMtl1@diffuse"]];
renderer.export("export_cube.vrscene", settings, function(err){
if (err) throw err;
// Start the sequence.
renderer.renderSequence();
// Wait for the renderer to finish.
renderer.waitForSequenceEnd(function() {
// Closes the renderer.
// The renderer object is unusable after closing since its resources
// are freed. It should be released for garbage collection.
renderer.close();
});
});
});
sekme-90
whitesmoke
600
#dd3333
# Compatibility with Python 2.7.
from __future__ import print_function
import sys, os
import vrfiles_parser as parser
# The directory containing the vray shared object should be present in the PYTHONPATH environment variable.
# Try to import the vray module from VRAY_SDK/python, if it is not in PYTHONPATH
VRAY_SDK = os.environ.get('VRAY_SDK')
if VRAY_SDK:
sys.path.append(os.path.join(VRAY_SDK, 'python'))
import vray
SCENE_PATH = os.path.join(VRAY_SDK, 'scenes')
# The name of the scene to be loaded
sceneName = 'cornell_new'
# The suffix to distinguish the exported file
exportedSuffix = '_sidecar'
# The name of the folder for storing the copied assets
resourcesName = 'resources'
# Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
os.chdir(SCENE_PATH)
# Create an instance of VRayRenderer with default options.
# The renderer is automatically closed after the `with` block.
with vray.VRayRenderer() as renderer:
# Register a simple log callback. Always useful for debugging.
def dumpMsg(renderer, message, level, instant):
if level == vray.LOGLEVEL_ERROR:
print("[ERROR]", message)
elif level == vray.LOGLEVEL_WARNING:
print("[Warning]", message)
elif level == vray.LOGLEVEL_INFO:
print("[info]", message)
# Uncomment for testing, but you might want to ignore these in real code
# else: print("[debug]", message)
renderer.setOnLogMessage(dumpMsg)
# Load scene from a file.
renderer.load(sceneName + parser.vrsceneExt)
# Export with settings for companion (sidecar) files - vrdata and vrfiles
# It is particularly useful when we have a vrscene containing:
# - large data buffers, which could possibly be duplicated between the plugins
# - various absolute or relative paths to referenced files - textures, OCIO configs, meshes, materials, etc.
# The files existing on the machine, which did the export, may not exist on another machine
settings = {}
# Enable vrdata files to be exported (default is false)
settings['vrdataExport'] = True
# If the buffer size in bytes is smaller than this value, it is not written to the vrdata file. (default is 2048 bytes)
settings['vrdataSmallBufferSizeLimit'] = 2048
# Limit the size (MiB) of the vrdata file. If this limit is reached another file is started. (default is 0 - no limit)
settings['vrdataFileSizeLimitMiB'] = 0
# Enable vrfiles files to be exported (default is false)
settings['vrfilesExport'] = True
# Enable computation and writing to the vfiles of MD5 and SHA256 hashes for each resolved asset file (default is false)
settings['vrfilesComputeHashes'] = True
# Optional absolute scene base path that can be used for resolving relative paths for the vrfiles file.
settings['sceneBasePath'] = SCENE_PATH
# Export the scene - the following directive is written in the beginning the vrscene file
# #version 2
exportedScene = sceneName + exportedSuffix
success = renderer.export(exportedScene + parser.vrsceneExt, settings)
if success:
# Copies all assets and files related to the exportedScene to the destFolder
# and rewrites the absolute actual paths in the vrfiles to relative ones
parser.packExportedVrscene(exportedScene, sceneName, resourcesName)
# The destFolder could be then packed and sent for rendering on another machine
# We could also load it locally and start rendering
os.chdir(sceneName)
renderer.load(exportedScene + parser.vrsceneExt)
renderer.start()
renderer.waitForRenderEnd(15000)
#define VRAY_RUNTIME_LOAD_PRIMARY
#include "vraysdk.hpp"
#include "vrayplugins.hpp"
#include "vrfiles_parser.h"
using namespace VRay;
using namespace VRay::Plugins;
using namespace std;
const char *BASE_PATH = getenv("VRAY_SDK");
const string SCENE_PATH = (BASE_PATH ? string(BASE_PATH) : string(".")) + PATH_DELIMITER + "scenes";
// The name of the scene to be loaded
static const string sceneName = "cornell_new";
// The suffix to distinguish the exported file
static const string exportedSuffix = "_sidecar";
// The name of the folder for storing the copied assets
static const string resourcesName = "resources";
int main() {
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
changeCurrentDir(SCENE_PATH.c_str());
// Load V-Ray SDK library.
VRayInit init(NULL, true);
// Create an instance of VRayRenderer with default options.
VRayRenderer renderer;
// It's recommended to always have a console log
renderer.setOnLogMessage(logMessage);
// Load scene from a file.
renderer.load(sceneName + vrsceneExt);
// Export with settings for companion (sidecar) files - vrdata and vrfiles
// It is particularly useful when we have a vrscene containing:
// - large data buffers, which could possibly be duplicated between the plugins
// - various absolute or relative paths to referenced files - textures, OCIO configs, meshes, materials, etc.
// The files existing on the machine, which did the export, may not exist on another machine
VRayExportSettings settings;
// Enable vrdata files to be exported (default is false)
settings.vrdataExport = true;
// If the buffer size in bytes is smaller than this value, it is not written to the vrdata file. (default is 2048 bytes)
settings.vrdataSmallBufferSizeLimit = 2048;
// Limit the size (MiB) of the vrdata file. If this limit is reached another file is started. (default is 0 - no limit)
settings.vrdataFileSizeLimitMiB = 0;
// Enable vrfiles files to be exported (default is false)
settings.vrfilesExport = true;
// Enable computation and writing to the vfiles of MD5 and SHA256 hashes for each resolved asset file (default is false)
settings.vrfilesComputeHashes = true;
// Optional absolute scene base path that can be used for resolving relative paths for the vrfiles file.
settings.sceneBasePath = SCENE_PATH;
// Export the scene - the following directive is written in the beginning the vrscene file
// #version 2
string exportedScene = sceneName + exportedSuffix;
int err = renderer.exportScene(exportedScene + vrsceneExt, settings);
if (!err) {
// Copies all assets and files related to the exportedScene to the destFolder
// and rewrites the absolute actual paths in the vrfiles to relative ones
VRFilesParser::packExportedVrscene(exportedScene, sceneName, resourcesName);
// The destFolder could be then packed and sent for rendering on another machine
// We could also load it locally and start rendering
changeCurrentDir(sceneName.c_str());
renderer.load(exportedScene + vrsceneExt);
renderer.startSync();
renderer.waitForRenderEnd(15000);
}
return 0;
}
using System;
using System.IO;
using VRay;
class Program
{
// The name of the scene to be loaded
const string sceneName = "cornell_new";
// The suffix to distinguish the exported file
const string exportedSuffix = "_sidecar";
// The name of the folder for storing the copied assets
const string resourcesName = "resources";
static void Main(string[] args)
{
string SCENE_PATH = Path.Combine(Environment.GetEnvironmentVariable("VRAY_SDK"), "scenes");
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
Directory.SetCurrentDirectory(SCENE_PATH);
// Create an instance of VRayRenderer with default options.
// The renderer is automatically closed after the `using` block.
using (VRayRenderer renderer = new VRayRenderer())
{
// Add a listener for any type of log message.
renderer.LogMessage += new EventHandler<MessageEventArgs>((source, e) =>
{
// You can remove the if for testing, but you might want to ignore Debug in real code
if (e.LogLevel != LogLevelType.Debug)
{
Console.WriteLine(String.Format("[{0}] {1}", e.LogLevel.ToString(), e.Message));
}
});
// Load scene from a file.
renderer.Load(sceneName + VRFilesParser.VrsceneExt);
// Export with settings for companion (sidecar) files - vrdata and vrfiles
// It is particularly useful when we have a vrscene containing:
// - large data buffers, which could possibly be duplicated between the plugins
// - various absolute or relative paths to referenced files - textures, OCIO configs, meshes, materials, etc.
// The files existing on the machine, which did the export, may not exist on another machine
ExportSettings settings = new ExportSettings();
// Enable vrdata files to be exported (default is false)
settings.VrdataExport = true;
// If the buffer size in bytes is smaller than this value, it is not written to the vrdata file. (default is 2048 bytes)
settings.VrdataSmallBufferSizeLimit = 2048;
// Limit the size (MiB) of the vrdata file. If this limit is reached another file is started. (default is 0 - no limit)
settings.VrdataFileSizeLimitMiB = 0;
// Enable vrfiles files to be exported (default is false)
settings.VrfilesExport = true;
// Enable computation and writing to the vfiles of MD5 and SHA256 hashes for each resolved asset file (default is false)
settings.VrfilesComputeHashes = true;
// Optional absolute scene base path that can be used for resolving relative paths for the vrfiles file.
settings.SceneBasePath = SCENE_PATH;
// Export the scene - the following directive is written in the beginning the vrscene file
// #version 2
string exportedScene = sceneName + exportedSuffix;
bool success = renderer.Export(exportedScene + VRFilesParser.VrsceneExt, settings);
if (success)
{
// Copies all assets and files related to the exportedScene to the destFolder
// and rewrites the absolute actual paths in the vrfiles to relative ones
VRFilesParser.PackExportedVrscene(exportedScene, sceneName, resourcesName);
// The destFolder could be then packed and sent for rendering on another machine
// We could also load it locally and start rendering
Directory.SetCurrentDirectory(sceneName);
renderer.Load(exportedScene + VRFilesParser.VrsceneExt);
renderer.StartSync();
renderer.WaitForRenderEnd(15000);
}
}
}
}
const parser = require("./vrfiles_parser");
const vray = require(parser.path.join(process.env.VRAY_SDK, "node", "vray"));
const SCENE_PATH = parser.path.join(process.env.VRAY_SDK, "scenes");
// The name of the scene to be loaded
const sceneName = "cornell_new";
// The suffix to distinguish the exported file
const exportedSuffix = "_sidecar";
// The name of the folder for storing the copied assets
const resourcesName = "resources";
// Change process working directory to SCENE_PATH in order to be able to load relative scene resources.
process.chdir(SCENE_PATH);
// Create an instance of VRayRenderer with default options.
var renderer = vray.VRayRenderer();
// It's recommended to always have a console log callback
renderer.on("logMessage", function (message, level, instant) {
if (level == vray.LOGLEVEL_ERROR)
console.log("[ERROR] ", message);
else if (level == vray.LOGLEVEL_WARNING)
console.log("[Warning] ", message);
else if (level == vray.LOGLEVEL_INFO)
console.log("[info] ", message);
// Uncomment for testing, but you might want to ignore these in real code
//else console.log("[debug] ", message);
});
// Load scene from a file.
renderer.load(sceneName + parser.vrsceneExt, function (err) {
if (err) throw err;
// Export with settings for companion (sidecar) files - vrdata and vrfiles
// It is particularly useful when we have a vrscene containing:
// - large data buffers, which could possibly be duplicated between the plugins
// - various absolute or relative paths to referenced files - textures, OCIO configs, meshes, materials, etc.
// The files existing on the machine, which did the export, may not exist on another machine
var settings = {};
// Enable vrdata files to be exported (default is false)
settings.vrdataExport = true;
// If the buffer size in bytes is smaller than this value, it is not written to the vrdata file. (default is 2048 bytes)
settings.vrdataSmallBufferSizeLimit = 2048;
// Limit the size (MiB) of the vrdata file. If this limit is reached another file is started. (default is 0 - no limit)
settings.vrdataFileSizeLimitMiB = 0;
// Enable vrfiles files to be exported (default is false)
settings.vrfilesExport = true;
// Enable computation and writing to the vfiles of MD5 and SHA256 hashes for each resolved asset file (default is false)
settings.vrfilesComputeHashes = true;
// Optional absolute scene base path that can be used for resolving relative paths for the vrfiles file.
settings.sceneBasePath = SCENE_PATH;
// Export the scene - the following directive is written in the beginning the vrscene file
// #version 2
var exportedScene = sceneName + exportedSuffix;
renderer.export(exportedScene + parser.vrsceneExt, settings, function (err) {
if (err) throw err;
// Copies all assets and files related to the exportedScene to the destFolder
// and rewrites the absolute actual paths in the vrfiles to relative ones
parser.packExportedVrscene(exportedScene, sceneName, resourcesName, function(err) {
if (err) throw err;
// The destFolder could be then packed and sent for rendering on another machine
// We could also load it locally and start rendering
process.chdir(sceneName);
renderer.load(exportedScene + parser.vrsceneExt, function (err) {
if (err) throw err;
renderer.start(function (err) {
if (err) throw err;
renderer.waitForRenderEnd(15000, function () {
// Closes the renderer.
// The renderer object is unusable after closing since its resources
// are freed. It should be released for garbage collection.
renderer.close();
});
});
});
});
});
});