### C24_fixedCore.slf
### 4D 24-cell Polytope -- with marked midpoints on all edges.
### suitbale for finding two Hamiltonian cycles represented by triangle strips (for 2-manifold coverage).
### ASSUME: the 2 paths can transform into each other with a C2 rotation around the z-axis
### color EVERYTHING to avoid face conflicts; 
### work from inside out, make sure everything is consistent
### hand-designed fixed core of four octas and attached "flag triangles".
### CHS 2005/7/23/ --- 2006/2/28 --- 2006/5/26

#Try C2 -- 180-degree rotation around z switches color;
# Start coloring from the 3-story octa tower plus outer octa  
# via the connecting "flag triangles" towards the middle connectors.
##############################################################################

tclinit {
  set winName .slfWINDOW
  
  source SLIDEUI.tcl
  source MATH.tcl
}

tclinit {
  
  proc CreateSliders { parent name } {
    set subname "slf_[subst $name]"
    
    if { $parent == {} } {
	set root .$subname
    } elseif { $parent == "." } {
	set root .$subname
    } else {
	set root $parent.$subname
    }
    
    toplevel $root
    
    set rBTL  [CreateScale $name $root rBTL "Fce: r.Base TopLeft"     0  0 360 90  1 horizontal]
    set rBTR  [CreateScale $name $root rBTR "Fce: r.Base TopRight"    0  0 360 90  1 horizontal]
    set rBBL  [CreateScale $name $root rBBL "Fce: r.Base BotLeft"     0  0 360 90  1 horizontal]
    set rBBR  [CreateScale $name $root rBBR "Fce: r.Base BotRight"    0  0 360 90  1 horizontal]
    set rPTL  [CreateScale $name $root rPTL "Fce: r.HPyr TopLeft"     0  0 360 90  1 horizontal]
    set rPTR  [CreateScale $name $root rPTR "Fce: r.HPyr TopRight"    0  0 360 90  1 horizontal]
    set rPBL  [CreateScale $name $root rPBL "Fce: r.HPyr BotLeft"     0  0 360 90  1 horizontal]
    set rPBR  [CreateScale $name $root rPBR "Fce: r.HPyr BotRight"    0  0 360 90  1 horizontal]

    set numS  [CreateScale $name $root numS "visib. Shells"     5  0   5  1  1 horizontal]
    set numP  [CreateScale $name $root numP "visib. Paths"      4  0   5  1  1 horizontal]
    set numF  [CreateScale $name $root numF "visib. Faces"      2  0   5  1  1 horizontal]
    
    pack    $rBTL $rBTR $rBBL $rBBR  $rPTL $rPTR $rPBL $rPBR  $numS $numP $numF   -side top -fill x
  }
  CreateSliders $winName slider
}

tclinit {

  proc CreateSli3 { parent name } {
    set subname "slf_[subst $name]"
    
    if { $parent == {} } {
	set root .$subname
    } elseif { $parent == "." } {
	set root .$subname
    } else {
	set root $parent.$subname
    }
    
    toplevel $root
    
    set v1  [CreateScale $name $root v1 "Vtx:: cubo top"    180  0 360 90  1 horizontal]
    set v2  [CreateScale $name $root v2 "Vtx:: cubo hi-A"    90  0 360 90  1 horizontal]
    set v3  [CreateScale $name $root v3 "Vtx:: cubo hi-B"     0  0 360 90  1 horizontal]
    set v4  [CreateScale $name $root v4 "Vtx:: cubo lo-A"   270  0 360 90  1 horizontal]
    set v5  [CreateScale $name $root v5 "Vtx:: cubo lo-B"   180  0 360 90  1 horizontal]
    set v6  [CreateScale $name $root v6 "Vtx:: cubo bot"      0  0 360 90  1 horizontal]

    set o1  [CreateScale $name $root o1 "Vtx:: oconn top"      0  0 360 90  1 horizontal]
    set o2  [CreateScale $name $root o2 "Vtx:: oconn hi"     180  0 360 90  1 horizontal]
    set o3  [CreateScale $name $root o3 "Vtx:: oconn mid-A"  270  0 360 90  1 horizontal]
    set o4  [CreateScale $name $root o4 "Vtx:: oconn mid-B"  180  0 360 90  1 horizontal]
    set o5  [CreateScale $name $root o5 "Vtx:: oconn lo"     270  0 360 90  1 horizontal]
    set o6  [CreateScale $name $root o6 "Vtx:: oconn bot"    270  0 360 90  1 horizontal]
    
    pack    $v1 $v2 $v3 $v4 $v5 $v6    $o1 $o2 $o3 $o4 $o5 $o6  -side top -fill x
  }

  CreateSli3 $winName sli3
}

