;; Fu Jie Huang  , Feb 2003
;; testing the manipulator
;; the cone object has a "Trackball" attached
;; click the trackball to rotate the cone

(libload "inventor/inventor")
(libload "inventor/inventorxt")

(setq mywindow (soxt_init "selection"))
(setq root (new soseparator ()))
(==> root ref)
(setq mycamera  (new soperspectivecamera ()))
(setq mylight   (new sodirectionallight ()))
(==> root addChild :mycamera:p)
(==> root addChild :mylight:p)

(setq coneroot      (new soseparator ()))
(let ((conematerial  (new somaterial ()))
      ;;***** create a trackball manipulator ******
      (conemanip     (new sotrackballmanip ()))
      (coneshape (new socone ())))
  (==> (==> conematerial  getmf_diffusecolor) setvalue 1.0 0.0 0.0)
  (==> (==> conemanip  getsf_translation) setvalue 2 0 0)
  (==> coneroot addChild :conematerial:p)
  (==> coneroot addChild :conemanip:p)
  (==> coneroot addChild :coneshape:p))

(setq sphereroot (new soseparator ()))
(let ((spherematerial  (new somaterial ()))
      (spheretransform (new sotransform ()))
      (sphereshape     (new sosphere ())))
  (==> (==> spherematerial getmf_diffusecolor) setvalue 0.0 0.0 1.0)
  (==> (==> spheretransform getsf_translation) setvalue -2 0 0)
  (==> sphereroot addChild :spherematerial:p)
  (==> sphereroot addChild :spheretransform:p)
  (==> sphereroot addChild :sphereshape:p))

(==> root addChild :coneroot:p)
(==> root addChild :sphereroot:p)

(setq myarea (new soxtrenderarea mywindow "test" 1 1 1 ()))
(==> myarea  setscenegraph :root:p)
(==> mycamera viewall_node :root:p  (==> myarea getviewportregion)  2.0)
(==> myarea show)
(soxt_show mywindow)
