# 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
# When VRAY_SDK is set, the App SDK binding will search for the VRaySDKLibrary binary and its dependencies inside VRAY_SDK/bin.
# If the directory structure of a product that uses App SDK doesn't include the binaries inside a /bin folder, VRAY_App SDK_BIN can be used instead of VRAY_SDK.
# In that case, the App SDK binding will try to load the binaries directly from the folder that VRAY_APPSDK_BIN points at.
# If no environment variables are set, the search path could be passed as the parameter of the function vray.setSDKLibraryPath(path)
with vray.VRayRenderer() as renderer:
# Create a new static geometry
mesh = renderer.classes.GeomStaticMesh()
# Assign a box geometry
mesh.vertices=vray.VectorList(
vray.Vector(-26.7598, -30.5826, 0.0),
vray.Vector(26.7598, -30.5826, 0.0),
vray.Vector(-26.7598, 30.5826, 0.0),
vray.Vector(26.7598, 30.5826, 0.0),
vray.Vector(-26.7598, -30.5826, 125.389),
vray.Vector(26.7598, -30.5826, 125.389),
vray.Vector(-26.7598, 30.5826, 125.389),
vray.Vector(26.7598, 30.5826, 125.389)
)
mesh.faces=vray.IntList(
0, 2, 3,
3, 1, 0,
4, 5, 7,
7, 6, 4,
0, 1, 5,
5, 4, 0,
1, 3, 7,
7, 5, 1,
3, 2, 6,
6, 7, 3,
2, 0, 4,
4, 6, 2
)
mesh.normals=vray.VectorList(
vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0),
vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0),
vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0),
vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0),
vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0),
vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0),
vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0),
vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0),
vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0),
vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0),
vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0),
vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0)
)
mesh.faceNormals=vray.IntList(
0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23,
24, 25, 26,
27, 28, 29,
30, 31, 32,
33, 34, 35
)
# Create a BRDF with diffuse color
newBRDF = renderer.classes.BRDFDiffuse()
# We specify solid green color
newBRDF.color = vray.Color(0.0, 1.0, 0.0)
# Create a new material with single BRDF
newMaterial = renderer.classes.MtlSingleBRDF()
# Assign the BRDF to the material
newMaterial.brdf = newBRDF
# Create a new node for the box
newNode = renderer.classes.Node()
newNode.material = newMaterial # Assign the new material to the new node
newNode.geometry = mesh # Assign the mesh
# We must specify transform in order to position the box in the world
newNode.transform = vray.Transform(vray.Matrix(vray.Vector(1.0, 0.0, 0.0),
vray.Vector(0.0, 1.0, 0.0),
vray.Vector(0.0, 0.0, 1.0)), vray.Vector(-20.6777, 131.6402, 0))
# Create the light
light = renderer.classes.LightRectangle()
# We must specify transform in order to position the light in the world
light.transform = vray.Transform(vray.Matrix(vray.Vector(1.0, 0.0, 0.0),
vray.Vector(0.0, 1.0, 0.0),
vray.Vector(0.0, 0.0, 1.0)), vray.Vector(-20.6777, 131.6402, 150))
# Set white color
light.color = vray.AColor(1.0, 1.0, 1.0)
# Increase the light's size (by default it's 1x1)
light.u_size = 50
light.v_size = 50
# Increase the default intensity
light.intensity = 100
# Create the camera
renderView = renderer.classes.RenderView()
# Position the camera towards the box
renderView.transform=vray.Transform(vray.Matrix(vray.Vector(0.92, 0.37, 0.0), vray.Vector(0.12, -0.3, 0.94), vray.Vector(0.35, -0.87, -0.32)), vray.Vector(59, -140, 44))
# Set Field of view (horizontal) in radians
renderView.fov=1.65806
renderer.start()
renderer.waitForRenderEnd(60000)
|
|
#define VRAY_RUNTIME_LOAD_PRIMARY
#include "vraysdk.hpp"
#include "vrayplugins.hpp"
using namespace VRay;
using namespace VRay::Plugins;
int main(int argc, char* argv[]) {
// The first parameter is the VRaySDKLibrary DLL/SO/DYLIB name (full path optional). Here the default name is used.
// When VRAY_SDK is set, the App SDK binding will search for the VRaySDKLibrary binary and its dependencies inside VRAY_SDK/bin.
// If the directory structure of a product that uses App SDK doesn't include the binaries inside a /bin folder, VRAY_APPSDK_BIN can be used instead of VRAY_SDK.
// In that case, the App SDK binding will try to load the binaries directly from the folder that VRAY_APPSDK_BIN points at.
// If no environment variables are set, the full path containing the VRaySDKLibrary filename could be passed as the first parameter.
// The second parameter is enable or disable the V-Ray Frame Buffer (VFB)
VRayInit init(NULL, true);
// Create an instance of VRayRenderer with default options
VRayRenderer renderer;
// Create a new static geometry
GeomStaticMesh mesh = renderer.newPlugin<GeomStaticMesh>();
// Assign a box geometry
Vector vertices[] = {
Vector(-26.7598, -30.5826, 0.0),
Vector(26.7598, -30.5826, 0.0),
Vector(-26.7598, 30.5826, 0.0),
Vector(26.7598, 30.5826, 0.0),
Vector(-26.7598, -30.5826, 125.389),
Vector(26.7598, -30.5826, 125.389),
Vector(-26.7598, 30.5826, 125.389),
Vector(26.7598, 30.5826, 125.389)
};
mesh.set_vertices(VectorList(vertices, vertices + 8));
int faces[] = {
0, 2, 3,
3, 1, 0,
4, 5, 7,
7, 6, 4,
0, 1, 5,
5, 4, 0,
1, 3, 7,
7, 5, 1,
3, 2, 6,
6, 7, 3,
2, 0, 4,
4, 6, 2
};
mesh.set_faces(IntList(faces, faces + 36));
Vector normals[] = {
Vector(0.0, 0.0, -1.0), Vector(0.0, 0.0, -1.0), Vector(0.0, 0.0, -1.0),
Vector(0.0, 0.0, -1.0), Vector(0.0, 0.0, -1.0), Vector(0.0, 0.0, -1.0),
Vector(0.0, 0.0, 1.0), Vector(0.0, 0.0, 1.0), Vector(0.0, 0.0, 1.0),
Vector(0.0, 0.0, 1.0), Vector(0.0, 0.0, 1.0), Vector(0.0, 0.0, 1.0),
Vector(0.0, -1.0, 0.0), Vector(0.0, -1.0, 0.0), Vector(0.0, -1.0, 0.0),
Vector(0.0, -1.0, 0.0), Vector(0.0, -1.0, 0.0), Vector(0.0, -1.0, 0.0),
Vector(1.0, 0.0, 0.0), Vector(1.0, 0.0, 0.0), Vector(1.0, 0.0, 0.0),
Vector(1.0, 0.0, 0.0), Vector(1.0, 0.0, 0.0), Vector(1.0, 0.0, 0.0),
Vector(0.0, 1.0, 0.0), Vector(0.0, 1.0, 0.0), Vector(0.0, 1.0, 0.0),
Vector(0.0, 1.0, 0.0), Vector(0.0, 1.0, 0.0), Vector(0.0, 1.0, 0.0),
Vector(-1.0, 0.0, 0.0), Vector(-1.0, 0.0, 0.0), Vector(-1.0, 0.0, 0.0),
Vector(-1.0, 0.0, 0.0), Vector(-1.0, 0.0, 0.0), Vector(-1.0, 0.0, 0.0)
};
mesh.set_normals(VectorList(normals, normals + 36));
int faceNormals[] = {
0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23,
24, 25, 26,
27, 28, 29,
30, 31, 32,
33, 34, 35
};
mesh.set_faceNormals(IntList(faceNormals, faceNormals + 36));
// Create a BRDF with diffuse color
BRDFDiffuse newBRDF = renderer.newPlugin<BRDFDiffuse>();
// We specify solid green color
newBRDF.set_color(Color(0.0, 1.0, 0.0));
// Create a new material with single BRDF
MtlSingleBRDF newMaterial = renderer.newPlugin<MtlSingleBRDF>();
// Assign the BRDF to the material
newMaterial.set_brdf(newBRDF);
// Create a new node for the box
Node newNode = renderer.newPlugin<Node>();
newNode.set_material(newMaterial); // Assign the new material to the new node
newNode.set_geometry(mesh); // Assign the mesh
// We must specify transform in order to position the box in the world
newNode.set_transform(Transform(Matrix(Vector(1.0, 0.0, 0.0),
Vector(0.0, 1.0, 0.0),
Vector(0.0, 0.0, 1.0)), Vector(-20.6777, 131.6402, 0)));
// Create the light
LightRectangle light = renderer.newPlugin<LightRectangle>();
// We must specify transform in order to position the light in the world
light.set_transform(Transform(Matrix(Vector(1.0, 0.0, 0.0),
Vector(0.0, 1.0, 0.0),
Vector(0.0, 0.0, 1.0)), Vector(-20.6777, 131.6402, 150)));
// Set white color
light.set_color(AColor(1.0, 1.0, 1.0));
// Increase the light's size (by default it's 1x1)
light.set_u_size(50);
light.set_v_size(50);
// Increase the default intensity
light.set_intensity(100);
// Create the camera
RenderView renderView = renderer.newPlugin<RenderView>();
// Position the camera towards the box
renderView.set_transform(Transform(Matrix(Vector(0.92, 0.37, 0.0),
Vector(0.12, -0.3, 0.94),
Vector(0.35, -0.87, -0.32)), Vector(59.0, -140, 44)));
// Set Field of view(horizontal) in radians
renderView.set_fov(1.65806f);
// Start rendering
renderer.startSync();
// Wait until rendering has finished or 60000ms have elapsed
renderer.waitForRenderEnd(60000);
return 0;
} |
|
using System;
using System.IO;
using VRay;
using VRay.Plugins;
namespace ConsoleApplication1
{
class Program
{
// When VRAY_SDK is set, the App SDK binding will search for the VRaySDKLibrary binary and its dependencies inside VRAY_SDK/bin.
// If the directory structure of a product that uses App SDK doesn't include the binaries inside a /bin folder, VRAY_APPSDK_BIN can be used instead of VRAY_SDK.
// In that case, the App SDK binding will try to load the binaries directly from the folder that VRAY_APPSDK_BIN points at.
// If no environment variables are set, the search path could be passed as the parameter of the function Globals.SetSDKLibraryPath(path);
static string SCENE_PATH = Path.Combine(Environment.GetEnvironmentVariable("VRAY_SDK"), "scenes");
static void HandleStartEvent(object source, System.EventArgs e)
{
Console.WriteLine("The V-Ray render process has started!");
}
static void Main(string[] args)
{
try
{
using (VRayRenderer renderer = new VRayRenderer())
{
// Create a new static geometry
GeomStaticMesh mesh = renderer.NewPlugin<GeomStaticMesh>();
// Assign a box geometry
Vector[] vertices = new Vector[] {
new Vector(-26.7598, -30.5826, 0.0),
new Vector(26.7598, -30.5826, 0.0),
new Vector(-26.7598, 30.5826, 0.0),
new Vector(26.7598, 30.5826, 0.0),
new Vector(-26.7598, -30.5826, 125.389),
new Vector(26.7598, -30.5826, 125.389),
new Vector(-26.7598, 30.5826, 125.389),
new Vector(26.7598, 30.5826, 125.389)
};
mesh.Vertices = vertices;
int[] faces = new int[]{
0, 2, 3,
3, 1, 0,
4, 5, 7,
7, 6, 4,
0, 1, 5,
5, 4, 0,
1, 3, 7,
7, 5, 1,
3, 2, 6,
6, 7, 3,
2, 0, 4,
4, 6, 2
};
mesh.Faces = faces;
Vector[] normals = new Vector[] {
new Vector(0.0, 0.0, -1.0), new Vector(0.0, 0.0, -1.0), new Vector(0.0, 0.0, -1.0),
new Vector(0.0, 0.0, -1.0), new Vector(0.0, 0.0, -1.0), new Vector(0.0, 0.0, -1.0),
new Vector(0.0, 0.0, 1.0), new Vector(0.0, 0.0, 1.0), new Vector(0.0, 0.0, 1.0),
new Vector(0.0, 0.0, 1.0), new Vector(0.0, 0.0, 1.0), new Vector(0.0, 0.0, 1.0),
new Vector(0.0, -1.0, 0.0), new Vector(0.0, -1.0, 0.0), new Vector(0.0, -1.0, 0.0),
new Vector(0.0, -1.0, 0.0), new Vector(0.0, -1.0, 0.0), new Vector(0.0, -1.0, 0.0),
new Vector(1.0, 0.0, 0.0), new Vector(1.0, 0.0, 0.0), new Vector(1.0, 0.0, 0.0),
new Vector(1.0, 0.0, 0.0), new Vector(1.0, 0.0, 0.0), new Vector(1.0, 0.0, 0.0),
new Vector(0.0, 1.0, 0.0), new Vector(0.0, 1.0, 0.0), new Vector(0.0, 1.0, 0.0),
new Vector(0.0, 1.0, 0.0), new Vector(0.0, 1.0, 0.0), new Vector(0.0, 1.0, 0.0),
new Vector(-1.0, 0.0, 0.0), new Vector(-1.0, 0.0, 0.0), new Vector(-1.0, 0.0, 0.0),
new Vector(-1.0, 0.0, 0.0), new Vector(-1.0, 0.0, 0.0), new Vector(-1.0, 0.0, 0.0)
};
mesh.Normals = normals;
int[] faceNormals = new int[]{
0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23,
24, 25, 26,
27, 28, 29,
30, 31, 32,
33, 34, 35
};
mesh.FaceNormals = faceNormals;
// Create a BRDF with diffuse color
BRDFDiffuse newBRDF = renderer.NewPlugin<BRDFDiffuse>();
// We specify solid green color
newBRDF.Color = new Color(0.0f, 1.0f, 0.0f);
// Create a new material with single BRDF
MtlSingleBRDF newMaterial = renderer.NewPlugin<MtlSingleBRDF>();
// Assign the BRDF to the material
newMaterial.Brdf = newBRDF;
// Create a new node for the box
Node newNode = renderer.NewPlugin<Node>();
newNode.Material = newMaterial; // Assign the new material to the new node
newNode.Geometry = mesh; // Assign the mesh
// We must specify transform in order to position the box in the world
newNode.Transform = new Transform(new Matrix(new Vector(1.0, 0.0, 0.0),
new Vector(0.0, 1.0, 0.0),
new Vector(0.0, 0.0, 1.0)), new Vector(-20.6777, 131.6402, 0));
// Create the light
LightRectangle light = renderer.NewPlugin<LightRectangle>();
// We must specify transform in order to position the light in the world
light.Transform = new Transform(new Matrix(new Vector(1.0, 0.0, 0.0),
new Vector(0.0, 1.0, 0.0),
new Vector(0.0, 0.0, 1.0)), new Vector(-20.6777, 131.6402, 150));
// Set white color
light.Color = new AColor(1.0f, 1.0f, 1.0f);
// Increase the light's size (by default it's 1x1)
light.USize = 50;
light.VSize = 50;
// Increase the default intensity
light.Intensity = 100;
// Create the camera
RenderView renderView = renderer.NewPlugin<RenderView>();
// Position the camera towards the box
renderView.Transform = new Transform(new Matrix(new Vector(0.92, 0.37, 0.0),
new Vector(0.12, -0.3, 0.94),
new Vector(0.35, -0.87, -0.32)), new Vector(59, -140, 44));
// Set Field of view (horizontal) in radians
renderView.Fov = 1.65806f;
renderer.Start();
renderer.WaitForRenderEnd(60000);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
} |
|
var path = require('path');
var vray = require(path.join(process.env.VRAY_SDK, 'node', 'vray'));
// When VRAY_SDK is set, the App SDK binding will search for the VRaySDKLibrary binary and its dependencies inside VRAY_SDK/bin.
// If the directory structure of a product that uses App SDK doesn't include the binaries inside a /bin folder, VRAY_APPSDK_BIN can be used instead of VRAY_SDK.
// In that case, the App SDK binding will try to load the binaries directly from the folder that VRAY_APPSDK_BIN points at.
// If no environment variables are set, the search path could be passed as the parameter of the function vray.setSDKLibraryPath(path);
var renderer = vray.VRayRenderer();
// Create a new static geometry
var mesh = renderer.classes.GeomStaticMesh();
// Assign a box geometry
mesh.vertices = vray.VectorList(
vray.Vector(-26.7598, -30.5826, 0.0),
vray.Vector(26.7598, -30.5826, 0.0),
vray.Vector(-26.7598, 30.5826, 0.0),
vray.Vector(26.7598, 30.5826, 0.0),
vray.Vector(-26.7598, -30.5826, 125.389),
vray.Vector(26.7598, -30.5826, 125.389),
vray.Vector(-26.7598, 30.5826, 125.389),
vray.Vector(26.7598, 30.5826, 125.389)
);
mesh.faces = vray.IntList(
0, 2, 3,
3, 1, 0,
4, 5, 7,
7, 6, 4,
0, 1, 5,
5, 4, 0,
1, 3, 7,
7, 5, 1,
3, 2, 6,
6, 7, 3,
2, 0, 4,
4, 6, 2
);
mesh.normals = vray.VectorList(
vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0),
vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0), vray.Vector(0.0, 0.0, -1.0),
vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0),
vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0), vray.Vector(0.0, 0.0, 1.0),
vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0),
vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0), vray.Vector(0.0, -1.0, 0.0),
vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0),
vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0), vray.Vector(1.0, 0.0, 0.0),
vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0),
vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0), vray.Vector(0.0, 1.0, 0.0),
vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0),
vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0), vray.Vector(-1.0, 0.0, 0.0)
);
mesh.faceNormals = vray.IntList(
0, 1, 2,
3, 4, 5,
6, 7, 8,
9, 10, 11,
12, 13, 14,
15, 16, 17,
18, 19, 20,
21, 22, 23,
24, 25, 26,
27, 28, 29,
30, 31, 32,
33, 34, 35
);
// Create a BRDF with diffuse color
var newBRDF = new renderer.classes.BRDFDiffuse();
// We specify solid green color
newBRDF.color = new vray.Color(0.0, 1.0, 0.0);
// Create a new material with single BRDF
var newMaterial = new renderer.classes.MtlSingleBRDF();
// Assign the BRDF to the material
newMaterial.brdf = newBRDF;
// Create a new node for the box
var newNode = renderer.classes.Node();
newNode.material = newMaterial; // Assign the new material to the new node
newNode.geometry = mesh; // Assign the mesh
// We must specify transform in order to position the box in the world
newNode.transform = vray.Transform(vray.Matrix(vray.Vector(1.0, 0.0, 0.0),
vray.Vector(0.0, 1.0, 0.0),
vray.Vector(0.0, 0.0, 1.0)), vray.Vector(-20.6777, 131.6402, 0));
// Create the light
var light = renderer.classes.LightRectangle();
// We must specify transform in order to position the light in the world
light.transform = vray.Transform(vray.Matrix(vray.Vector(1.0, 0.0, 0.0),
vray.Vector(0.0, 1.0, 0.0),
vray.Vector(0.0, 0.0, 1.0)), vray.Vector(-20.6777, 131.6402, 150));
// Set white color
light.color = new vray.AColor(1.0, 1.0, 1.0);
// Increase the light's size (by default it's 1x1)
light.u_size = 50;
light.v_size = 50;
// Increase the default intensity
light.intensity = 100;
// Create the camera
var renderView = renderer.classes.RenderView();
// Position the camera towards the box
renderView.transform = vray.Transform(vray.Matrix(vray.Vector(0.92, 0.37, 0.0),
vray.Vector(0.12, -0.3, 0.94),
vray.Vector(0.35, -0.87, -0.32)), vray.Vector(59, -140, 44));
// Set Field of view (horizontal) in radians
renderView.fov = 1.65806;
// Start rendering
renderer.start();
renderer.waitForRenderEnd(60000, function () {
renderer.close();
}); |
|
|