####################
# BALLS
####################

sphere ballB
  radius 0.1
  zslices 4
  thetaslices 8
endsphere

sphere ballS
  radius 0.05
  zslices 2
  thetaslices 4
endsphere

group vertices
# inner octa
  instance ballS translate (0.3 0 0.3 )  rotate(0 0 1)(-90) endinstance
  instance ballS translate (0.3 0.3 0 )  rotate(0 0 1)(90) endinstance
  instance ballS translate (0.3 0 -0.3 )  rotate(0 0 1)(0) endinstance

# inner connectors
  instance ballS translate (0.5 0 0.8)  rotate(0 0 1)(0) endinstance
  instance ballS translate (0.8 0 0.5 ) rotate(0 0 1)(0) endinstance 
  instance ballS translate (0.8 0.5 0 )  rotate(0 0 1)(-90) endinstance
  instance ballS translate (0.8 -0.5 0 )  rotate(0 0 1)(180) endinstance
  instance ballS translate (0.8 0 -0.5 )  rotate(0 0 1)(-90) endinstance
  instance ballS translate (0.5 0 -0.8)  rotate(0 0 1)(0) endinstance

# cubocta
  instance ballS translate (0.5 0.5 1 )  rotate(0 0 1)({expr $sli3_v1}) endinstance
  instance ballS translate (1 0.5 0.5 )  rotate(0 0 1)({expr $sli3_v2}) endinstance
  instance ballS translate (1 -0.5 0.5 )  rotate(0 0 1)({expr $sli3_v3}) endinstance
  instance ballS translate (1 0.5 -0.5 )  rotate(0 0 1)({expr $sli3_v4}) endinstance
  instance ballS translate (1 -0.5 -0.5 )  rotate(0 0 1)({expr $sli3_v5}) endinstance
  instance ballS translate (0.5 0.5 -1 )  rotate(0 0 1)({expr $sli3_v6}) endinstance

# outer connectors
  instance ballS translate (0.5 0 2)  rotate(0 0 1)({expr $sli3_o1}) endinstance
  instance ballS translate (2 0 0.5 )  rotate(0 0 1)({expr $sli3_o2}) endinstance
  instance ballS translate (2 0.5 0 )  rotate(0 0 1)({expr $sli3_o3}) endinstance
  instance ballS translate (2 -0.5 0 )  rotate(0 0 1)({expr $sli3_o4}) endinstance
  instance ballS translate (2 0 -0.5 )  rotate(0 0 1)({expr $sli3_o5}) endinstance
  instance ballS translate (0.5 0 -2)  rotate(0 0 1)({expr $sli3_o6}) endinstance

# outer octa
  instance ballS translate (1.5 0 1.5 )  rotate(0 0 1)(180) endinstance
  instance ballS translate (1.5 1.5 0 )  rotate(0 0 1)(-90) endinstance
  instance ballS translate (1.5 0 -1.5 ) rotate(0 0 1)(90) endinstance
endgroup



### POINTS ###########################################################

point X  (3 0 0 ) endpoint
point A  (-3 0 0 ) endpoint
point Y  (0 3 0 ) endpoint
point B  (0 -3 0 ) endpoint
point Z  (0 0 3 ) endpoint
point C  (0 0 -3 ) endpoint

