예제 #1
0
void PerspectiveRangeCamera::setupLens() {
  PointerTo<Lens> lens = new PerspectiveLens();
  lens->set_near_far(rangeLimits[0], rangeLimits[1]);
  lens->set_fov(fov[0]*180.0/M_PI, fov[1]*180.0/M_PI);

  setupCamera(lens);

  set_hpr(angles[0]*180.0/M_PI-90.0, angles[1]*180.0/M_PI, 0.0);
}
예제 #2
0
void RangeCamera::setupCamera(PointerTo<Lens> lens) {
  depthMap.set_format(Texture::F_depth_component);
  depthMap.set_component_type(Texture::T_unsigned_short);
  depthMap.set_minfilter(Texture::FT_nearest);
  depthMap.set_magfilter(Texture::FT_nearest);

  buffer = Morsel::getWindow(0)->make_texture_buffer("DepthMap",
    resolution[0], resolution[1], &depthMap, true);

  cameraNode = new Camera("Camera");
  cameraNode->set_camera_mask(cameraMask);
  cameraNode->set_scene(Morsel::getGSG()->get_scene()->get_scene_root());
  cameraNode->set_lens(lens);

  camera = attach_new_node(cameraNode);
  camera.set_light_off(numeric_limits<int>::max());
  camera.set_material_off(numeric_limits<int>::max());
  camera.set_color_off(numeric_limits<int>::max());
  camera.set_transparency(TransparencyAttrib::M_none);

  PointerTo<DisplayRegion> drd = buffer->make_display_region();
  drd->set_sort(0);
  drd->set_camera(camera);
  
  if (acquireColor) {
    colorMap.set_minfilter(Texture::FT_nearest);
    colorMap.set_magfilter(Texture::FT_nearest);
    buffer->add_render_texture(&colorMap, GraphicsOutput::RTM_copy_ram,
      DrawableRegion::RTP_color);
  }
  else if (!acquireLabel.empty()) {
    labelMap.set_minfilter(Texture::FT_nearest);
    labelMap.set_magfilter(Texture::FT_nearest);
    buffer->add_render_texture(&labelMap, GraphicsOutput::RTM_copy_ram,
      DrawableRegion::RTP_color);

    program.define("LABEL", acquireLabel);
    shader = program.make();

    NodePath shaderAttrib("ShaderLabel");
    shaderAttrib.set_shader(shader);
    shaderAttrib.set_shader_input(acquireLabel, Color::intToRgb(0));
    cameraNode->set_initial_state(shaderAttrib.get_state());
    buffer->set_clear_color(Color::intToRgb(0));
  }
}
예제 #3
0
void ImageSensor::setupCamera() {
  PointerTo<GraphicsOutput> window = Morsel::getWindow(0);
  colorBuffer = window->make_texture_buffer("ColorMap", resolution[0],
    resolution[1], &colorMap, true);

  PointerTo<Lens> lens = new PerspectiveLens();
  lens->set_near_far(rangeLimits[0], rangeLimits[1]);
  lens->set_view_vector(1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
  lens->set_film_size(filmSize[0], filmSize[1]);
  lens->set_focal_length(focalLength);

  cameraNode = new Camera("Camera");
  cameraNode->set_camera_mask(cameraMask);
  cameraNode->set_scene(Morsel::getGSG()->get_scene()->get_scene_root());
  camera = attach_new_node(cameraNode);
  cameraNode->set_lens(lens);

  PointerTo<DisplayRegion> drc = colorBuffer->make_display_region();
  drc->set_sort(0);
  drc->set_camera(camera);
}