Exemplo n.º 1
0
/* voxel loop function for regrid_minc */
void regrid_loop(void *caller_data, long num_voxels,
                 int input_num_buffers, int input_vector_length,
                 double *input_data[],
                 int output_num_buffers, int output_vector_length,
                 double *output_data[], Loop_Info * loop_info)
{
   long     ivox;
   long     idx[MAX_VAR_DIMS];
   int      v, idim;
   double   voxel_coord[WORLD_NDIMS];
   double   world_coord[WORLD_NDIMS];
   double   value;
   int      valid;

   /* get pointer to loop data */
   Loop_Data *ld = (Loop_Data *) caller_data;

   /* shut the compiler up - yes I _know_ I don't use these */
   (void)input_num_buffers;
   (void)output_num_buffers;
   (void)output_vector_length;
   (void)output_data;

   /* for each (vector) voxel */
   for(ivox = 0; ivox < num_voxels * (long)input_vector_length;
       ivox += (long)input_vector_length){

      /* figure out where we are in space */
      get_info_voxel_index(loop_info, ivox, ld->file_ndims, idx);

      /* convert voxel index to world co-ordinate */
      for(idim = 0; idim < WORLD_NDIMS; idim++){
         voxel_coord[idim] = idx[ld->space_to_dim[idim]];
         }
      transform_coord(&world_coord[0], ld->voxel_to_world, &voxel_coord[0]);

      /* get the data */
      valid = 0;
      for(v = 0; v < input_vector_length; v++){
         value = input_data[0][(ivox * (long)input_vector_length) + (long)v];

         /* check if this point is valid */
         if(value > ld->floor && value < ld->ceil){
            valid = 1;
            }

         ld->data_buf[v] = value;
         }

      /* then regrid the point if valid */
      if(valid){
         regrid_point(ld->totals, ld->weights,
                      world_coord[0], world_coord[1], world_coord[2],
                      input_vector_length, ld->data_buf);
         }
      }

   return;
   }
Exemplo n.º 2
0
bool BM_get(pbit_mat bm, int r, int c)
{
  _ASSERT_VALID_BM(bm);
  _ASSERT_VALID_POS(bm, r, c);
  _LINT cella;
  _BTYPE mask;
  transform_coord(bm, r, c, &cella, &mask);
  return (bm->arr[cella] & mask)!=0;
}
Exemplo n.º 3
0
void BM_set_block(pbit_mat bm, int r, int c, _BTYPE block)
{
  _ASSERT_VALID_BM(bm);
  _ASSERT_VALID_POS(bm, r, c);
  my_assert(c%_LBTYPE==0);
  _LINT cella;
  _BTYPE mask;
  transform_coord(bm, r, c, &cella, &mask);
  bm->arr[cella]= block;
}
Exemplo n.º 4
0
_BTYPE BM_get_block(pbit_mat bm, int r, int c)
{
  _ASSERT_VALID_BM(bm);
  _ASSERT_VALID_POS(bm, r, c);
  my_assert(c%_LBTYPE==0);
  _LINT cella;
  _BTYPE mask;
  transform_coord(bm, r, c, &cella, &mask);
  return bm->arr[cella];
}
Exemplo n.º 5
0
void BM_set(pbit_mat bm, int r, int c, bool value)
{
  _ASSERT_VALID_BM(bm);
  _ASSERT_VALID_POS(bm, r, c);
  _LINT cella;
  _BTYPE mask;
  transform_coord(bm, r, c, &cella, &mask);
  if (value) {
	 bm->arr[cella]= bm->arr[cella] | mask;
  } else {
	 bm->arr[cella]= bm->arr[cella] & (~mask);
  }
}
Exemplo n.º 6
0
/** Transforms local space position in to global space point */
 Vector& IDrawInterface::LocalToGlobalTransform(Vector& OutGlobalPoint, const Vector& InLocalPoint) const
 {
	 transform_coord(OutGlobalPoint, InLocalPoint, m_WorldMatrixTransform);

	 return OutGlobalPoint;
 }