point xy  (1 1 0) endpoint
point xb  (1 -1 0) endpoint
point ay  (-1 1 0) endpoint
point ab  (-1 -1 0) endpoint
point yz  (0 1 1) endpoint
point yc  (0 1 -1) endpoint
point bz  (0 -1 1) endpoint
point bc  (0 -1 -1) endpoint
point xz  (1 0 1) endpoint
point xc  (1 0 -1) endpoint
point az  (-1 0 1) endpoint
point ac  (-1 0 -1) endpoint

point ix  (0.6 0 0 ) endpoint
point ia  (-0.6 0 0 ) endpoint
point iy  (0 0.6 0 ) endpoint
point ib  (0 -0.6 0 ) endpoint
point iz  (0 0 0.6 ) endpoint
point ic  (0 0 -0.6 ) endpoint

####  EDGE MID-POINTS ##########################
# Outer Octa 
point Oxy  (1.5 1.5 0 ) endpoint
point Oxb  (1.5 -1.5 0 ) endpoint
point Oay  (-1.5 1.5 0 ) endpoint
point Oab  (-1.5 -1.5 0 ) endpoint
point Oxz  (1.5 0 1.5 ) endpoint
point Oxc  (1.5 0 -1.5 ) endpoint
point Oaz  (-1.5 0 1.5 ) endpoint
point Oac  (-1.5 0 -1.5 ) endpoint
point Oyz  (0 1.5 1.5 ) endpoint
point Oyc  (0 1.5 -1.5 ) endpoint
point Obz  (0 -1.5 1.5 ) endpoint
point Obc  (0 -1.5 -1.5 ) endpoint

# Inner Octa
point Ixy  (0.3 0.3 0 ) endpoint
point Ixb  (0.3 -0.3 0 ) endpoint
point Iay  (-0.3 0.3 0 ) endpoint
point Iab  (-0.3 -0.3 0 ) endpoint
point Ixz  (0.3 0 0.3 ) endpoint
point Ixc  (0.3 0 -0.3 ) endpoint
point Iaz  (-0.3 0 0.3 ) endpoint
point Iac  (-0.3 0 -0.3 ) endpoint
point Iyz  (0 0.3 0.3 ) endpoint
point Iyc  (0 0.3 -0.3 ) endpoint
point Ibz  (0 -0.3 0.3 ) endpoint
point Ibc  (0 -0.3 -0.3 ) endpoint

# Cubocta Edges
point mx_yz  (1 0.5 0.5 ) endpoint
point mx_yc  (1 0.5 -0.5 ) endpoint
point mx_bz  (1 -0.5 0.5 ) endpoint
point mx_bc  (1 -0.5 -0.5 ) endpoint
point ma_yz  (-1 0.5 0.5 ) endpoint
point ma_yc  (-1 0.5 -0.5 ) endpoint
point ma_bz  (-1 -0.5 0.5 ) endpoint
point ma_bc  (-1 -0.5 -0.5 ) endpoint

point my_xz  (0.5 1 0.5 ) endpoint
point my_xc  (0.5 1 -0.5 ) endpoint
point my_az  (-0.5 1 0.5) endpoint
point my_ac  (-0.5 1 -0.5) endpoint
point mb_xz  (0.5 -1 0.5 ) endpoint
point mb_xc  (0.5 -1 -0.5 ) endpoint
point mb_az  (-0.5 -1 0.5 ) endpoint
point mb_ac  (-0.5 -1 -0.5 ) endpoint

point mz_xy  (0.5 0.5 1 ) endpoint
point mz_xb  (0.5 -0.5 1 ) endpoint
point mz_ay  (-0.5 0.5 1 ) endpoint
point mz_ab  (-0.5 -0.5 1 ) endpoint
point mc_xy  (0.5 0.5 -1 ) endpoint
point mc_xb  (0.5 -0.5 -1 ) endpoint
point mc_ay  (-0.5 0.5 -1 ) endpoint
point mc_ab  (-0.5 -0.5 -1 ) endpoint

