Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Fancy Bullets
  • If e.g. the definition type of a plugin property being set is VectorList and you try to assign an array or a list of 3*N floats or doubles to it, the data will be automatically reinterpreted or converted to a VectorList of N elements often more efficiently than doing it in your code. This can be useful in cases where you receive the data in a format different from the expected one.
  • So code like this will work (Python/js-like syntax is used in the examples below but the technique would work in all supported languages):
    mesh.vertices = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9] # values are automatically converted
    or
    mesh.vertices = FloatList(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9) # value is directly reinterpreted
    mesh.vertices value is now VectorList(Vector(1.1, 2.2, 3.3), Vector(4.4, 5.5, 6.6), Vector(7.7, 8.8, 9.9))
  • Note that e.g. std::vector<double> in C++ and List<double> or double[] in C# will be automatically converted to FloatList, VectorList or ColorList efficiently depending on the property definition type.
    But to use it you'd have to call the general Plugin.setValue(propertyName, value) function because the property setters in C++ and properties in C# are strongly typed and wouldn't accept data of any other type.

Node.js specific

...

UI Text Box
typenote

Plugin properties (parameters) are always set and read by value, not by reference!

...

Fancy Bullets
  • Many methods in the Node.js binding offer both synchronous and asynchronous versions. When you don't have to wait for the whole process to complete, you can use the asynchronous version.
  • In addition to the standard synchronous VRayRenderer object construction, the asynchronous API vray.createVRayRenderer(callback, options) is also available.
  • Similarly, vray.createVRayServer(callback, options) could be used to construct a VRayServer object asynchronously.
  • The following VRayRenderer methods have sync/async versions: start, export, pickPlugin, pickPlugins, load, append, loadAsText, appendAsText, loadFromBuffer, appendFromBuffer, loadFiltered, appendFiltered, loadAsTextFiltered, appendAsTextFiltered, appendFromBufferFiltered, saveIrradianceMapFile, saveLightCacheFile, savePhotonMapFile, saveCausticsFile, addHosts, removeHosts, resetHosts, getAllHosts, getActiveHosts, getInactiveHosts
  • The following VRayServer methods have sync/async versions: addHosts, removeHosts, resetHosts, getAllHosts, getActiveHosts, getInactiveHosts
  • The following VRayImage methods have sync/async versions: createFromBuffer, save, compress, getDownscaled, getResized, getDownscaledCropped, getResizedCropped, getFitIn, getFitOut, getCutIn, load, loadSize
  • The following VFB methods have sync/async versions: saveImage, loadImage

...

Tabs Container
directionhorizontal
Tabs Page
titleNode.js
Code Block
languagejs
var a = FloatList(0.1, 0.2, 0.3, 0.4, 0.5, 0.6); // let's have a float list
var b = Buffer.from(a.buffer); // now the buffer 'b' shares its bytes with 'a'
var c = new VectorList(b.buffer); // now the VectorList shares its data with buffer 'b' and the list 'a'
// 'c' is VectorList(Vector(0.1, 0.2, 0.3), Vector(0.4, 0.5, 0.6))

Since v6.20

Two new typed-list types were added in version 6.20:

...

Tabs Container
directionhorizontal
Tabs Page
titleC++
Code Block
languagecpp
VectorList vectors(500000); // A large list of vectors
// Fill in the list...

// This will set a copy of vectors inside V-Ray memory
GeomStaticMesh.set_vertices(vectors);

// But this will get the vertices data pointer and set it directly into V-Ray memory avoiding the expensive copy operation
GeomStaticMesh.set_vertices(std::move(vectors));


Or in a more complex example:

Tabs Container
directionhorizontal
Tabs Page
titleC++
Code Block
languagecpp
VectorList vectors(500000); // A large list of vectors
IntList ints(1500000); // A large list of ints
// Fill in the lists...

ValueList channel;
channel.push_back(Value(1));
channel.push_back(Value(std::move(vectors))); // Move vectors data to Value and Value to ValueList
channel.push_back(Value(std::move(ints))); // Move ints data to Value and Value to ValueLis

ValueList mapChannels;
mapChannels.push_back(Value(std::move(channel))); // Move channel data to Value and Value to mapChannels
mesh.set_map_channels(std::move(mapChannels)); // Move large data (vectors and ints) to V-Ray memory and copy the rest

Ref lists

This is an advanced feature, enabled by the VRAY_SDK_INTEROPERABILITY macro. Use these types for large lists of primitives. The available types are: IntRefList, FloatRefList, VectorRefList, ColorRefList, CharString, CharStringRefList, Value, ValueRefList. They are also suitable for migrating existing code written against the V-Ray SDK to the AppSDK.

...

Tabs Container
directionhorizontal
Tabs Page
titlePython
Code Block
languagepy
a=IntList(1, 2, 3) # create an int list 'a' of 3 elements and a[0]=1, a[1]=2, a[2]=3
b=IntList(count=300) # create an int list 'b' with 300 elements initialized to 0. You can set their values later.

s=[1, 2, 3, 4] # if you already have a different sequence and want to create a typed array from its elements
a=IntList(source=s) # the 'source' keyword can be used.