Raytracer:add

Edit

Adds a Mesh or Model to the Raytracer.

The object has a custom transform, and exists on up to 8 layers, given as a bitmask.

After adding all objects to the Raytracer, call Raytracer:build to finalize the raytracer.







Arguments

NameTypeDefaultDescription
meshMesh The Mesh to add to the Raytracer.
xnumber0 The x coordinate to place the object at.
ynumber0 The y coordinate to place the object at.
znumber0 The z coordinate to place the object at.
scalenumber1 The scale of the object.
anglenumber0 The rotation of the object around its rotation axis, in radians.
axnumber0 The x component of the axis of rotation.
aynumber1 The y component of the axis of rotation.
aznumber0 The z component of the axis of rotation.
layersnumber0xff A binary bitmask of 8 layers to place the object on. The object is placed on all layers by default. For example, 0x1 will place the object on the first layer, 0x2 will place it on the second layer, 0x3 for the first two layers, etc.
tagnumbernil A custom tag for the object, provided in the shader when the object is hit. Shaders can use this tag for whatever they want. If nil, the tag will be set to the same ID as the one returned by this function. The tag can be between 0 and 16,777,215.

Returns

NameTypeDescription
idnumber An ID for the object. Use it to move the object layer using Raytracer:set. If the Raytracer is full, the object is not added and this ID will be nil.

Arguments

NameTypeDefaultDescription
modelModel The Model to add to the Raytracer.
xnumber0 The x coordinate to place the object at.
ynumber0 The y coordinate to place the object at.
znumber0 The z coordinate to place the object at.
scalenumber1 The scale of the object.
anglenumber0 The rotation of the object around its rotation axis, in radians.
axnumber0 The x component of the axis of rotation.
aynumber1 The y component of the axis of rotation.
aznumber0 The z component of the axis of rotation.
layersnumber0xff A binary bitmask of 8 layers to place the object on. The object is placed on all layers by default. For example, 0x1 will place the object on the first layer, 0x2 will place it on the second layer, 0x3 for the first two layers, etc.
tagnumbernil A custom tag for the object, provided in the shader when the object is hit. Shaders can use this tag for whatever they want. If nil, the tag will be set to the same ID as the one returned by this function. The tag can be between 0 and 16,777,215.

Returns

NameTypeDescription
idnumber An ID for the object. Use it to move the object layer using Raytracer:set. If the Raytracer is full, the object is not added and this ID will be nil.

Arguments

NameTypeDefaultDescription
meshMesh The Mesh to add to the Raytracer.
positionvector The position to place the object at.
scale3vector The scale of the object.
orientationquaternion The orientation of the object.
layersnumber0xff A binary bitmask of 8 layers to place the object on. The object is placed on all layers by default. For example, 0x1 will place the object on the first layer, 0x2 will place it on the second layer, 0x3 for the first two layers, etc.
tagnumbernil A custom tag for the object, provided in the shader when the object is hit. Shaders can use this tag for whatever they want. If nil, the tag will be set to the same ID as the one returned by this function. The tag can be between 0 and 16,777,215.

Returns

NameTypeDescription
idnumber An ID for the object. Use it to move the object layer using Raytracer:set. If the Raytracer is full, the object is not added and this ID will be nil.

Arguments

NameTypeDefaultDescription
modelModel The Model to add to the Raytracer.
positionvector The position to place the object at.
scale3vector The scale of the object.
orientationquaternion The orientation of the object.
layersnumber0xff A binary bitmask of 8 layers to place the object on. The object is placed on all layers by default. For example, 0x1 will place the object on the first layer, 0x2 will place it on the second layer, 0x3 for the first two layers, etc.
tagnumbernil A custom tag for the object, provided in the shader when the object is hit. Shaders can use this tag for whatever they want. If nil, the tag will be set to the same ID as the one returned by this function. The tag can be between 0 and 16,777,215.

Returns

NameTypeDescription
idnumber An ID for the object. Use it to move the object layer using Raytracer:set. If the Raytracer is full, the object is not added and this ID will be nil.

Arguments

NameTypeDefaultDescription
meshMesh The Mesh to add to the Raytracer.
transformMat4 The transform of the object.
layersnumber0xff A binary bitmask of 8 layers to place the object on. The object is placed on all layers by default. For example, 0x1 will place the object on the first layer, 0x2 will place it on the second layer, 0x3 for the first two layers, etc.
tagnumbernil A custom tag for the object, provided in the shader when the object is hit. Shaders can use this tag for whatever they want. If nil, the tag will be set to the same ID as the one returned by this function. The tag can be between 0 and 16,777,215.

Returns

NameTypeDescription
idnumber An ID for the object. Use it to move the object layer using Raytracer:set. If the Raytracer is full, the object is not added and this ID will be nil.

Arguments

NameTypeDefaultDescription
modelModel The Model to add to the Raytracer.
transformMat4 The transform of the object.
layersnumber0xff A binary bitmask of 8 layers to place the object on. The object is placed on all layers by default. For example, 0x1 will place the object on the first layer, 0x2 will place it on the second layer, 0x3 for the first two layers, etc.
tagnumbernil A custom tag for the object, provided in the shader when the object is hit. Shaders can use this tag for whatever they want. If nil, the tag will be set to the same ID as the one returned by this function. The tag can be between 0 and 16,777,215.

Returns

NameTypeDescription
idnumber An ID for the object. Use it to move the object layer using Raytracer:set. If the Raytracer is full, the object is not added and this ID will be nil.

See also