#outer connectors
point ko_xz  (2 0 0.5 ) endpoint
point ko_xc  (2 0 -0.5 ) endpoint
point ko_xy  (2 0.5 0 ) endpoint
point ko_xb  (2 -0.5 0 ) endpoint
point ko_az  (-2 0 0.5) endpoint
point ko_ay  (-2 0.5 0) endpoint
point ko_ab  (-2 -0.5 0) endpoint
point ko_ac  (-2 0 -0.5) endpoint

point ko_yz  (0 2 0.5) endpoint
point ko_yc  (0 2 -0.5) endpoint
point ko_yx  (0.5 2 0) endpoint
point ko_ya  (-0.5 2 0) endpoint
point ko_bc  (0 -2 -0.5) endpoint
point ko_bz  (0 -2 0.5) endpoint
point ko_bx  (0.5 -2 0) endpoint
point ko_ba  (-0.5 -2 0) endpoint

point ko_zx  (0.5 0  2) endpoint
point ko_zy  (0 0.5  2) endpoint
point ko_zb  (0 -0.5 2) endpoint
point ko_za  (-0.5 0 2) endpoint
point ko_ca  (-0.5 0 -2) endpoint
point ko_cx  (0.5 0 -2) endpoint
point ko_cy  (0 0.5 -2) endpoint
point ko_cb  (0 -0.5 -2) endpoint

#inner connectors
point ki_xz  (0.8 0 0.5 ) endpoint
point ki_xc  (0.8 0 -0.5 ) endpoint
point ki_xy  (0.8 0.5 0 ) endpoint
point ki_xb  (0.8 -0.5 0 ) endpoint
point ki_ay  (-0.8 0.5 0 ) endpoint
point ki_ab  (-0.8 -0.5 0 ) endpoint
point ki_az  (-0.8 0 0.5 ) endpoint
point ki_ac  (-0.8 0 -0.5 ) endpoint

point ki_yx  (0.5 0.8 0 ) endpoint
point ki_ya  (-0.5 0.8 0 ) endpoint
point ki_yz  (0 0.8 0.5 ) endpoint
point ki_yc  (0 0.8 -0.5 ) endpoint
point ki_bx  (0.5 -0.8 0 ) endpoint
point ki_ba  (-0.5 -0.8 0 ) endpoint
point ki_bz  (0 -0.8 0.5 ) endpoint
point ki_bc  (0 -0.8 -0.5 ) endpoint

point ki_zx  (0.5 0 0.8 ) endpoint
point ki_za  (-0.5 0 0.8 ) endpoint
point ki_zb  (0 -0.5 0.8 ) endpoint
point ki_zy  (0 0.5  0.8) endpoint
point ki_cx  (0.5 0 -0.8) endpoint
point ki_ca  (-0.5 0 -0.8) endpoint
point ki_cb  (0 -0.5 -0.8) endpoint
point ki_cy  (0 0.5 -0.8) endpoint

##################### Center area of selected faces acting as potential connectors  ###############

#Inner octa
face io1 (Ixz Ibz Ixb) endface
face io2 (Iac Iyc Iay) endface
object ioc (io1 io2)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject

#Top and Bottom Octa == vertical pyramid tips
face t1 (mz_xy ko_zx ko_zy) endface
face t2 (mz_xb ko_zx ko_zb) endface
face t3 (mz_ay ki_za ki_zy) endface   # opposite, bottom pair
face t4 (mz_ab ki_za ki_zb) endface
object vTP (t1 t2 t3 t4)   solid SLF_HOLLOW 
 #shading SLF_WIRE   
endobject # top pyr

face t5 (mc_xy ki_cx ki_cy) endface
face t6 (mc_xb ki_cx ki_cb) endface
face t7 (mc_ay ko_ca ko_cy) endface
face t8 (mc_ab ko_ca ko_cb) endface
object vBP (t5 t6 t7 t8)   solid SLF_HOLLOW   
 #shading SLF_WIRE   
