Initialization

Evaluate this group first to get Mathematica ready (select group and Shift - Enter)

SzgLink Initialization

SetDirectory[NotebookDirectory[]]
<<SzgLink`

MathLink connections

Launch remote TCPIP CAVE application

(*Beckman Fire (Cube console) *)
machineip="130.126.127.24"

(* Ports for Mathematica -> caveMathematica communication. Evaluate this third. 
Note port2 must be port1+1 (as a string). *)

port1 ="9996";
port2 = ToString[ToExpression[port1]+1];
(* Ports for caveMathematica -> Mathematica communication *)
masterport1 = ToString[ToExpression[port2]+1]
masterport2 = ToString[ToExpression[masterport1]+1]

Open MathLink connection in Listen Mode (Evaluate this 4th).

$szglink = Install[port1<>"@"<>machineip<>","<>port2<>"@"<>machineip, LinkMode->Listen, LinkProtocol->"TCPIP"]

Now, start CaveMathematica on Fire (the Cube console):
Standalone :
 	caveMathematica 130.126.127.24
or

For a cluster :
   dex < virtual_computer > caveMathematica 130.126.127.24

Evaluate this group to establish a controller link

CaveOpenSecondaryLink[" -linkconnect -linkprotocol tcpip -linkname "<>masterport1<>"@"<>machineip<>","<>masterport2<>"@"<>machineip]

$szgcavelink = LinkOpen[masterport1<>"@"<>machineip<>","<>masterport2<>"@"<>machineip,LinkMode->Listen, LinkProtocol->"TCPIP"]

MathLink`AddSharingLink[$szgcavelink,MathLink`AllowPreemptive->True]

Closing the Connection

Close CaveMathematica on Fire first

Evaluate this group

If[$szgcavelink=!=None,LinkClose[$szgcavelink]]
Uninstall[$szglink]
$szglink=None;
$szgcavelink = None;

Running Code

Changing the wand graphic:

WandSZG[]

RenderSZG to show an object:

The object can be made first and then passed to RenderSZG:

Object=SphericalPlot3D[1+Sin[5 ϕ] Sin[10 θ]/10,{θ,0,π},{ϕ,0,2π},ColorFunction->(ColorData["Rainbow"][#6]&),Mesh->None,PlotPoints->25,Boxed->False,Axes->False]

RenderSZG[Object]

It can also be passed directly:

RenderSZG[ParametricPlot3D[{Cos[θ]Sin[ϕ],Sin[θ]Sin[ϕ],Cos[ϕ]},{θ,0,2π},{ϕ,0,2π}]]

Animations are also possible (hit "play"):

Manipulate[RenderSZG[ParametricPlot3D[{Cos[θ]Sin[ϕ],Sin[θ]Sin[ϕ],r Cos[ϕ]},{θ,0,2π},{ϕ,0,2π}]], {r,1,0,.05}]

It should be possible to hook the Cave controls up to the dial in Manipulate to allow control of the objects.