text: /*
   * =====================================================================================
   *
   *       Filename:  xChainDemo.cpp
   *
   *    Description:  
   *
   *        Version:  1.0
   *        Created:  01/30/2014 17:24:07
   *       Revision:  none
   *       Compiler:  gcc
   *
   *         Author:  YOUR NAME (), 
   *   Organization:  
   *
   * =====================================================================================
   */
  
  
  //Get mouse position as an "unprojected" point in 3D space
  
  #include "vsr_cga3D.h"   
  #include "vsr_GLVimpl.h"
  #include "vsr_chain.h"
  
  using namespace vsr;
  using namespace vsr::cga3D;
  
  
  struct MyApp : App {    
     
    Pnt mouse;
    Lin ray;
  
    float time;
    float amt;
  
    MyApp(Window * win ) : App(win){
      scene.camera.pos( 0,0,10 ); 
      time = 0;
    }
  
    void initGui(){
        gui(amt,"amt",-100,100);
    }
    
      void getMouse(){
        auto tv = interface.vd().ray; 
        Vec z (tv[0], tv[1], tv[2] );
        auto tm = interface.mouse.projectMid;
        ray = Round::point( tm[0], tm[1], tm[2] ) ^ z ^ Inf(1); 
        mouse = Round::point( ray,  Ori(1) );  
    }
  
      virtual void onDraw(){ 
          
        getMouse();
  
        Draw(mouse);
  
        static Chain chain(5);
  
  
        chain.fabrik( mouse, 4, 0 );
  
        chain.fk();
  
        for (int i = 0; i < chain.num(); ++i){
          Draw( chain[i] );
          //Touch( interface, chain.joint(i), chain[i] );
        }
  
        
  
      
    }
     
  
    
  };
  
  
  MyApp * app;
  
  
  int main(){
                               
    GLV glv(0,0);  
  
    Window * win = new Window(500,500,"Versor",&glv);    
    app = new MyApp( win ); 
    app -> initGui();
    
    
    glv << *app;
  
    Application::run();
  
    return 0;
  
  }
  