endobject # bot pyr

#Outer octa
face oo1 (Oxz Obz Oxb) endface
face oo2 (Oac Oyc Oay) endface
object ooc (oo1 oo2)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject

## the four octas contain a total of 32 triangles


#Vertical Flags
face ft1 (Ixz ki_xz ki_zx) endface
face ft2 (Iyz ki_yz ki_zy) endface
face fb1 (Ibc ki_bc ki_cb) endface
face fb2 (Ixc ki_xc ki_cx) endface
object flgi (fb1 ft1 fb2 ft2)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject

face ft3 (Oaz ko_az ko_za) endface
face ft4 (Oyz ko_yz ko_zy) endface
face fb3 (Obc ko_bc ko_cb) endface
face fb4 (Oac ko_ac ko_ca) endface
object flgo (fb3 ft3 fb4 ft4)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject

#Horizontal Flags
face fm1 (Iab ki_ab ki_ba) endface
face fm2 (Iay ki_ay ki_ya) endface
face fht1 (mz_ab ma_bz mb_az) endface
face fht2 (mz_xb mx_bz mb_xz) endface
face fhb1 (mc_xy mx_yc my_xc) endface
face fhb2 (mc_ay ma_yc my_ac) endface
face fho1 (Oxy ko_xy ko_yx) endface
face fho2 (Oxb ko_xb ko_bx) endface
object flgh (fm1 fm2 fht1 fht2 fhb1 fhb2 fho1 fho2)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject

## a total of 32 "flag triangles"


#inner horizontal pyramid bases 
face ib1 (mx_yz ki_xz ki_xy) endface
face ib2 (mx_yc ki_xc ki_xy) endface
face ib3 (mx_bz ki_xz ki_xb) endface
face ib4 (mx_bc ki_xc ki_xb) endface
face ib5 (my_az ki_yz ki_ya) endface
face ib6 (my_ac ki_yc ki_ya) endface
face ib7 (my_xz ki_yz ki_yx) endface
face ib8 (my_xc ki_yc ki_yx) endface
object btl (ib3 ib7)   solid SLF_HOLLOW   
 #shading SLF_WIRE   
endobject
object btr (ib1 ib5)   solid SLF_HOLLOW   
 #shading SLF_WIRE   
endobject
object bbl (ib4 ib8)   solid SLF_HOLLOW   
 #shading SLF_WIRE   
endobject
object bbr (ib2 ib6)   solid SLF_HOLLOW   
 #shading SLF_WIRE   
endobject

#outer horizontal pyramids
face ip1 (mx_yz ko_xz ko_xy) endface
face ip2 (mx_yc ko_xc ko_xy) endface
face ip3 (mx_bz ko_xz ko_xb) endface
face ip4 (mx_bc ko_xc ko_xb) endface
face ip5 (my_az ko_yz ko_ya) endface
face ip6 (my_ac ko_yc ko_ya) endface
face ip7 (my_xz ko_yz ko_yx) endface
face ip8 (my_xc ko_yc ko_yx) endface
object ptl (ip3 ip7)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject
object ptr (ip1 ip5)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject
object pbl (ip4 ip8)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject
object pbr (ip2 ip6)   solid SLF_HOLLOW  
 #shading SLF_WIRE   
endobject

############################################################################
############################################################################
#######    Line segments marking the path through various triangles:


polyline i1  pointlist (  Iab Ibz Ixz  ki_xz  ) endpolyline      # inner octa
polyline i2  pointlist (  Iay Iyc Ixc  ki_xc  ) endpolyline

polyline m4  pointlist (  mz_xb ko_zx ko_zy  ko_yz  ) endpolyline       # upper pyr
polyline m5  pointlist (  mz_ab ki_za ki_zy  ki_yz  ) endpolyline       # upper pyr

