STOP, before runing this notebook, make sure you can display the examples in the caveMathematica notebook in the CAVE/CUBE

This works, but it will be better to define your own SZGSphere and SZGCylinder instead of overriding the system Sphere and Cylinder

Unprotect[Sphere]
Unprotect[Cylinder]
Unprotect[Cuboid]

Sphere[{x_,y_,z_},rr_]:=ParametricPlot3D[{x+rr  Cos[theta]*Cos[rho],y+ rr Sin[theta]*Cos[rho],z+rr Sin[rho] },{rho,-Pi/2,Pi/2},{theta,0,2π},PlotPoints->12,MaxRecursion->0,Mesh->All,BoxRatios->Automatic][[1]]
Sphere[{{x_,y_,z_}},rr_]:=Sphere[{x,y,z},rr]
Sphere[p_List]:=Sphere[p,1.0]

Cylinder[{P_,Q_}, rr_]:=Module[{X,Y,V,W},
      X=P-Q; Y=If[Cross[X,{1,0,0}]≠{0,0,0}, {1,0,0}, {0,1,0}];   
     V=Cross[X,Y]; V=V/Norm[V];
     W=Cross[V,X]; W=W/Norm[W];
     ParametricPlot3D[rr V Cos[theta] + rr W Sin[theta] + P (1-h) + h Q ,
   {theta, 0, 2  π} , {h,0,1},PlotPoints->12,MaxRecursion->0,Mesh->All,BoxRatios->Automatic][[1]] ]

Define the geometry here, use Polygon, Sphere, Cylinder and Cuboid. DO NOT use Graphics3D[] here, just define a list of primitives.

david1={Polygon[{{-1,-1,-1},{-1,1,1},{1,-1,1}}],Polygon[{{-1,-1,-1},{1,1,-1},{-1,1,1}}],Polygon[{{1,-1,1},{-1,1,1},{1,1,-1}}],Polygon[{{-1,-1,-1},{1,-1,1},{1,1,-1}}]}

Test your model in Mathematica

Graphics3D[david1,Boxed->False]

This is an undocumented functions in Mathematica used to convert polygons into GraphicsComplex, this is necessary for the cave polygon processing code. If this works, you should be ready to display your model in the CAVE!!

Graphics`Mesh`GeometryPlot3D[david1]

If the previous command displayed your model, now you can use the RenderSZG[] displayfunction to show your 3 D model in the CAVE. If you were able to display the examples in the caveMathematica notebook before running this notebook, then this will display your model!

You need a ColorFunction, otherwhise you will get a Part[] error message and the model will be displayed all in white. For now we do not support flat colors, only VertexColors based which are generated with the ColorFunctions option.

Graphics`Mesh`GeometryPlot3D[david1,ColorFunction->(RGBColor[#1,#2,#3]&),DisplayFunction:>((RenderSZG[#];#)&)]