 'OBJ RENDER
  ==========

  function main()
  ===============
  cls 0,0.20,0.20
  picksetup
  '
  shading
  pushstate
  static MoveableObject mover
  if snew
    mover.id=0
    snew=0
  endif
  if not mover.id then
    mover.set 0x10000,0,0,0,0
    mover.a.x=0
    mover.a.y=0
    mover.a.z=0
    'mover.a.y =180
    'mover.aa.y=180
    mover.mode=0x100
  end if
  sys dt=15
  move dt,-dt,-dt-1
  mover.act
  if pick then
    scale dt
    go sphere
    'touchzone
  else
    Material WhiteShiny
    go sphere
    float f=smax-smin
    if f then scale 2*dt/f
    'scale 1,1,-1.0 'REVERSE Z
    if li=1 then
      'NO MATERIAL SPECIFIED
      Material White
      go glist[1] 'j=1
    end if
    int j,q
    for j=2 to li
      'SELECT MATERIAL
      q=mlist[j]
      material mat[q]
      texture mat[q+14]
      'EXEC GL DRAWING LIST
      go glist[j]
      texture 0
    next
  end if
  
  popstate
  '
  printl
  printl
  '
  if FileDrop
    inputs=FileDrop
    FileDrop=""
    ObjFileName=inputs
    q=BuildObj()
  end if
  '
  '
  'F1 HELP
  '
  if key[0x70]
    flat
    pushstate
    move 20,0
    color .9,.9,.9
    scale  1.5,1.0
    printl "Active Keys:"
    printl
    scale  1/1.5,1.0
    printl "Esc"    tab "Exit"
    printl "Ctrl-P" tab "Take snapshot"
    printl "F1 This help panel"
    printl "F5 Exec function"
    printl "TAB to Select Object / Text line"
    printl "Arrow keys PgUp PgDn to move"
    printl "Ctrl Arrow keys PgUp PgDn to rotate"
    printl "+ - keys to scale up and scale down"
    printl "Ctrl Home to reset rotation"
    printl "Shift for faster movement"
    printl
    scale 1.5,1.0
    printl "Mouse:"
    printl		
    scale 1/1.5,1.0
    printl "Point to Object, then"
    printl "Left button to move"
    printl "Middle button to scale"
    printl "Right button to rotate"
    printl "Wheel to move in Z direction"
    popstate
  end if
  picklabel 0
  lastkey=0
  lastchar=0
  end function