Exemplo n.º 7
0
//----------------------------------------------------------------------------------------------
void IDrawInterface::DoBuildWorldTransform_(const Matrix &WTM)
{
	m_WorldMatrixTransform = GetLTM_() * WTM * GetSTM_();

    m_Bounds.SetUnvalid(); // invalidate

    std::vector<IRenderInterface*> &vecRenderEntities = const_cast<CActor*>(m_pNode->m_pKey)->m_VecRenderEntities;
	for (std::vector<IRenderInterface*>::const_iterator iter = vecRenderEntities.begin(); iter != vecRenderEntities.end(); ++iter)
	{
		(*iter)->SetRWTM(m_WorldMatrixTransform);
	
		Bounds3f BBox = (*iter)->GetRBounds_();

		if (BBox.IsValid())
		{
            const unsigned int BBOX_POINTS = 8;

			Vector BoxPoints[BBOX_POINTS] =
			{ 
				/*Vector(BBox.bound_min.x, BBox.bound_min.y, BBox.bound_min.z),
				Vector(BBox.bound_min.x, BBox.bound_min.y, BBox.bound_max.z),
				Vector(BBox.bound_max.x, BBox.bound_min.y, BBox.bound_max.z),
				Vector(BBox.bound_max.x, BBox.bound_min.y, BBox.bound_min.z),

				Vector(BBox.bound_min.x, BBox.bound_max.y, BBox.bound_min.z),
				Vector(BBox.bound_min.x, BBox.bound_max.y, BBox.bound_max.z),
				Vector(BBox.bound_max.x, BBox.bound_max.y, BBox.bound_max.z),
				Vector(BBox.bound_max.x, BBox.bound_max.y, BBox.bound_min.z),*/

                // TODO make homogeneous with exporter tool
                Vector(BBox.bound_min.z, BBox.bound_min.y, BBox.bound_min.x),
                Vector(BBox.bound_max.z, BBox.bound_min.y, BBox.bound_min.x),
                Vector(BBox.bound_max.z, BBox.bound_min.y, BBox.bound_max.x),
                Vector(BBox.bound_min.z, BBox.bound_min.y, BBox.bound_max.x),

                Vector(BBox.bound_min.z, BBox.bound_max.y, BBox.bound_min.x),
                Vector(BBox.bound_max.z, BBox.bound_max.y, BBox.bound_min.x),
                Vector(BBox.bound_max.z, BBox.bound_max.y, BBox.bound_max.x),
                Vector(BBox.bound_min.z, BBox.bound_max.y, BBox.bound_max.x),
			}; 

			Matrix MT = m_WorldMatrixTransform;
			MT.t = Vector(0.f, 0.f, 0.f);

            Bounds3f tmpBound;
			for (int Index = 0; Index < BBOX_POINTS; ++Index)
			{
				Vector point = transform_coord(BoxPoints[Index], MT);
                
                if (Index == 0)
                {
                    tmpBound.SetBounds(point, point);
                    continue;
                }
                tmpBound.Add(point);
			}

            const Vector bound_min = m_WorldMatrixTransform.t + tmpBound.bound_min;
            const Vector bound_max = m_WorldMatrixTransform.t + tmpBound.bound_max;

            (*iter)->SetWBounds(Bounds3f(bound_min, bound_max));

            if (iter == vecRenderEntities.begin())
            {
                m_Bounds.SetBounds(bound_min, bound_max);
                continue;
            }
            else
            {
                m_Bounds.Add(bound_min);
                m_Bounds.Add(bound_max);
            }
		}
	}

    // invalidate composite bounds
    m_CompositeBounds = m_Bounds;
}
Exemplo n.º 8
0
    ExperimentalApp() : GLFWApp(1280, 800, "Geometric Algorithm Development App")
    {
        glfwSwapInterval(0);

        igm.reset(new gui::ImGuiManager(window));
        gui::make_dark_theme();

        fixedTimer.start();

        lights[0] = {{0, 10, -10}, {0, 0, 1}};
        lights[1] = {{0, 10, 10}, {0, 1, 0}};

        int width, height;
        glfwGetWindowSize(window, &width, &height);
        glViewport(0, 0, width, height);

        grid = RenderableGrid(1, 100, 100);
        cameraController.set_camera(&camera);
        camera.look_at({0, 2.5, -2.5}, {0, 2.0, 0});

        simpleShader = make_watched_shader(shaderMonitor, "../assets/shaders/simple_vert.glsl", "assets/shaders/simple_frag.glsl");
        normalDebugShader = make_watched_shader(shaderMonitor, "../assets/shaders/normal_debug_vert.glsl", "assets/shaders/normal_debug_frag.glsl");

        Renderable debugAxis = Renderable(make_axis(), false, GL_LINES);
        debugAxis.pose = Pose(float4(0, 0, 0, 1), float3(0, 1, 0));
        debugModels.push_back(std::move(debugAxis));

        // Initial supershape settings
        supershape = Renderable(make_supershape_3d(16, 5, 7, 4, 12));
        supershape.pose.position = {0, 2, -2};

        // Initialize PTF stuff
        {
            std::array<float3, 4> controlPoints = {float3(0.0f, 0.0f, 0.0f), float3(0.667f, 0.25f, 0.0f), float3(1.33f, 0.25f, 0.0f), float3(2.0f, 0.0f, 0.0f)};
            ptf = make_parallel_transport_frame_bezier(controlPoints, 32);

            for (int i = 0; i < ptf.size(); ++i)
            {
                Renderable p = Renderable(make_cube());
                ptfBoxes.push_back(std::move(p));
            }
        }

        // Initialize Parabolic pointer stuff
        {
            // Set up the ground plane used as a nav mesh for the parabolic pointer
            worldSurface = make_plane(48, 48, 96, 96);
            for (auto & p : worldSurface.vertices)
            {
                float4x4 model = make_rotation_matrix({1, 0, 0}, -ANVIL_PI / 2);
                p = transform_coord(model, p);
            }
            worldSurfaceRenderable = Renderable(worldSurface);

            parabolicPointer = make_parabolic_pointer(worldSurface, params);
        }

        // Initialize objects for ballistic trajectory tests
        {
            turret.source = Renderable(make_tetrahedron());
            turret.source.pose = Pose({-5, 2, 5});

            turret.target = Renderable(make_cube());
            turret.target.pose = Pose({0, 0, 40});

            turret.bullet = Renderable(make_sphere(1.0f));
        }

        float4x4 tMat = mul(make_translation_matrix({3, 4, 5}), make_rotation_matrix({0, 0, 1}, ANVIL_PI / 2));
        auto p = make_pose_from_transform_matrix(tMat);
        std::cout << tMat << std::endl;
        std::cout << p << std::endl;

        gl_check_error(__FILE__, __LINE__);
    }