These examples cover the FRED general Ray Data scripting commands: "Add" - add a ray buffer, "Get" - retrieves information from a ray buffer, "Set" - changes the active ray buffer.
The structure listed below contains the parameters required to define ray data:
"Add" a ray
The following example constructs polar grid of rays in the z=0 plane. Here the rays are positioned like the spokes of a wheel: Dim r As T_RAY nrings=5 'number of rings aprad=2 'aperture radius r.z=0 'set rays to be in the z=0 plane 'center ray For i=spc To aprad Step spc
"Get" ray data
The "Get" commands are used to return either ray count or specific ray information.
Getting ray count involves a single command that returns the number of rays in the active ray buffer:
count=GetRayCount()
GetRay populates an existing T_RAY structure with the current ray parameters. The example below gets the data for ray 12 and places it in T_RAY structure r. Here, some of the data is printed to the output window.
Dim r As T_RAY If IsRayLive(i) Then GetRay 12, r Print r.x,r.y,r.z Print "The ray is active -", r.active End If
"Set" a ray
Use "SetRay" to change the parameters of an existing ray. Here, ray number 35 is made inactive (nontraceable):
Dim r As T_RAY r.active=False SetRay 35, r
Looping over Rays
The recommended method of looping over rays is shown below. The commands GetFirstRay and GetNextRay retrieve individual ray data into the T_RAY structure. See Multi-Threaded Raytracing for further details on looping over rays.
success = GetFirstRay(i,tr) While success : : : : success = GetNextRay(i,tr) Wend
See Also….
|