polyline m6  pointlist (  mc_ay ki_ca ki_cb  ki_bc  ) endpolyline         # lower pyr  
polyline m7  pointlist (  mc_xy ko_cx ko_cb  ko_bc  ) endpolyline         # lower pyr  

group path0        ## inner octa
  instance i1   endinstance
  instance i2   endinstance
                   ## Inner 2 Octa-Pyramids 
  instance m4 endinstance
  instance m5 endinstance
  instance m6 endinstance
  instance m7 endinstance
endgroup


polyline o1  pointlist (  ko_az   Oaz Obz Oxb  ) endpolyline         #outer octa
polyline o2  pointlist (  ko_ac   Oac Oyc Oxy    ) endpolyline       #outer octa

group path1 ## Outer Octahedron 
  instance o1  endinstance
  instance o2  endinstance
endgroup



##################################################################################

####   24-Cell Edges  ############################################################

polyline pix_iy   pointlist (ix iy)   endpolyline
polyline piz_ix   pointlist (iz ix)   endpolyline
polyline piy_ic   pointlist (iy ic)   endpolyline

polyline piy_yz   pointlist (iy yz)   endpolyline
polyline pic_bc   pointlist (ic bc)   endpolyline
polyline piz_az   pointlist (iz az)   endpolyline
polyline pix_xc   pointlist (ix xc)   endpolyline
polyline pia_ay   pointlist (ia ay)    endpolyline
polyline pib_xb   pointlist (ib xb)   endpolyline

polyline pab_ac   pointlist (ab ac)   endpolyline
polyline pab_bz   pointlist (ab bz)   endpolyline
polyline pxz_bz   pointlist (xz bz)   endpolyline
polyline pxz_xy   pointlist (xz xy)   endpolyline
polyline pyc_xy   pointlist (yc xy)   endpolyline
polyline pyc_ac   pointlist (yc ac)   endpolyline

polyline pZ_yz    pointlist (Z yz)   endpolyline
polyline pB_bc    pointlist (B bc)    endpolyline
polyline pY_ay    pointlist (Y ay)    endpolyline
polyline pA_az    pointlist (A az)    endpolyline
polyline pC_xc    pointlist (C xc)    endpolyline
polyline pX_xb    pointlist (X xb)   endpolyline

polyline pZ_X     pointlist (Z X)     endpolyline
polyline pX_Y     pointlist (X Y)    endpolyline
polyline pY_C     pointlist (Y C)     endpolyline

#################################################################################
### All edges as frame of reference

group innerocta  
# inner octa  BLACK
  instance piz_ix surface K endinstance
  instance pix_iy surface K endinstance
  instance piy_ic surface K endinstance
endgroup

group inneredges  
# cubocta and inner connectors (top down)   GRAY
  instance piz_az   endinstance
  instance piy_yz   endinstance
  instance pib_xb   endinstance
  instance pix_xc   endinstance
  instance pic_bc   endinstance
  instance pia_ay   endinstance
endgroup

group cubocta
   instance pxz_bz surface K   endinstance
   instance pab_bz surface K   endinstance
   instance pxz_xy surface K   endinstance
   instance pab_ac surface K   endinstance
   instance pyc_ac surface K   endinstance
   instance pyc_xy surface K   endinstance
endgroup

group outeredges  
# outer connectors   GRAY
  instance pC_xc   endinstance
  instance pB_bc   endinstance
  instance pX_xb   endinstance
  instance pY_ay   endinstance
  instance pA_az   endinstance
  instance pZ_yz   endinstance
endgroup

group outerocta 
# outer octa  BLACK
  instance pZ_X  surface K   endinstance
  instance pX_Y  surface K   endinstance
  instance pY_C  surface K   endinstance
endgroup

#############################################################################
#############################################################################

