本文整理汇总了C#中BoundingBoxD.Distance方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBoxD.Distance方法的具体用法?C# BoundingBoxD.Distance怎么用?C# BoundingBoxD.Distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBoxD
的用法示例。
在下文中一共展示了BoundingBoxD.Distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultGizmoCloseEnough
public static bool DefaultGizmoCloseEnough(ref MatrixD invGridWorldMatrix, BoundingBoxD gizmoBox, float gridSize, float intersectionDistance)
{
//MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Intersection distance = " + intersectionDistance, Color.Red, 1.0f);
var m = invGridWorldMatrix;
MyCharacter character = MySession.LocalCharacter;
if (character == null)
return false;
// Character head for measuring distance to intesection.
Vector3D originHead = character.GetHeadMatrix(true).Translation;
// Camera position adn direction. Used for ray cast to cube block box.
Vector3D originCamera = MySector.MainCamera.Position;
Vector3 direction = MySector.MainCamera.ForwardVector;
Vector3 localHead = Vector3D.Transform(originHead, m);
Vector3 localStart = Vector3D.Transform(originCamera, m);
Vector3 localEnd = Vector3D.Transform(originCamera + direction * intersectionDistance, m);
LineD line = new LineD(localStart, localEnd);
// AABB of added block
float inflate = 0.025f * gridSize;
gizmoBox.Inflate(inflate);
/*{
Vector4 blue = Color.Blue.ToVector4();
Matrix mtx = Matrix.Invert(invGridWorldMatrix);
MySimpleObjectDraw.DrawTransparentBox(ref mtx, ref gizmoBox, ref blue, MySimpleObjectRasterizer.Wireframe, 1, 0.04f);
}*/
double distance = double.MaxValue;
if (gizmoBox.Intersects(line, out distance))
{
// Distance from the player's head to the gizmo box.
double distanceToPlayer = gizmoBox.Distance(localHead);
return distanceToPlayer <= 5.0;
}
return false;
}
示例2: DefaultGizmoCloseEnough
public static bool DefaultGizmoCloseEnough(ref MatrixD invGridWorldMatrix, BoundingBoxD gizmoBox, float gridSize, float intersectionDistance)
{
//MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Intersection distance = " + intersectionDistance, Color.Red, 1.0f);
var m = invGridWorldMatrix;
MyCharacter character = MySession.Static.LocalCharacter;
if (character == null)
return false;
// Character head for measuring distance to intesection.
Vector3D originHead = character.GetHeadMatrix(true).Translation;
// Camera position adn direction. Used for ray cast to cube block box.
Vector3D originCamera = MySector.MainCamera.Position;
Vector3 direction = MySector.MainCamera.ForwardVector;
double cameraHeadDist = (originHead - MySector.MainCamera.Position).Length();
Vector3 localHead = Vector3D.Transform(originHead, m);
Vector3 localStart = Vector3D.Transform(originCamera, m);
Vector3 localEnd = Vector3D.Transform(originCamera + direction * (intersectionDistance + (float)cameraHeadDist), m);
LineD line = new LineD(localStart, localEnd);
// AABB of added block
float inflate = 0.025f * gridSize;
gizmoBox.Inflate(inflate);
//{
// Color blue = Color.Blue;
// MatrixD mtx = MatrixD.Invert(invGridWorldMatrix);
// MySimpleObjectDraw.DrawTransparentBox(ref mtx, ref gizmoBox, ref blue, MySimpleObjectRasterizer.Wireframe, 1, 0.04f);
// MyRenderProxy.DebugDrawLine3D(originCamera, originCamera + direction * (intersectionDistance + (float)cameraHeadDist), Color.Red, Color.Red, false);
//}
double distance = double.MaxValue;
if (gizmoBox.Intersects(ref line, out distance))
{
// Distance from the player's head to the gizmo box.
double distanceToPlayer = gizmoBox.Distance(localHead);
if (MySession.Static.ControlledEntity is MyShipController)
{
if (MyCubeBuilder.Static.CubeBuilderState.CurrentBlockDefinition.CubeSize == MyCubeSize.Large)
return distanceToPlayer <= MyCubeBuilder.CubeBuilderDefinition.BuildingDistLargeSurvivalShip;
else
return distanceToPlayer <= MyCubeBuilder.CubeBuilderDefinition.BuildingDistSmallSurvivalShip;
}
else
{
if (MyCubeBuilder.Static.CubeBuilderState.CurrentBlockDefinition.CubeSize == MyCubeSize.Large)
return distanceToPlayer <= MyCubeBuilder.CubeBuilderDefinition.BuildingDistLargeSurvivalCharacter;
else
return distanceToPlayer <= MyCubeBuilder.CubeBuilderDefinition.BuildingDistSmallSurvivalCharacter;
}
}
return false;
}