Exemple #1
0
/// \param vector The orientation (unit) vector that you want to reflect
/// \return A unit vector that is reflected about the slope of the plane.
Vector3 Plane::reflectOrientation(const Vector3& vector) const
{
  Vector3 out;
  Plane tempPlane(a,b,c,0.0f);

  out = tempPlane.reflectPoint(vector);

  return out;
}
BOOL cCollision::IntersectLinePlane( cLine& Line,cPlane& TargetPlane,D3DXVECTOR3* pCrossPos/*=NULL*/ ,D3DXVECTOR3* pReflectionVec/*=NULL*/)
{	
	D3DXVECTOR3 posCross;
	D3DXPLANE tempPlane(TargetPlane.GetNormal().x,TargetPlane.GetNormal().y,TargetPlane.GetNormal().z,TargetPlane.GetDistance());
	//평면 교점 구하기
	if ( NULL ==  D3DXPlaneIntersectLine(&posCross,&tempPlane,&Line.GetStart(),&D3DXVECTOR3(Line.GetDirection()+Line.GetStart())) )
		return FALSE;
	
	//반사벡터 구하기
	if (pReflectionVec!=NULL)
	{
		D3DXVECTOR3 CrossNormal,vecLineStartToCross;	
		vecLineStartToCross = posCross - Line.GetStart();
		*pReflectionVec =  (2.0f * TargetPlane.GetNormal()) + vecLineStartToCross;
	}


	return TRUE;
}