예제 #1
0
bool User::config(jccl::ConfigElementPtr element)
{
   vprASSERT(element.get() != NULL);
   vprASSERT(element->getID() == "user");

   vprDEBUG_BEGIN(vrjDBG_KERNEL, vprDBG_STATE_LVL)
      << "vjUser::config: Creating a new user\n" << vprDEBUG_FLUSH;

   // Assign user id
   mUserId = mNextUserId++;

   // Setup user name
   mName = element->getName();

   // Initialize the head stuff
   std::string head_alias = element->getProperty<std::string>("head_position");
   mHead.init(head_alias);

   // Initialize interocular distance
   mInterocularDist = element->getProperty<float>("interocular_distance");

   if(mInterocularDist == 0.0f)
   {
      vprDEBUG(vrjDBG_KERNEL,vprDBG_CONFIG_LVL) << clrOutNORM(clrRED, "WARNING:") << "User: "******" has interocular distance is set to 0.0f.  This is probably not what you wanted.\n" << vprDEBUG_FLUSH;
   }

   vprDEBUG(vrjDBG_KERNEL,vprDBG_STATE_LVL) << "id: " << mUserId << "   Name:" << mName.c_str()
                           << "   head_positon:" << head_alias.c_str()
                           << "   interocular_distance:" << mInterocularDist
                           << std::endl << vprDEBUG_FLUSH;

   return true;
}
예제 #2
0
bool SurfaceViewport::config(jccl::ConfigElementPtr element)
{
   vprASSERT(element.get() != NULL);
   vprASSERT(element->getID() == "surface_viewport");

   // Call base class config
   if ( ! Viewport::config(element) )
   {
      return false;
   }

   bool result(true);

   mType = SURFACE;

   // Read in the corners
   mLLCorner.set(element->getProperty<float>("lower_left_corner", 0),
                 element->getProperty<float>("lower_left_corner", 1),
                 element->getProperty<float>("lower_left_corner", 2));
   mLRCorner.set(element->getProperty<float>("lower_right_corner", 0),
                 element->getProperty<float>("lower_right_corner", 1),
                 element->getProperty<float>("lower_right_corner", 2));
   mURCorner.set(element->getProperty<float>("upper_right_corner", 0),
                 element->getProperty<float>("upper_right_corner", 1),
                 element->getProperty<float>("upper_right_corner", 2));
   mULCorner.set(element->getProperty<float>("upper_left_corner", 0),
                 element->getProperty<float>("upper_left_corner", 1),
                 element->getProperty<float>("upper_left_corner", 2));
   
   mCornerUpdateMode = static_cast<CornerUpdateMode>(element->getProperty<int>("auto_corner_update", 0));

   // Calculate the rotation and the pts
//   calculateSurfaceRotation();
//   calculateCornersInBaseFrame();

   // Get info about being tracked
   mTracked = element->getProperty<bool>("tracked");
   if(mTracked)
   {
      mTrackerProxyName = element->getProperty<std::string>("tracker_proxy");
   }

   // Create Projection objects
   // NOTE: The -'s are because we are measuring distance to
   //  the left(bottom) which is opposite the normal axis direction
   //vjMatrix rot_inv;
   //rot_inv.invert(mSurfaceRotation);
   SurfaceProjectionPtr left_proj;
   SurfaceProjectionPtr right_proj;

   if(!mTracked)
   {
      left_proj = SurfaceProjection::create(mLLCorner, mLRCorner, mURCorner,
                                            mULCorner);
      right_proj = SurfaceProjection::create(mLLCorner, mLRCorner, mURCorner,
                                             mULCorner);
   }
   else
   {
      left_proj = TrackedSurfaceProjection::create(mLLCorner, mLRCorner,
                                                   mURCorner, mULCorner,
                                                   mTrackerProxyName);
      right_proj = TrackedSurfaceProjection::create(mLLCorner, mLRCorner,
                                                    mURCorner, mULCorner,
                                                    mTrackerProxyName);
   }

   try
   {
      left_proj->validateCorners();
      right_proj->validateCorners();

      // NOTE: Even if the corner validation above failed, we still proceed with
      // setting up mLeftProj and mRightProj. This is because other code is not
      // written to handle the case of a viewport having no projections. This
      // could definitely be improved.
      mLeftProj  = left_proj;
      mRightProj = right_proj;

      // Configure the projections
      mLeftProj->config(element);
      mLeftProj->setEye(Projection::LEFT);
      mLeftProj->setViewport(shared_from_this());

      mRightProj->config(element);
      mRightProj->setEye(Projection::RIGHT);
      mRightProj->setViewport(shared_from_this());
   }
   catch (InvalidSurfaceException& ex)
   {
      vprDEBUG(vrjDBG_DISP_MGR, vprDBG_CRITICAL_LVL)
         << clrOutBOLD(clrRED, "ERROR")
         << ": The surface defined by the viewport named\n" << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(vrjDBG_DISP_MGR, vprDBG_CRITICAL_LVL)
         << "       '" << element->getName() << "' is invalid!\n"
         << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(vrjDBG_DISP_MGR, vprDBG_CRITICAL_LVL)
         << ex.what() << std::endl << vprDEBUG_FLUSH;

      result = false;
   }

   return result;
}