示例#1
0
文件: 3dview.c 项目: yhalcyon/Gromacs
gmx_bool zoom_3d(t_3dview *view, real fac)
{
    real dr;
    real bm, dr1, dr2;
    int  i;

    dr2 = 0;
    for (i = 0; (i < DIM); i++)
    {
        dr   = view->eye[i];
        dr2 += dr*dr;
    }
    dr1 = sqrt(dr2);
    if (fac < 1)
    {
        bm = max(norm(view->box[XX]), max(norm(view->box[YY]), norm(view->box[ZZ])));
        if (dr1*fac < 1.1*bm) /* Don't come to close */
        {
            return FALSE;
        }
    }

    for (i = 0; (i < DIM); i++)
    {
        view->eye[i] *= fac;
    }
    calculate_view(view);
    return TRUE;
}
示例#2
0
文件: 3dview.c 项目: Chadi-akel/cere
void translate_view(t_3dview *view,int axis,bool bPositive)
{
#ifdef DEBUG
  printf("Translate called\n");
#endif
  if (bPositive)
    view->origin[axis]+=view->box[axis][axis]/8;
  else
    view->origin[axis]-=view->box[axis][axis]/8;
  calculate_view(view);
}
示例#3
0
void perspective_camera::set_vertical_fov(const float vertical_fov)
{
	m_vertical_fov = vertical_fov;
	
	// calculate horizontal fov
	float fov_radians = m_vertical_fov * degrees_to_radians;
	m_horizontal_fov = 2.0 * std::atanf(get_aspect_ratio() * std::tanf(fov_radians * 0.5));
	m_horizontal_fov *= radians_to_degrees;
	//m_vertical_fov = 2 * std::atan((1 / get_aspect_ratio()) * std::tan((fov_radians / 2.0));

	calculate_view();
}
示例#4
0
文件: 3dview.c 项目: Chadi-akel/cere
void reset_view(t_3dview *view)
{
  int  i;

#ifdef DEBUG
  printf("Reset view called\n");
#endif
  set_scale(view,4.0,4.0);
  clear_rvec(view->eye);
  calc_box_center(view->box,view->origin);
  view->eye[ZZ]=3.0*max(view->box[XX][XX],view->box[YY][YY]);
  zoom_3d(view,1.0);
  view->eye[WW]=view->origin[WW]=0.0;

  /* Initiate the matrix */
  unity_m4(view->Rot);
  calculate_view(view);
}
示例#5
0
文件: 3dview.c 项目: Chadi-akel/cere
void rotate_3d(t_3dview *view,int axis,bool bPositive)
{
  static bool bFirst=TRUE;
  static mat4 RotP[DIM];
  static mat4 RotM[DIM];
  int  i,j;
  mat4 m4;

  if (bFirst) {
    real rot=DEG2RAD*15;

    for(i=0; (i<DIM); i++) {
      rotate(i,        rot ,RotP[i]);
      rotate(i,(real)(-rot),RotM[i]);
#ifdef DEBUG
      print_m4(debug,"RotP",RotP[i]);
      print_m4(debug,"RotM",RotM[i]);
#endif
    }
  }

  /*
    if (bPositive)
    m4_op(RotP[axis],view->eye,v4);
    else
    m4_op(RotM[axis],view->eye,v4);
    for(i=0; (i<DIM); i++)
    view->eye[i]=v4[i];
    */
  if (bPositive)
    mult_matrix(m4,view->Rot,RotP[axis]);
  else
    mult_matrix(m4,view->Rot,RotM[axis]);
  for(i=0; (i<N); i++)
    for(j=0; (j<N); j++)
    view->Rot[i][j]=m4[i][j];

  calculate_view(view);
}
示例#6
0
文件: 3dview.c 项目: yhalcyon/Gromacs
void rotate_3d(t_3dview *view, int axis, gmx_bool bPositive)
{
    int  i, j;
    mat4 m4;

    if (bPositive)
    {
        mult_matrix(m4, view->Rot, view->RotP[axis]);
    }
    else
    {
        mult_matrix(m4, view->Rot, view->RotM[axis]);
    }
    for (i = 0; (i < N); i++)
    {
        for (j = 0; (j < N); j++)
        {
            view->Rot[i][j] = m4[i][j];
        }
    }

    calculate_view(view);
}