Description Copies the N'th importance sample specification from a surface and applies the same specification to a destination node and its descendants.
Syntax nadded = ImpSampCopy( surf, idx, dst, recurse )
Parameters nadded (Long) Number of surfaces that the importance sample was copied to.
surf As Long Node number of the surface from with the I'th importance sample is being copied.
idx As Long Index (0 based) of the importance sample on the surf node that is being copied.
dst As Long Node number of the destination where the importance sample is being copied to. If recurse = True, then the importance sample is copied to all of the descendant surfaces of the dst node. If the surf node is a descendant of the dst node, the surf node is ignored and does not receive a copy of its own importance sample.
recurse As Boolean If True, the importance sample is copied to the descendant surfaces of the dst node.
Example #1 The example below defines a "default" hemispheric importance sample to reference surface in the model and then copies the importance sample to all other surfaces by calling ImpSampCopy onto the Geometry folder (node #2) with the recursive option.
Sub Main
'Remove all importance samples from the model RemoveAllImpSampProp( 2 ) 'Called on the Geometry folder
'Define a hemispheric importance sample on a reference surface Dim refsurf As Long, isidx As Long refsurf = FindFullName( "Geometry.Cube.Right Face (+X)" ) isidx = ImpSampAddDir( refsurf, "Default", 90, 0, 0, 1, -4 )
'Copy importance sample to all other surfaces in the model Dim nadded As Long nadded = ImpSampCopy( refsurf, isidx, 2, True ) 'Apply to Geometry folder Update
Print "Applied hemispheric importance sample to " & nadded & " surfaces."
End Sub
Example #2 The example below removes all importance samples from the model, defines a new importance sample that subtends a 5 degree semi-angle about the specular direction on a reference surface and then copies this importance sample to all other surfaces that have either the Reflective Optics or Refractive Optics raytrace controls.
Sub Main
'Remove all importance samples from the model RemoveAllImpSampProp( 2 ) 'Called on the Geometry folder
'Add a specular type importance sample to an optical surface Dim refSurf As Long, isRef As Long refSurf = FindFullName( "Geometry.Subassembly 4.Lens 1.Surface 1" ) isRef = ImpSampAddSpecular( refSurf, "Specular 5", 5 ) 'Specular, 5 degree semi-angle ImpSampSetRayCount( refSurf, isRef, 20 ) '20 scattered rays
'Copy this importance sample to all surfaces with specific raytrace controls Dim reflCtrl As Long, refrCtrl As Long, curEnt As Long, sctrl As Long, iscount As Long reflCtrl = FindRaytraceCtrl( "Reflective Optics" ) refrCtrl = FindRaytraceCtrl( "Refractive Optics" ) For curEnt = 0 To GetEntityCount()-1 If IsSurface(curEnt) Then sctrl = GetSurfRaytraceCtrl( curEnt ) If (sctrl = reflCtrl) Or (sctrl = refrCtrl) Then 'Copy the importance sample from the reference surface to the current entity iscount += ImpSampCopy( refSurf, isRef, curEnt, False ) End If End If Next Update
Print "Assigned importance sample to " & iscount & " surfaces."
End Sub
See Also Importance Sample Scripting Commands
|