Hi
 
currently I am having trouble with view matrix
 
following is the code:
 
 else if( key == '4')
 {
  pos_matrix = nvViewer::getOSGViewer()->getViewMatrix();
  osg_User_Pos = pos_matrix.getTrans();
  pos_matrix.get(RotQua);
  
  trans_matrix.makeTranslate(osg_User_Pos);
  rot_matrix.makeRotate(RotQua);
  offset_rot_mat.makeRotate(
   osg::DegreesToRadians(10.0), osg::Vec3(0,-1,0),
   osg::DegreesToRadians(0.0), osg::Vec3(1,0,0),
   osg::DegreesToRadians(0.0), osg::Vec3(0,0,-1)
   );
  
  view_matrix = rot_matrix * trans_matrix;
  //view_matrix = trans_matrix * rot_matrix;
  view_matrix = view_matrix * offset_rot_mat;
  if(pos_matrix == view_matrix)
  {
   printf ("Two matrix matches \n");
  }
  else
  {
   printf ("not matches \n");
  }
  nvViewer::getOSGViewer()->setViewByMatrix(Producer::Matrix(view_matrix.ptr()));
  osg_User_Pos = pos_matrix.getTrans();
  printf("pos x: %f y: %f z: %f \n", osg_User_Pos[0],osg_User_Pos[1],osg_User_Pos[2]);
  
  osg_User_Pos = view_matrix.getTrans();
  printf("view x: %f y: %f z: %f \n", osg_User_Pos[0],osg_User_Pos[1],osg_User_Pos[2]);
  printf("rot %f %f %f %f \n", RotQua[0],RotQua[1],RotQua[2],RotQua[3]);
  
  view_matrix.get(RotQua);
  printf("rot1 %f %f %f %f \n", RotQua[0],RotQua[1],RotQua[2],RotQua[3]);
  return 1; 
 }
 
by using event manager, every time button 4 is pressed an event occurs
 
The event would be rotating the view to left.
 
This works well but only problem is the position of the view seems change as well.
 
as you can see i did printf at the bottom, and xyz value seems change.
 
could you please tell me where i am going wrong with this?
 
thanks in advance.
 
Jae


Express yourself instantly with MSN Messenger! MSN Messenger Download today it's FREE!
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to