group assembly  
  # outer orientation markers
  instance ballB translate (3 0 0 ) surface R endinstance
  instance ballB translate (0 0 3 ) surface B endinstance
  instance ballB translate (0 0 -3 ) surface D endinstance

  # edge midpoints  -- opposite pairs (around z) are differently colored -- individual rotations set near path definitions
  instance vertices surface W endinstance
  instance vertices surface W rotate (0 0 1)(90) endinstance
  instance vertices surface M rotate (0 0 1)(180) endinstance
  instance vertices surface M rotate (0 0 1)(270) endinstance

  # edges of the 24-Cell  -- 4 quadrants
  instance innerocta surface D lod {if {$slider_numS >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} }  endinstance
  instance innerocta surface D lod {if {$slider_numS >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(180) endinstance
  instance innerocta surface D lod {if {$slider_numS >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(90) endinstance
  instance innerocta surface D lod {if {$slider_numS >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(-90) endinstance 

  instance inneredges surface D lod {if {$slider_numS >= 2} {expr $SLF_FULL} else {expr $SLF_OFF} }  endinstance
  instance inneredges surface D lod {if {$slider_numS >= 2} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(180) endinstance
  instance inneredges surface D lod {if {$slider_numS >= 2} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)( 90) endinstance
  instance inneredges surface D lod {if {$slider_numS >= 2} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(-90) endinstance 

  instance cubocta surface D lod {if {$slider_numS >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} }  endinstance
  instance cubocta surface D lod {if {$slider_numS >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(180) endinstance
  instance cubocta surface D lod {if {$slider_numS >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)( 90) endinstance
  instance cubocta surface D lod {if {$slider_numS >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(-90) endinstance 

  instance outeredges surface D lod {if {$slider_numS >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} }  endinstance
  instance outeredges surface D lod {if {$slider_numS >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(180) endinstance
  instance outeredges surface D lod {if {$slider_numS >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(90) endinstance
  instance outeredges surface D lod {if {$slider_numS >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(-90) endinstance 

  instance outerocta surface D lod {if {$slider_numS >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} }  endinstance
  instance outerocta surface D lod {if {$slider_numS >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(180) endinstance
  instance outerocta surface D lod {if {$slider_numS >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(90) endinstance
  instance outerocta surface D lod {if {$slider_numS >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate (0 0 1)(-90) endinstance 

##### core faces to mark connectors for which the orientation is still open: 
# fixed inner octa:
  instance ioc surface Yf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0) endinstance 
  instance ioc surface Yf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(-90) endinstance 
  instance ioc surface Rf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(90) endinstance 
  instance ioc surface Rf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180) endinstance 

# Outer octa:
  instance ooc surface Yf lod {if {$slider_numF >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0) endinstance 
  instance ooc surface Yf lod {if {$slider_numF >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(270) endinstance 
  instance ooc surface Rf lod {if {$slider_numF >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180) endinstance 
  instance ooc surface Rf lod {if {$slider_numF >= 5} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(90) endinstance 

# Tob and Bottom octa:
  instance vTP surface Yf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0) endinstance 
  instance vTP surface Rf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180)  endinstance 
  instance vBP surface Yf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180) endinstance 
  instance vBP surface Rf lod {if {$slider_numF >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0)  endinstance 

# "Vertical Flags"
  instance flgi surface Y lod {if {$slider_numF >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0) endinstance  
  instance flgi surface R lod {if {$slider_numF >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180) endinstance 
  instance flgo surface Y lod {if {$slider_numF >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0) endinstance  
  instance flgo surface R lod {if {$slider_numF >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180) endinstance 
# "Horizontal Flags"
  instance flgh surface Y lod {if {$slider_numF >= 2} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(0) endinstance  
  instance flgh surface R lod {if {$slider_numF >= 2} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180) endinstance 




# Stuff affected bt sli3:
  instance btl surface YY lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBTL}) endinstance 
  instance btl surface RR lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBTL+180})  endinstance 
  instance btr surface YY lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBTR}) endinstance 
  instance btr surface RR lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBTR+180})  endinstance 
  instance bbl surface YY lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBBL}) endinstance 
  instance bbl surface RR lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBBL+180})  endinstance 
  instance bbr surface YY lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBBR}) endinstance 
  instance bbr surface RR lod {if {$slider_numP >= 3} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rBBR+180})  endinstance 

  instance ptl surface YY lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPTL}) endinstance 
  instance ptl surface RR lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPTL+180})  endinstance 
  instance ptr surface YY lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPTR}) endinstance 
  instance ptr surface RR lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPTR+180})  endinstance 
  instance pbl surface YY lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPBL}) endinstance 
  instance pbl surface RR lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPBL+180})  endinstance 
  instance pbr surface YY lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPBR}) endinstance 
  instance pbr surface RR lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)({expr $slider_rPBR+180})  endinstance 

######  THE PATH -- and its complement -- Make this C2 !

  instance path0 surface W lod {if {$slider_numP >= 0} {expr $SLF_FULL} else {expr $SLF_OFF} }        endinstance 
  instance path0 surface M lod {if {$slider_numP >= 0} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180)  endinstance 
                                                                         
  instance path1 surface W lod {if {$slider_numP >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} }        endinstance 
  instance path1 surface M lod {if {$slider_numP >= 1} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180)  endinstance 
                                                                         
#  instance path2 surface W lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} }       endinstance 
#  instance path2 surface M lod {if {$slider_numP >= 4} {expr $SLF_FULL} else {expr $SLF_OFF} } rotate(0 0 1)(180)   endinstance 

endgroup


##################### COLORS ####################

surface K color (0.0 0.0 0.0) endsurface
surface D color (0.3 0.3 0.3) endsurface
surface W color (1 1 1) endsurface

surface R color (0.8 0.0 0.4) endsurface
surface Rf color (1.0 0.2 0.2) endsurface ## for "fixed central octas
surface RR color (1 0.0 0.0) endsurface
surface B color (0.0 0.0 1.0) endsurface
surface Y color (0.6 0.9 0.0) endsurface
surface Yf color (0.9 0.9 0.2) endsurface ## for "fixed central octas
surface YY color (1 1 0.0) endsurface
surface C color (0.0 1.0 1.0) endsurface
surface G color (0.0 0.6 0.0) endsurface
surface L color (0.6 1.0 0.6) endsurface
surface M color (1.0 0.0 1.0) endsurface
surface O color (1.0 0.6 0.0) endsurface

#################### VIEWING ###############################

group World
  instance assembly
    scale (0.03 0.03 0.03)
    rotate (1 0 0)(-90)
    #rotate (0 1 0)(45)
    #rotate (1 0 0)(35.25)
  endinstance
endgroup

##################### CAMERA

camera cam
  #projection SLF_PARALLEL
  projection SLF_PERSPECTIVE
  frustum (-0.1 -0.1 -2) (0.1 0.1 -0.01)
endcamera

group gCamera
  instance cam
    id instCam
    translate (0.0 0.0 1.0)
  endinstance
endgroup

##################### LIGHT

light lite
  type SLF_DIRECTIONAL
endlight

group gLight
  instance lite
    id instLite
    lookat
      eye (1.0 0.0 1.0)
      target (0.0 0.0 0.0)
      up (0.0 1.0 0.0)
    endlookat
  endinstance

  instance lite
    id antiLite
    lookat
      eye (-1.0 0.0 -1.0)
      target (0.0 0.0 0.0)
      up (0.0 1.0 0.0)
    endlookat
  endinstance
endgroup

light lite2
  type SLF_AMBIENT
  color (0.5 0.5 0.5)
endlight

group gLight2
  instance lite2
    id instLite2
  endinstance
endgroup

##################### RENDER

window WINDOW
  background (0.3 0.5 0.7)
#  background (1 1 1)
endwindow

viewport VIEWPORT WINDOW
  origin (0.0 0.0)
  size (1.0 1.0)
endviewport

render VIEWPORT gCamera.instCam.cam World
  light gLight.instLite.lite
  light gLight.antiLite.lite
  light gLight2.instLite2.lite2
endrender