<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><font face="Times New Roman,sans-serif" size="3" color="#000000">Hi !</font><div><font face="Times New Roman,sans-serif" size="3" color="#000000"><br></font></div><div><font size="3" face="Times New Roman, sans-serif"><font color="#000000">I would like to interact the button of my keyboard in order to modify the position of a 3D object (translation) using up or down or left or right buttons.<br id="FontBreak"></font><br>I created the following piece of code but it does not give results :</font></div><div><font size="3" face="Times New Roman, sans-serif">------------------------------------------------------------------------------------------------------------</font></div><div><div class="_4tdt" style="margin: 10px 8px; position: relative;"><div class="_4tdv"><div class="_5wd4 _1nc7 direction_ltr _2cnu" style="direction: ltr; line-height: 1.28; overflow: hidden; padding: 0px;"><div class="_5wd9" style="min-height: 26px; margin-left: 36px;"><span style="line-height: 20.48px; white-space: pre-wrap; background-color: rgb(254, 254, 254);"><font size="3" face="Times New Roman, sans-serif">class KeyPressInteractorStyle : public vtkInteractorStyleTrackballCamera
{      
  public:
    static KeyPressInteractorStyle* New();
    vtkTypeMacro(KeyPressInteractorStyle, vtkInteractorStyleTrackballCamera);
   

    virtual void OnKeyPress() 
    {
                double handpos[3]={8.0,2.0, 0.0};
      // Get the keypress
      vtkRenderWindowInteractor *rwi = this->Interactor;
         // vtkRenderer *rend=new(vtkRenderer);
      std::string key = rwi->GetKeySym();
 
      // Output the key that was pressed
      std::cout << "Pressed " << key << std::endl;
 
      // Handle an arrow key
     if(key == "Up")
        { 
                
        std::cout << "The up arrow was pressed." << std::endl;
                
//      act->SetPosition(handpos[0]+1, handpos[1], handpos[2]);
            myTrans->Translate(handpos[0]+1, handpos[1], handpos[2]);        
                handpos[0]++;
            act->SetPosition(handpos[0], handpos[1], handpos[2]);

                renderer->Render();
                renderWindow->Render();
        }
          
      // Handle a "normal" key
      if(key == "Down")
        {
        std::cout << "The a key was pressed." << std::endl;
                handpos[0]++;
                        act->SetPosition(handpos[0], handpos[1], handpos[2]);
                renderer->Render();
                        renderWindow->Render();
        }
           // Handle a "normal" key
      if(key == "Right")
        {
        std::cout << "The Right key was pressed." << std::endl;
                handpos[2]++;
                        act->SetPosition(handpos[0], handpos[1], handpos[2]);
                renderer->Render();
                renderWindow->Render();
                        

        }
          if(key== "Left")
          {
                  std::cout << "The left key was pressed." << std::endl;
                  handpos[2]++;
                act->SetPosition(handpos[0], handpos[1], handpos[2]);
                renderer->Render();
                renderWindow->Render();
          }
      // Forward events
      vtkInteractorStyleTrackballCamera::OnKeyPress();
    }
 
};</font></span></div><div class="_3ry4" style="margin-left: 36px;"></div></div></div></div><div class="_4tdt" style="margin: 10px 8px 3px; position: relative;"><div class="_31o4" style="bottom: 0px; left: 0px; position: absolute; line-height: 16px; background-color: rgb(237, 238, 241);"><font size="3" face="Times New Roman, sans-serif"><br></font></div></div>------------------------------------------------------------------------------------------------------------------</div><div><br></div><div>Best regards, </div><div><br></div><div><br><font size="3" face="Garamond">Abdelkhalek Bakkari</font><div><span style="line-height:14px;"><font size="3" face="Garamond">Ph.D candidate in Computer Science</font></span></div><div><span style="line-height:20.82666778564453px;background-color:rgb(255, 255, 255);"><font face="Garamond" size="3">Institute of Applied Computer Science</font></span></div><div><span style="line-height:18.399999618530273px;"><font face="Garamond" size="3">Lodz University of Technology, Poland</font></span></div><div><span style="line-height:18.399999618530273px;"><font face="Garamond" size="3"><br></font></span></div><div><br></div></div>                                        </div></body>
</html>