sekme-82
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(os.environ.get('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)
# Load scene from a file.
renderer.load(os.path.join(SCENE_PATH, 'cornell_new.vrscene'))
# Create a VRayClipper plugin
clipper = renderer.classes.VRayClipper()
# Don't assign a node to get mesh from; clip against a plane instead
# Enable the clipper
clipper.enabled = True
# List of exclusion nodes
exclusionNodes = [
renderer.plugins['Sphere0Shape1@node'],
renderer.plugins['Sphere0Shape4@node']
]
clipper.exclusion_nodes = exclusionNodes
# Exclude the nodes from the list; all other nodes will be clipped
clipper.exclusion_mode = True
# Perform subtraction
clipper.invert_inside = 1
# Attach the blue material
clipper.material = renderer.plugins['Blue_Mtl@mtlsingle']
# Assign a transform to the clipper plane
clipper.transform = vray.Transform(vray.Matrix(vray.Vector(1, 0, 0), vray.Vector(0, 0.5, 0.87), vray.Vector(0, -0.87, 0.5)), vray.Vector(0, 20, 0))
# Start rendering.
renderer.startSync()
# Wait for rendering to end.
renderer.waitForRenderEnd()
#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";
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);
// Load scene from a file.
renderer.load("cornell_new.vrscene");
// Create a VRayClipper plugin
VRayClipper clipper = renderer.newPlugin<VRayClipper>();
// Don't assign a node to get mesh from; clip against a plane instead
// Enable the clipper
clipper.set_enabled(true);
// List of exclusion nodes
ValueList exclusionNodes;
exclusionNodes = {
Value(renderer.getPlugin("Sphere0Shape1@node")),
Value(renderer.getPlugin("Sphere0Shape4@node"))
};
clipper.set_exclusion_nodes(exclusionNodes);
// Exclude the nodes from the list; all other nodes will be clipped
clipper.set_exclusion_mode(true);
// Perform subtraction
clipper.set_invert_inside(1);
// Attach the blue material
clipper.set_material(renderer.getPlugin("Blue_Mtl@mtlsingle"));
// Assign a transform to the clipper plane
clipper.set_transform(Transform(Matrix(Vector(1, 0, 0), Vector(0, 0.5, 0.87), Vector(0, -0.87, 0.5)), Vector(0, 20, 0)));
// Start rendering.
renderer.startSync();
// Wait for rendering to end.
renderer.waitForRenderEnd();
return 0;
}
using System;
using System.IO;
using System.Collections.Generic;
using VRay;
using VRay.Plugins;
namespace _clipperPlane
{
class Program
{
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("cornell_new.vrscene");
// Create a VRayClipper plugin
VRayClipper clipper = renderer.NewPlugin<VRayClipper>();
// Don't assign a node to get mesh from; clip against a plane instead
// Enable the clipper
clipper.Enabled = true;
// List of exclusion nodes
List<object> exclusionNodes = new List<object> {
renderer.GetPlugin("Sphere0Shape1@node"),
renderer.GetPlugin("Sphere0Shape4@node")
};
clipper.ExclusionNodes = exclusionNodes;
// Exclude the nodes from the list; all other nodes will be clipped
clipper.ExclusionMode = true;
// Perform subtraction
clipper.InvertInside = 1;
// Attach the blue material
clipper.Material = renderer.GetPlugin("Blue_Mtl@mtlsingle");
// Assign a transform to the clipper plane
clipper.Transform = new Transform(new Matrix(new Vector(1, 0, 0), new Vector(0, 0.5, 0.87), new Vector(0, -0.87, 0.5)), new Vector(0, 20, 0));
// Start rendering.
renderer.StartSync();
// Wait for rendering to end.
renderer.WaitForRenderEnd();
}
}
}
}
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);
});
// Load scene from a file asynchronously.
renderer.load("cornell_new.vrscene", function(err) {
if (err) throw err;
// Create a VRayClipper plugin
var clipper = renderer.classes.VRayClipper();
// Don't assign a node to get mesh from; clip against a plane instead
// Enable the clipper
clipper.enabled = true;
// List of exclusion nodes
var exclusionNodes = vray.List(
renderer.plugins["Sphere0Shape1@node"],
renderer.plugins["Sphere0Shape4@node"]
);
clipper.exclusion_nodes = exclusionNodes;
// Exclude the nodes from the list; all other nodes will be clipped
clipper.exclusion_mode = true;
// Perform subtraction
clipper.invert_inside = 1;
// Attach the blue material
clipper.material = renderer.plugins["Blue_Mtl@mtlsingle"];
// Assign a transform to the clipper plane
clipper.transform = vray.Transform(vray.Matrix(vray.Vector(1, 0, 0), vray.Vector(0, 0.5, 0.87), vray.Vector(0, -0.87, 0.5)), vray.Vector(0, 20, 0));
// Start rendering.
renderer.start(function(err) {
if (err) throw err;
// Wait for rendering to end.
renderer.waitForRenderEnd(function() {
renderer.close();
});
});
});