Exemplo n.º 1
0
Pointgroup ptg_get_transformation_matrix(int transform_mat[3][3],
					 SPGCONST int rotations[][3][3],
					 const int num_rotations)
{
  int i, j, pg_num;
  int axes[3];
  PointSymmetry pointsym;
  Pointgroup pointgroup;

  debug_print("ptg_get_transformation_matrix:\n");

  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      transform_mat[i][j] = 0;
    }
  }
  
  pg_num = get_pointgroup_number_by_rotations(rotations, num_rotations);
  
  if (pg_num > 0) {
    pointgroup = ptg_get_pointgroup(pg_num);
    pointsym = get_pointsymmetry(rotations, num_rotations);
    get_axes(axes, pointgroup.laue, &pointsym);
    set_transformation_matrix(transform_mat, axes);
  } else {
    pointgroup = ptg_get_pointgroup(0);
  }    

  return pointgroup;
}
Exemplo n.º 2
0
        void NodeOverlay::update_texture2D (const int plane, const int slice)
        {
          // Suspect this should never be run...
          // Only time this could conceptually be used is if activation of the connectome tool
          // 'overhauled' the main image, and the camera & focus plane were set based on the
          // parcellation image
          assert (0);
          if (!texture2D[plane])
            texture2D[plane].gen (gl::TEXTURE_3D);
          texture2D[plane].bind();
          gl::PixelStorei (gl::UNPACK_ALIGNMENT, 1);
          texture2D[plane].set_interp (interpolation);

          if (tex_positions[plane] == slice && !need_update)
            return;
          tex_positions[plane] = slice;

          int x, y;
          get_axes (plane, x, y);
          const ssize_t xsize = data.size (x), ysize = data.size (y);

          vector<float> texture_data;
          texture_data.resize (4*xsize*ysize, 0.0f);
          if (tex_positions[plane] >= 0 && tex_positions[plane] < data.size (plane)) {
            data.index(plane) = slice;
            for (data.index(y) = 0; data.index(y) < ysize; ++data.index(y)) {
              for (data.index(x) = 0; data.index(x) < xsize; ++data.index(x)) {
                for (data.index(3) = 0; data.index(3) != 4; ++data.index(3)) {
                  texture_data[4*(data.index(x)+data.index(y)*xsize) + data.index(3)] = data.value();
            } } }
          }

          gl::TexImage3D (gl::TEXTURE_3D, 0, internal_format, xsize, ysize, 1, 0, format, type, reinterpret_cast<void*> (&texture_data[0]));
          need_update = false;
        }
