These examples cover the FRED Ray Buffer Handling scripting commands: "Add" - add a ray buffer, "Copy" - copies from one buffer to another, "Delete" - deletes an existing ray buffer, "Get" - retrieves information from a ray buffer, "Move" - moves rays from one buffer to another, "Set" - changes the active ray buffer.
There are no structures required for ray buffer manipulation.
"Add" a ray buffer In this example, a new ray buffer is added to the FRED document. The command returns the identifier of the newly created buffer.
buffid = AddRayBuffer ()
"Copy" a ray buffer The CopyRayBufferToBuffer command is used to copy rays from one buffer to another. In the following example, the number of rays in a specific buffer is first determined along with the number of rays in that buffer (see below). A loop then copies every 4th ray from one buffer to the prior buffer:
count = GetRayBufferRayCount ( id ) id = GetActiveRayBufferIndex ()
For i=0 To count Step 4 CopyRayBufferToBuffer i, id, id-1 Next i
"Delete" a ray buffer Use DeleteRayBuffer to delete the contents of an existing ray buffer. In this example, the rays from the active buffer buf are deleted:
buf = GetActiveRayBufferIndex () DeleteRayBuffer buf
"Get" ray buffer info The "Get" commands return information such as buffer identifier, number of rays in a buffer and the number of buffers. All the "Get" commands are used in conjunction with other Ray Buffer commands.
For instance, to find the total number of buffers in the main ray buffer, use
count = GetRayBufferCount ( )
or the number of auxiliary ray buffers with
count = GetAuxRayBufferCount ( )
Find the identifier for the active ray buffer using
id = GetActiveRayBufferIndex ()
Find the number of rays in a specific buffer using
count = GetRayBufferRayCount ( id )
or in an auxiliary buffer using
count = GetAuxRayBufferRayCount ( buffer )
"Move" a ray buffer
Similar to the Copy operation, MoveRayBufferToBuffer transfers ray information from one buffer to another. However, the move operation removes the specified rays from the existing buffer.
In the following example, the number of rays in a specific buffer is first determined along with the number of rays in that buffer (see below). A loop then moves every 4th ray from one buffer to the prior buffer:
count = GetRayBufferRayCount ( id ) id = GetActiveRayBufferIndex ()
For i=0 To count Step 4 MoveRayBufferToBuffer i, id, id-1 Next i
"Set" a ray buffer
Since numerous ray buffers can exist in FRED, the SetActiveRayBufferIndex command is used to specify which buffer is to become the active ray buffer.
In this example, the command is used to cycle through a set of active ray buffers. Each is traced separately and other operations involving data capture can be performed. In each case, the previously active ray buffer identifier is returned.
count = GetRayBufferCount ( ) For i=0 To count oldBuf = SetActiveRayBufferIndex ( i ) TraceExisting : : Next i
See Also….
|