本文整理匯總了C#中BoundingSphereD.IntersectRaySphere方法的典型用法代碼示例。如果您正苦於以下問題:C# BoundingSphereD.IntersectRaySphere方法的具體用法?C# BoundingSphereD.IntersectRaySphere怎麽用?C# BoundingSphereD.IntersectRaySphere使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BoundingSphereD
的用法示例。
在下文中一共展示了BoundingSphereD.IntersectRaySphere方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckInput
private void CheckInput()
{
MatrixD headMatrix = MyAPIGateway.Session.ControlledObject.GetHeadMatrix(true);
RayD ray = new RayD(headMatrix.Translation, headMatrix.Forward);
BoundingSphereD holoSphere = new BoundingSphereD(m_offset.ToWorld(m_block), m_radiusHolo.Value);
double tmin, tmax;
if (!holoSphere.IntersectRaySphere(ray, out tmin, out tmax) || tmin > CrosshairRange)
return;
int scroll = MyAPIGateway.Input.DeltaMouseScrollWheelValue();
if (scroll != 0)
{
int scrollSteps = (int)Math.Round(scroll * InputScrollMulti);
float rangeMulti = 1f;
while (scrollSteps > 0)
{
rangeMulti *= ScrollRangeMulti;
scrollSteps--;
}
while (scrollSteps < 0)
{
rangeMulti /= ScrollRangeMulti;
scrollSteps++;
}
m_rangeDetection.Value *= rangeMulti;
}
if (MyAPIGateway.Input.IsNewRightMousePressed())
{
m_centreEntityId.Value = 0L;
}
else if (MyAPIGateway.Input.IsNewLeftMousePressed())
{
IMyEntity firstHit = null;
double firstHitDistance = CrosshairRange;
foreach (SeenHolo sh in m_holoEntities.Values)
if (sh.Holo.Render.Visible && sh.Holo.PositionComp.WorldAABB.Intersect(ref ray, out tmin, out tmax) && tmin < firstHitDistance)
{
firstHit = sh.Seen.Entity;
firstHitDistance = tmin;
}
if (firstHit != null)
m_centreEntityId.Value = firstHit.EntityId;
}
}
示例2: GetBoneOnSphere
private Vector3 GetBoneOnSphere(Vector3I center, Vector3I bonePos, MyCubeGrid grid)
{
Vector3D worldCenter = BoneToWorld(center, Vector3.Zero, grid);
Vector3D worldBone = BoneToWorld(bonePos, Vector3.Zero, grid);
BoundingSphereD sphere = new BoundingSphereD(worldCenter, grid.GridSize);
Vector3D direction = worldCenter - worldBone;
direction.Normalize();
RayD ray = new RayD(worldBone, direction);
double tmin, tmax;
if (sphere.IntersectRaySphere(ray, out tmin, out tmax))
{
Vector3D onSphere = worldBone + direction * tmin;
var worldOnSphere = Vector3D.Transform(onSphere, grid.PositionComp.WorldMatrixInvScaled);
worldOnSphere += new Vector3D(grid.GridSize / MyGridSkeleton.BoneDensity);
return (worldOnSphere - (Vector3D)(bonePos / (float)MyGridSkeleton.BoneDensity) * grid.GridSize);
}
else
{
return Vector3.Zero;
}
}