コード例 #1
0
ファイル: constraint.cpp プロジェクト: SoumyajitG/VolRoverN
/*! Depending on translationConstraintType(), constrain \p translation to be along an axis or
  limited to a plane defined in the world coordinate system by
  translationConstraintDirection(). */
void WorldConstraint::constrainTranslation(Vec& translation, Frame* const frame)
{
  Vec proj;
  switch (translationConstraintType())
    {
    case AxisPlaneConstraint::FREE:
      break;
    case AxisPlaneConstraint::PLANE:
      if (frame->referenceFrame())
	{
	  proj = frame->referenceFrame()->transformOf(translationConstraintDirection());
	  translation.projectOnPlane(proj);
	}
      else
	translation.projectOnPlane(translationConstraintDirection());
      break;
    case AxisPlaneConstraint::AXIS:
      if (frame->referenceFrame())
	{
	  proj = frame->referenceFrame()->transformOf(translationConstraintDirection());
	  translation.projectOnAxis(proj);
	}
      else
	translation.projectOnAxis(translationConstraintDirection());
      break;
    case AxisPlaneConstraint::FORBIDDEN:
      translation = Vec(0.0, 0.0, 0.0);
      break;
    }
}
コード例 #2
0
ファイル: Plane.cpp プロジェクト: 1062054548/extend-mesh
Vec Plane::projectionOf(const Vec &point)
{
	if(IsOn(point))
		return point;
	else
	{
		Vec proj = point - this->center;

		proj.projectOnPlane(n);

		return proj + this->center;
	}
}
コード例 #3
0
ファイル: constraint.cpp プロジェクト: SoumyajitG/VolRoverN
/*! Depending on translationConstraintType(), constrain \p translation to be along an axis or
  limited to a plane defined in the Frame local coordinate system by
  translationConstraintDirection(). */
void LocalConstraint::constrainTranslation(Vec& translation, Frame* const frame)
{
  Vec proj;
  switch (translationConstraintType())
    {
    case AxisPlaneConstraint::FREE:
      break;
    case AxisPlaneConstraint::PLANE:
      proj = frame->rotation().rotate(translationConstraintDirection());
      translation.projectOnPlane(proj);
      break;
    case AxisPlaneConstraint::AXIS:
      proj = frame->rotation().rotate(translationConstraintDirection());
      translation.projectOnAxis(proj);
      break;
    case AxisPlaneConstraint::FORBIDDEN:
      translation = Vec(0.0, 0.0, 0.0);
      break;
    }
}
コード例 #4
0
void ManipulatedFrameSetConstraint::constrainTranslation(Vec& translation, Frame* const) 
{
   // Filter the translation
   switch (translationConstraintType()) {
      case AXIS:
         translation.projectOnAxis(translationConstraintDirection());
         break;

      case PLANE:
         translation.projectOnPlane(translationConstraintDirection());
         break;

     default:
         break;
   }

   QList<GLObject*>::iterator iter, end;
   for (iter = m_primitives.begin(), end = m_primitives.end(); iter != end; ++iter) {
       (*iter)->m_frame.translate(translation);
   }
}
コード例 #5
0
ファイル: constraint.cpp プロジェクト: SoumyajitG/VolRoverN
/*! Depending on translationConstraintType(), constrain \p translation to be along an axis or
  limited to a plane defined in the camera() coordinate system by
  translationConstraintDirection(). */
void CameraConstraint::constrainTranslation(Vec& translation, Frame* const frame)
{
  Vec proj;
  switch (translationConstraintType())
    {
    case AxisPlaneConstraint::FREE:
      break;
    case AxisPlaneConstraint::PLANE:
      proj = camera()->frame()->inverseTransformOf(translationConstraintDirection());
      if (frame->referenceFrame())
	proj = frame->referenceFrame()->transformOf(proj);
      translation.projectOnPlane(proj);
      break;
    case AxisPlaneConstraint::AXIS:
      proj = camera()->frame()->inverseTransformOf(translationConstraintDirection());
      if (frame->referenceFrame())
	proj = frame->referenceFrame()->transformOf(proj);
      translation.projectOnAxis(proj);
      break;
    case AxisPlaneConstraint::FORBIDDEN:
      translation = Vec(0.0, 0.0, 0.0);
      break;
    }
}