示例#1
0
void BasicSimulator::updateProjectionData(const float positionScale,
                                          ProjectionPtr leftProj,
                                          ProjectionPtr rightProj)
{
   updateInternalData(positionScale);

   gmtl::Matrix44f camera_pos = getCameraPos();
   gmtl::Vec3f camera_trans = gmtl::makeTrans<gmtl::Vec3f>(camera_pos);

   //mCameraProj->calcViewMatrix(camera_pos);

   // -- Calculate camera (eye) Positions -- //
   vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL)
      << "[vrj::BasicSimulator::updateProjectionData()] Getting cam position"
      << std::endl << vprDEBUG_FLUSH;
   vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL) << "CamPos:" << camera_trans
                                        << std::endl << vprDEBUG_FLUSH;

   // Compute location of left and right eyes
   float interocular_dist = mSimViewport->getUser()->getInterocularDistance();
   interocular_dist *= positionScale;               // Scale into correct units
   float eye_offset = interocular_dist / 2.0f;      // Distance to move eye

   // NOTE: Eye coord system is -z forward, x-right, y-up
   const gmtl::Point3f left_eye_pos(
      camera_pos * gmtl::Point3f(-eye_offset, 0.0f, 0.0f)
   );
   const gmtl::Point3f right_eye_pos(
      camera_pos * gmtl::Point3f(eye_offset, 0.0f, 0.0f)
   );

   leftProj->calcViewMatrix(left_eye_pos, positionScale);
   rightProj->calcViewMatrix(right_eye_pos, positionScale);
}
示例#2
0
Ray RayTracer::computeRay(uint x, uint y) {
    Vect dir = computeDirection(x, y);
    Ray r(getCameraPos(), dir);
    return r;
}