Exemplo n.º 3
0
/* pointgroup is modified. */
void ptg_get_transformation_matrix( Pointgroup * pointgroup,
				    const Symmetry * symmetry )
{
  int axes[3];
  int transform_mat[3][3];

  get_axes( axes, pointgroup->laue, symmetry );
  get_transform_matrix( transform_mat, axes );
  mat_copy_matrix_i3( pointgroup->transform_mat, transform_mat );
}
Exemplo n.º 4
0
int main()
{
 int exit = 0;

 init();

 VEC3F wp1 = vec3f(100.0, 100.0, 100.0), wp2 = vec3f(200.0, 100.0, 100.0), wp3 = vec3f(200.0, 200.0, 100.0);
 VEC3F tp1 = vec3f(0.0, 0.0, 0.0), tp2 = vec3f(1.0, 0.0, 0.0), tp3 = vec3f(1.0, 1.0, 0.0);
 VEC3F U, V, W;
 VEC3F wp4, tp4, tp4_real;

 while(!exit)
  {
   float k1 = (float)rand() / RAND_MAX, k2 = (float)rand() / RAND_MAX;
   get_axes(wp1, wp2, wp3, tp1, tp2, tp3, &U, &V, &W);
   
   //wp4 = bary(wp1, wp2, wp3, k1, k2);
   //tp4_real = bary(tp1, tp2, tp3, k1, k2);
   VEC3F norm = USCALE_VEC3F(vec3f_normal(wp1, wp2, wp3), 10.0);
   wp4 = VEC3F_SUM(wp3, norm);

   transform_to_space(U, V, W, wp1, tp1, wp4, &tp4);
   printf("%f %f %f\n", tp4.x, tp4.y, tp4.z);
   
   //float error = fabs(tp4.x - tp4_real.x) + fabs(tp4.y - tp4_real.y) + fabs(tp4.z - tp4_real.z);
   //printf("%f\n", error);

   if(key[KEY_ESC]) { exit = 1; }

   clear_to_color(buffer, 0);
   blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
  }

 destroy_bitmap(buffer);
 return 0;
}
Exemplo n.º 5
0
int main()
{
 int exit = 0, i, vnum, pnum;
 VEC3F pos = vec3f(0.0, 0.0, 0.3), ang = ZERO_VEC3F;
 MAT16F tmat;
 VERTEX *vertex;
 POLY3D *poly;

 init();

 load_map("quake_map2.txt", &vertex, &poly, &vnum, &pnum, 0.2);

 LOCK_VARIABLE(fps);
 LOCK_VARIABLE(frame_count);
 LOCK_FUNCTION(update_fps);
 install_int(update_fps, 1000);

 VEC3F cam_pos = vec3f(0.0, 3.0, 0.0), cam_dir, cam_dir_normal, cam_ang = vec3f(0.0, 0.0, 0.0);

 while(!exit)
  {
   int mx, my;
   get_mouse_mickeys(&mx, &my);
   position_mouse(SCREEN_W / 2, SCREEN_H / 2);

   cam_ang.x += my * 0.001;
   cam_ang.y -= mx * 0.001;
   cam_dir.x = CAM_SPEED * cos(0.5 * M_PI + cam_ang.y);
   cam_dir.y = CAM_SPEED * cos(0.5 * M_PI + cam_ang.x);
   cam_dir.z = CAM_SPEED * sin(0.5 * M_PI + cam_ang.y);
   cam_dir_normal = vec3f(-cam_dir.z, 0.0, cam_dir.x);

   if(key[KEY_ESC]) { exit = 1; }
   if(key[KEY_W]) { cam_pos = VEC3F_SUM(cam_pos, cam_dir); }
   if(key[KEY_S]) { cam_pos = VEC3F_DIFF(cam_pos, cam_dir); }
   if(key[KEY_A]) { cam_pos = VEC3F_SUM(cam_pos, cam_dir_normal); }
   if(key[KEY_D]) { cam_pos = VEC3F_DIFF(cam_pos, cam_dir_normal); }

   set_fov(90.0);
   if(mouse_b > 1)
    set_fov(30.0);

   reset_mat16f(tmat);
   translate_mat16f(tmat, -cam_pos.x, -cam_pos.y, -cam_pos.z);
   rotate_z_mat16f(tmat, 0.0);
   rotate_y_mat16f(tmat, -cam_ang.y);
   rotate_x_mat16f(tmat, -cam_ang.x);

   for(i = 0; i < vnum; i++)
    {
     transform_vec3f(&vertex[i].trans, vertex[i].object, tmat);
     project_vertex(&vertex[i]);
    }

   clear_to_color(buffer, 0);
   clear_to_color(BASE_INT_z_buffer, BASE_INT_z_buffer_precision);

   for(i = 0; i < pnum; i++)
    {
     update_poly3d_normal(&poly[i], vertex);
     V0 = vertex[poly[i].vind[0]].trans;
     global_n = USCALE_VEC3F(NORMALIZED_VEC3F(poly[i].normal), -1.0);
     VEC3F N = global_n;
     DIST = -VEC3F_DOT_PRODUCT(V0, N);

     get_axes(vertex[poly[i].vind[0]].trans,
              vertex[poly[i].vind[1]].trans,
              vertex[poly[i].vind[2]].trans,
              to_vec3f(poly[i].texcoord[0]),
              to_vec3f(poly[i].texcoord[1]),
              to_vec3f(poly[i].texcoord[2]), &A, &B, &C);
     T0 = to_vec3f(poly[i].texcoord[0]);

     if(cull_backface(&poly[i], vertex))
     render_poly3d(&poly[i], vertex);
    }

   textprintf_ex(buffer, font, 10, 10, makecol(255, 255, 255), 0, "FPS: %d", fps);
   blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
   frame_count++;
  }

 for(i = 0; i < pnum; i++)
  destroy_poly3d(&poly[i]);
 free(vertex);

 deinit_engine();
 return 0;
}