本文整理汇总了C#中Microsoft.Xna.Framework.BoundingBox.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBox.Contains方法的具体用法?C# BoundingBox.Contains怎么用?C# BoundingBox.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BoundingBoxContainsBoundingSphere
public void BoundingBoxContainsBoundingSphere()
{
var testSphere = new BoundingSphere(Vector3.Zero, 1);
var testBox = new BoundingBox(-Vector3.One, Vector3.One);
Assert.AreEqual(testBox.Contains(testSphere), ContainmentType.Contains);
testSphere.Center -= Vector3.One;
Assert.AreEqual(testBox.Contains(testSphere), ContainmentType.Intersects);
testSphere.Center -= Vector3.One;
Assert.AreEqual(testBox.Contains(testSphere), ContainmentType.Disjoint);
}
示例2: PerformKDRegionSearch
protected void PerformKDRegionSearch(KDNode<TriangleGraph> node, ref BoundingBox region, List<TriangleGraph> triangleCollection)
{
if (node != null)
{
if (region.Contains(node.element.Centroid) != ContainmentType.Disjoint
|| region.Contains(node.element.GetVertex0()) != ContainmentType.Disjoint
|| region.Contains(node.element.GetVertex1()) != ContainmentType.Disjoint
|| region.Contains(node.element.GetVertex2()) != ContainmentType.Disjoint)
{
triangleCollection.Add(node.element);
}
PerformKDRegionSearch(node.leftChild, ref region, triangleCollection);
PerformKDRegionSearch(node.rightChild, ref region, triangleCollection);
}
}
示例3: PerformKDRegionSearch
protected void PerformKDRegionSearch(KDNode<TriangleGraph> node, ref BoundingBox region, List<TriangleGraph> triangleCollection, bool isLandmark)
{
if (node != null && (isLandmark || !usedLandmarkTriangles.ContainsKey(node.element.ID)))
{
if (region.Contains(node.element.Centroid) != ContainmentType.Disjoint
|| region.Contains(node.element.GetVertex0()) != ContainmentType.Disjoint
|| region.Contains(node.element.GetVertex1()) != ContainmentType.Disjoint
|| region.Contains(node.element.GetVertex2()) != ContainmentType.Disjoint)
{
triangleCollection.Add(node.element);
}
PerformKDRegionSearch(node.leftChild, ref region, triangleCollection, isLandmark);
PerformKDRegionSearch(node.rightChild, ref region, triangleCollection, isLandmark);
}
}
示例4: Update
public override void Update(GameTime gametime)
{
min = MIN + CurrentPosition;
max = MAX + CurrentPosition;
tankBox = new BoundingBox(min, max);
//float distance = Vector3.Subtract(targetTank.CurrentPosition, this.CurrentPosition).Length();
//distance > Tank.destinationThreshold &&
//if (tankBox.Contains(tankBox) == ContainmentType.Disjoint)
if (tankBox.Contains(targetTank.tankBox) == ContainmentType.Disjoint)
{
//if (Mouse.GetState().LeftButton == ButtonState.Pressed && mousepick.GetCollisionPosition().HasValue == true)
//{
//pickPosition = mousepick.GetCollisionPosition().Value;
Point start = Map.WorldToMap(CurrentPosition);
Point end = Map.WorldToMap(targetTank.CurrentPosition);
//Point end = Map.WorldToMap(pickPosition);
if (end.X < 20 && end.X>=0&&end.Y < 20&&end.Y>=0)
{
pathfinder = new Pathfinder(map);
path = pathfinder.FindPath(start, end);
//pathdebug = path;
}
}
if(path!=null&& moveorder<path.Count)
{
distanceTopickPosition = Vector3.Distance(path[moveorder], CurrentPosition);
if (distanceTopickPosition > desThresholdtoplayer)
{
speed = velocity.Length();
currentAngle = (float)Math.Atan2(velocity.Z, velocity.X);
moveAngle = currentAngle - initialAngle;
rotation = Matrix.CreateRotationY(-moveAngle);
//wheelRotationValue = (float)gametime.TotalGameTime.TotalSeconds * 10;
//canonRotationValue = (float)Math.Sin(gametime.TotalGameTime.TotalSeconds * 0.25f) * 0.333f - 0.333f;
//hatchRotationValue = MathHelper.Clamp((float)Math.Sin(gametime.TotalGameTime.TotalSeconds * 2) * 2, -1, 0);
velocity += steer.seek(path[moveorder], CurrentPosition, velocity) * (float)gametime.ElapsedGameTime.TotalSeconds;
CurrentPosition += velocity * (float)gametime.ElapsedGameTime.TotalSeconds;
translation = Matrix.CreateTranslation(CurrentPosition);
}
else moveorder++;
}
else
{
moveorder = 0;
if (path != null) path.Clear();
}
//base.Update(gametime);
//turretRorationValue = (float)Math.Sin(gametime.TotalGameTime.TotalSeconds);
}
示例5: isColliding
public bool isColliding(BoundingBox box)
{
for (int I = 0; I < this.model.Meshes.Count; ++I)
{
BoundingSphere sphere1 = this.model.Meshes[I].BoundingSphere;
sphere1 = sphere1.Transform(this.World);
if (box.Contains(sphere1) == ContainmentType.Intersects)
return true;
}
return false;
}
示例6: ContaiseGeomertry
private static bool ContaiseGeomertry(BoundingBox box, Geomertry geomertry)
{
if (geomertry is Triangle)
{
Triangle triangle = (Triangle) geomertry;
Vector3 at = Vector3.Transform(triangle.A, triangle.Transform);
Vector3 bt = Vector3.Transform(triangle.B, triangle.Transform);
Vector3 ct = Vector3.Transform(triangle.C, triangle.Transform);
return box.Contains(at) == ContainmentType.Contains ||
box.Contains(bt) == ContainmentType.Contains ||
box.Contains(ct) == ContainmentType.Contains;
}
else if (geomertry is Sphere)
{
Sphere sphere = (Sphere) geomertry;
Vector3 center = Vector3.Transform(sphere.Center, sphere.Transform);
float rx = sphere.Radius*sphere.Transform.M11;
float ry = sphere.Radius*sphere.Transform.M22;
float rz = sphere.Radius*sphere.Transform.M33;
float maxR = Math.Max(rx, Math.Max(ry, rz));
float a = box.Max.X - box.Min.X;
float b = box.Max.Y - box.Min.Y;
float c = box.Max.Z - box.Min.Z;
float halfDiagonal = (float) ((Math.Sqrt(a*a + b*b + c*c))/2.0);
float distance = Vector3.Distance(center, (box.Max + box.Min)/2.0f);
return distance <= halfDiagonal + maxR;
}
throw new Exception("Unsupported geometry");
}
示例7: BoundingBoxVisible
public bool BoundingBoxVisible(BoundingBox bounds)
{
if (bounds.Contains(camPos) != ContainmentType.Disjoint)
return true;
for (int i = 0; i < 6; i++)
{
Vector3 vec;
vec.X = (planes[i].a >= 0) ? bounds.Max.X : bounds.Min.X;
vec.Y = (planes[i].b >= 0) ? bounds.Max.Y : bounds.Min.Y;
vec.Z = (planes[i].c >= 0) ? bounds.Max.Z : bounds.Min.Z;
if (planes[i].PointBehindPlane(vec))
return false;
}
return true;
}
示例8: PreUpdate
public void PreUpdate(BoundingBox area)
{
area.Contains(waterSource);
ForeGround[(int)waterSource.X, (int)waterSource.Y].SetType(NodeFactory.Get(NodeTypes.Water));
}
示例9: Update
public void Update()
{
Vector3 position = this.MailboxAo.Position;
Vector3 center = this.PlayerManager.Center;
Vector3 b1 = FezMath.SideMask(this.CameraManager.Viewpoint);
Vector3 b2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
Vector3 vector3 = new Vector3(FezMath.Dot(position, b1), position.Y, 0.0f);
BoundingBox boundingBox = new BoundingBox(vector3 - new Vector3(0.5f, 0.75f, 0.5f), vector3 + new Vector3(0.5f, 0.75f, 0.5f));
Vector3 point = new Vector3(FezMath.Dot(center, b1), center.Y, 0.0f);
if ((double) FezMath.Dot(center, b2) >= (double) FezMath.Dot(this.MailboxAo.Position, b2) || boundingBox.Contains(point) == ContainmentType.Disjoint || this.InputManager.GrabThrow != FezButtonState.Pressed)
return;
this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.MailboxAo.Id);
ServiceHelper.AddComponent((IGameComponent) new LetterViewer(ServiceHelper.Game, this.MailboxAo.ActorSettings.TreasureMapName));
this.GomezService.OnReadMail();
this.Empty = true;
}
示例10: IsColliding
public bool IsColliding(BoundingBox box)
{
//Check if the given box is colliding with any other box
foreach (BoundingBox b in levelBoxes)
{
if (b.Intersects(box) || b.Contains(box) == ContainmentType.Contains || box.Contains(b) == ContainmentType.Contains)
{
return true;
}
}
return false;
}
示例11: ValveState
public ValveState(ValvesBoltsTimeswitchesHost host, ArtObjectInstance ao)
{
ServiceHelper.InjectServices((object) this);
this.Host = host;
this.ArtObject = ao;
this.IsBolt = this.ArtObject.ArtObject.ActorType == ActorType.BoltHandle;
this.IsTimeswitch = this.ArtObject.ArtObject.ActorType == ActorType.Timeswitch;
BoundingBox boundingBox = new BoundingBox(this.ArtObject.Position - this.ArtObject.ArtObject.Size / 2f, this.ArtObject.Position + this.ArtObject.ArtObject.Size / 2f);
if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
this.AttachedGroup = this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value];
if (this.IsTimeswitch)
{
this.eTimeswitchWindBack = SoundEffectExtensions.EmitAt(this.Host.TimeswitchWindBackSound, ao.Position, true, true);
foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
{
if (artObjectInstance != ao && artObjectInstance.ArtObject.ActorType == ActorType.TimeswitchMovingPart)
{
BoundingBox box = new BoundingBox(artObjectInstance.Position - artObjectInstance.ArtObject.Size / 2f, artObjectInstance.Position + artObjectInstance.ArtObject.Size / 2f);
if (boundingBox.Intersects(box))
{
this.TimeswitchScrewAo = artObjectInstance;
break;
}
}
}
}
int num1;
if (!this.IsBolt && !this.IsTimeswitch && (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0))
{
int num2 = Math.Abs(num1);
int num3 = Math.Sign(num1);
for (int index = 0; index < num2; ++index)
this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float) num3);
}
if (this.IsBolt)
{
foreach (TrileInstance instance in this.AttachedGroup.Triles)
instance.PhysicsState = new InstancePhysicsState(instance);
}
foreach (Volume volume in (IEnumerable<Volume>) this.LevelManager.Volumes.Values)
{
Vector3 vector3 = FezMath.Abs(volume.To - volume.From);
if ((double) vector3.X == 3.0 && (double) vector3.Z == 3.0 && ((double) vector3.Y == 1.0 && boundingBox.Contains(volume.BoundingBox) == ContainmentType.Contains))
{
this.CenterOffset = (volume.From + volume.To) / 2f - this.ArtObject.Position;
break;
}
}
}
示例12: isColliding
public bool isColliding(BoundingBox box, Camera cam, Vector3 playerDimensions)
{
BoundingBox cameraBox = new BoundingBox(
new Vector3(cam.GetPosition.X - (playerDimensions.X / 2), cam.GetPosition.Y - (playerDimensions.Y), cam.GetPosition.Z - (playerDimensions.Z / 2)),
new Vector3(cam.GetPosition.X + (playerDimensions.X / 2), cam.GetPosition.Y, cam.GetPosition.Z + (playerDimensions.Z / 2))
);
return box.Contains(cameraBox) != ContainmentType.Disjoint;
}
示例13: TrackGroupConnectivePath
//.........这里部分代码省略.........
Vector3 vector3_2 = artObjectInstance1.Scale * artObjectInstance1.ArtObject.Size / 2f;
BoundingBox box = new BoundingBox((artObjectInstance1.Position - vector3_2) * vector3_1, (artObjectInstance1.Position + vector3_2) * vector3_1 + b);
if (boundingBox2.Intersects(box))
{
artObjectInstance3 = artObjectInstance1;
break;
}
}
}
if (artObjectInstance3 == null)
{
InvalidOperationException operationException = new InvalidOperationException("Nodeless branch!");
Logger.Log("Connective Groups", LogSeverity.Warning, operationException.Message);
throw operationException;
}
else
{
ArtObjectInstance artObjectInstance1;
for (; artObjectInstance3.ActorSettings.PrecedingNodeAo != null; artObjectInstance3 = artObjectInstance3.ActorSettings.PrecedingNodeAo)
{
Vector3 a = artObjectInstance3.ActorSettings.PrecedingNodeAo.Position - artObjectInstance3.Position;
if ((double) Math.Abs(FezMath.Dot(a, b)) <= (double) Math.Abs(FezMath.Dot(a, FezMath.XZMask - b)))
{
bool flag = false;
Vector3 point = a / 2f + artObjectInstance3.Position;
foreach (ArtObjectInstance artObjectInstance2 in this.connectedAos)
{
if (artObjectInstance2.ArtObject.ActorType == ActorType.None)
{
Vector3 vector3_2 = artObjectInstance2.Scale * artObjectInstance2.ArtObject.Size / 2f;
BoundingBox boundingBox3 = new BoundingBox(artObjectInstance2.Position - vector3_2, artObjectInstance2.Position + vector3_2);
Quaternion rotation = artObjectInstance2.Rotation;
FezMath.RotateOnCenter(ref boundingBox3, ref rotation);
if (boundingBox3.Contains(point) != ContainmentType.Disjoint)
{
flag = true;
break;
}
}
}
if (!flag)
{
artObjectInstance1 = artObjectInstance3;
goto label_72;
}
}
}
artObjectInstance1 = artObjectInstance3;
label_72:
Vector3 ordering = artObjectInstance1.Position - vector3_3;
group.Triles.Sort((IComparer<TrileInstance>) new MovingTrileInstanceComparer(ordering));
foreach (TrileInstance instance in group.Triles)
{
instance.Position += ordering;
this.LevelManager.UpdateInstance(instance);
}
MovementPath movementPath = new MovementPath()
{
EndBehavior = PathEndBehavior.Bounce
};
ArtObjectInstance artObjectInstance4 = artObjectInstance1;
PathSegment pathSegment1 = (PathSegment) null;
while (true)
{
ArtObjectInstance nextNodeAo = artObjectInstance4.ActorSettings.NextNodeAo;
if (nextNodeAo != null)
示例14: PointsInside
/// <summary>
/// How many of the triangles corners are inside the bounding box
/// </summary>
public int PointsInside(BoundingBox box)
{
int count = 0;
for (int i = 0; i < Vertex.Length; i++)
{
if (box.Contains(Vertex[i]) != ContainmentType.Disjoint)
{
count++;
}
}
return count;
}
示例15: getElements
public void getElements(BoundingBox bb, ISelectionExecutor executor)
{
ContainmentType t = bb.Contains(BoundingBox);
if (t == ContainmentType.Contains)
{
foreach (SceneElement e in m_elements)
{
executor.execute(e);
if (m_children != null)
{
foreach (OctreeNode node in m_children)
{
node.getElements(bb, executor);
}
}
}
}
else if (t == ContainmentType.Intersects)
{
foreach (SceneElement se in m_elements)
{
t = bb.Contains(se.BoundingBox);
if (t == ContainmentType.Contains || t == ContainmentType.Intersects)
{
executor.execute(se);
}
}
if (m_children != null)
{
foreach (OctreeNode node in m_children)
{
node.getElements(bb, executor);
}
}
}
return;
}