本文整理汇总了C#中Microsoft.Xna.Framework.BoundingBox.GetCorners方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBox.GetCorners方法的具体用法?C# BoundingBox.GetCorners怎么用?C# BoundingBox.GetCorners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.GetCorners方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBBox
public static void DrawBBox(BoundingBox box, Matrix Projection, Matrix View, Matrix localWorld,Color color)
{
// Use inside a drawing loop
Vector3[] corners = box.GetCorners();
VertexPositionColor[] primitiveList = new VertexPositionColor[corners.Length];
// Assign the 8 box vertices
for (int i = 0; i < corners.Length; i++)
{
primitiveList[i] = new VertexPositionColor(corners[i], color);
}
/* Set your own effect parameters here */
boxEffect.World = localWorld;
boxEffect.View = View;
boxEffect.Projection = Projection;
boxEffect.TextureEnabled = false;
// Draw the box with a LineList
foreach (EffectPass pass in boxEffect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawUserIndexedPrimitives(
PrimitiveType.LineList, primitiveList, 0, 8,
bBoxIndices, 0, 12);
}
}
示例2: Render
/// <summary>
/// Renders the bounding box for debugging purposes.
/// </summary>
/// <param name="box">The box to render.</param>
/// <param name="graphicsDevice">The graphics device to use when rendering.</param>
/// <param name="view">The current view matrix.</param>
/// <param name="projection">The current projection matrix.</param>
/// <param name="color">The color to use drawing the lines of the box.</param>
public static void Render(
BoundingBox box,
GraphicsDevice graphicsDevice,
Matrix view,
Matrix projection,
Color color)
{
if (box.Min == box.Max)
{
return;
}
if (effect == null)
{
effect = new BasicEffect(graphicsDevice)
{TextureEnabled = false, VertexColorEnabled = true, LightingEnabled = false};
}
Vector3[] corners = box.GetCorners();
for (int i = 0; i < 8; i++)
{
verts[i].Position = corners[i];
verts[i].Color = color;
}
effect.View = view;
effect.Projection = projection;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, verts, 0, 8, indices, 0,
indices.Length/2);
}
}
示例3: Draw
public static void Draw(BoundingBox box, BaseCamera camera, Color color)
{
if (effect == null)
{
effect = new BasicEffect(YnG.GraphicsDevice);
effect.VertexColorEnabled = true;
effect.LightingEnabled = false;
}
Vector3 [] corners = box.GetCorners();
for (int i = 0; i < 8; i++)
{
verts [i].Position = corners [i];
verts [i].Color = color;
}
effect.View = camera.View;
effect.Projection = camera.Projection;
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
YnG.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, verts, 0, 8, indices, 0, indices.Length / 2);
}
}
示例4: Render
public static void Render(BoundingBox box,
GraphicsDevice graphicsDevice,
Matrix view,
Matrix projection,
Color color)
{
if (_effect.IsNull())
_effect = new BasicEffect(graphicsDevice) { VertexColorEnabled = true, LightingEnabled = false };
var corners = box.GetCorners();
for (var i = 0; i < 8; i++)
{
Vertices[i].Position = corners[i];
Vertices[i].Color = color;
}
_effect.View = view;
_effect.Projection = projection;
foreach (var pass in _effect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList,
Vertices,
0,
8,
Indices,
0,
Indices.Length / 2);
}
}
示例5: AddBoundingBox
public static void AddBoundingBox(BoundingBox box, Color color, float life)
{
DebugShape shape = GetShapeForLines(12, life);
box.GetCorners(Corners);
shape.Vertices[0] = new VertexPositionColor(Corners[0], color);
shape.Vertices[1] = new VertexPositionColor(Corners[1], color);
shape.Vertices[2] = new VertexPositionColor(Corners[1], color);
shape.Vertices[3] = new VertexPositionColor(Corners[2], color);
shape.Vertices[4] = new VertexPositionColor(Corners[2], color);
shape.Vertices[5] = new VertexPositionColor(Corners[3], color);
shape.Vertices[6] = new VertexPositionColor(Corners[3], color);
shape.Vertices[7] = new VertexPositionColor(Corners[0], color);
shape.Vertices[8] = new VertexPositionColor(Corners[4], color);
shape.Vertices[9] = new VertexPositionColor(Corners[5], color);
shape.Vertices[10] = new VertexPositionColor(Corners[5], color);
shape.Vertices[11] = new VertexPositionColor(Corners[6], color);
shape.Vertices[12] = new VertexPositionColor(Corners[6], color);
shape.Vertices[13] = new VertexPositionColor(Corners[7], color);
shape.Vertices[14] = new VertexPositionColor(Corners[7], color);
shape.Vertices[15] = new VertexPositionColor(Corners[4], color);
shape.Vertices[16] = new VertexPositionColor(Corners[0], color);
shape.Vertices[17] = new VertexPositionColor(Corners[4], color);
shape.Vertices[18] = new VertexPositionColor(Corners[1], color);
shape.Vertices[19] = new VertexPositionColor(Corners[5], color);
shape.Vertices[20] = new VertexPositionColor(Corners[2], color);
shape.Vertices[21] = new VertexPositionColor(Corners[6], color);
shape.Vertices[22] = new VertexPositionColor(Corners[3], color);
shape.Vertices[23] = new VertexPositionColor(Corners[7], color);
}
示例6: Draw
public static void Draw(BoundingBox box)
{
Vector3[] corners = box.GetCorners();
VertexPositionColor[] primitiveList = new VertexPositionColor[corners.Length];
// Assign the 8 box vertices
for (int i = 0; i < corners.Length; i++)
{
primitiveList[i] = new VertexPositionColor(corners[i], Color.White);
}
/* Set your own effect parameters here */
boxEffect.World = Matrix.Identity;
boxEffect.View = Camera.View;
boxEffect.Projection = Camera.Projection;
boxEffect.TextureEnabled = false;
// Draw the box with a LineList
foreach (EffectPass pass in boxEffect.CurrentTechnique.Passes)
{
pass.Apply();
AssetManager.Singleton.m_GraphicsDevice.DrawUserIndexedPrimitives(
PrimitiveType.LineList, primitiveList, 0, 8,
bBoxIndices, 0, 12);
}
}
示例7: GetVerticesFromBounds
public static VertexPositionColor[] GetVerticesFromBounds(BoundingBox bounds, Color hitboxColor)
{
Vector3[] corners = bounds.GetCorners();
VertexPositionColor[] debugVerts = new VertexPositionColor[24];
debugVerts[0] = new VertexPositionColor(corners[0], hitboxColor);
debugVerts[1] = new VertexPositionColor(corners[1], hitboxColor);
debugVerts[2] = new VertexPositionColor(corners[1], hitboxColor);
debugVerts[3] = new VertexPositionColor(corners[5], hitboxColor);
debugVerts[4] = new VertexPositionColor(corners[5], hitboxColor);
debugVerts[5] = new VertexPositionColor(corners[4], hitboxColor);
debugVerts[6] = new VertexPositionColor(corners[4], hitboxColor);
debugVerts[7] = new VertexPositionColor(corners[0], hitboxColor);
debugVerts[8] = new VertexPositionColor(corners[3], hitboxColor);
debugVerts[9] = new VertexPositionColor(corners[2], hitboxColor);
debugVerts[10] = new VertexPositionColor(corners[2], hitboxColor);
debugVerts[11] = new VertexPositionColor(corners[6], hitboxColor);
debugVerts[12] = new VertexPositionColor(corners[6], hitboxColor);
debugVerts[13] = new VertexPositionColor(corners[7], hitboxColor);
debugVerts[14] = new VertexPositionColor(corners[7], hitboxColor);
debugVerts[15] = new VertexPositionColor(corners[3], hitboxColor);
debugVerts[16] = new VertexPositionColor(corners[3], hitboxColor);
debugVerts[17] = new VertexPositionColor(corners[0], hitboxColor);
debugVerts[18] = new VertexPositionColor(corners[2], hitboxColor);
debugVerts[19] = new VertexPositionColor(corners[1], hitboxColor);
debugVerts[20] = new VertexPositionColor(corners[6], hitboxColor);
debugVerts[21] = new VertexPositionColor(corners[5], hitboxColor);
debugVerts[22] = new VertexPositionColor(corners[7], hitboxColor);
debugVerts[23] = new VertexPositionColor(corners[4], hitboxColor);
return debugVerts;
}
示例8: AddLightVolume
public void AddLightVolume(ref BoundingBox boundingBox)
{
boundingBox.GetCorners(boundingBoxCorners);
for (int i = 0; i < boundingBoxCorners.Length; i++)
{
additionalLightVolumePoints.Add(boundingBoxCorners[i]);
}
}
示例9: IsNaN
public static bool IsNaN(BoundingBox b)
{
Vector3[] corners = new Vector3[8];
b.GetCorners(corners);
bool nan = false;
for (int i = 0; i < CornersInBB && !nan; i++)
{
Vector3 v = corners[i];
nan = nan || float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z);
}
return nan;
}
示例10: CreateVertices
VertexPositionColor[] CreateVertices(BoundingBox boundingBox)
{
var vertices = new VertexPositionColor[8];
Vector3[] corners = boundingBox.GetCorners();
for (int i = 0; i < 8; i++)
{
vertices[i].Position = corners[i];
vertices[i].Color = Color.Red;
}
return vertices;
}
示例11: Transform
public static BoundingBox Transform(BoundingBox box, Matrix world)
{
var vertices = box.GetCorners();
var minVertex = new Vector3(float.MaxValue);
var maxVertex = new Vector3(float.MinValue);
foreach (Vector3 vertex in vertices)
{
var transformedVertex = Vector3.Transform(vertex, world);
minVertex = Vector3.Min(minVertex, transformedVertex);
maxVertex = Vector3.Max(maxVertex, transformedVertex);
}
return new BoundingBox(minVertex, maxVertex);
}
示例12: GetWorldSpaceFrustumCorners
public static IEnumerable<Vector3> GetWorldSpaceFrustumCorners(
float clipSpaceNear, float clipSpaceFar,
Matrix viewProjectionInverse)
{
var clipSpaceBoundingBox = new BoundingBox(
new Vector3(-1, -1, clipSpaceNear),
new Vector3(1, 1, clipSpaceFar));
return clipSpaceBoundingBox.GetCorners().Select(v =>
{
var vt = Vector4.Transform(v, viewProjectionInverse);
vt /= vt.W;
return new Vector3(vt.X, vt.Y, vt.Z);
});
}
示例13: Render
/// <summary>
/// Renders the bounding box for debugging purposes.
/// </summary>
/// <param name="box">The box to render.</param>
/// <param name="graphicsDevice">The graphics device to use when rendering.</param>
/// <param name="view">The current view matrix.</param>
/// <param name="projection">The current projection matrix.</param>
/// <param name="color">The color to use drawing the lines of the box.</param>
public static void Render(
BoundingBox box,
GraphicsDevice graphicsDevice,
Matrix view,
Matrix projection,
Color color)
{
if (effect == null)
{
effect = new BasicEffect(graphicsDevice, null);
effect.VertexColorEnabled = true;
effect.LightingEnabled = false;
vertDecl = new VertexDeclaration(graphicsDevice, VertexPositionColor.VertexElements);
}
Vector3[] corners = box.GetCorners();
for (int i = 0; i < 8; i++)
{
verts[i].Position = corners[i];
verts[i].Color = color;
}
graphicsDevice.VertexDeclaration = vertDecl;
effect.View = view;
effect.Projection = projection;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
graphicsDevice.DrawUserIndexedPrimitives(
PrimitiveType.LineList,
verts,
0,
8,
indices,
0,
indices.Length / 2);
pass.End();
}
effect.End();
}
示例14: Render
/// <summary>
/// Renders the bounding box for debugging purposes.
/// </summary>
/// <param name="box">The box to render.</param>
/// <param name="graphicsDevice">The graphics device to use when rendering.</param>
/// <param name="view">The current view matrix.</param>
/// <param name="projection">The current projection matrix.</param>
/// <param name="color">The color to use for drawing the lines of the box.</param>
public static void Render(
BoundingBox box,
GraphicsDevice graphicsDevice,
Matrix view,
Matrix projection,
Color color)
{
if (effect == null)
{
effect = new BasicEffect(graphicsDevice);
effect.VertexColorEnabled = true;
effect.LightingEnabled = false;
}
Vector3[] corners = box.GetCorners();
for (int i = 0; i < 8; i++)
{
verts[i].Position = corners[i];
verts[i].Color = color;
}
vertex_Buffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), verts.Length, BufferUsage.WriteOnly);
vertex_Buffer.SetData<VertexPositionColor>(verts);
graphicsDevice.SetVertexBuffer(vertex_Buffer);
effect.View = view;
effect.Projection = projection;
effect.CurrentTechnique.Passes[0].Apply();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
graphicsDevice.DrawUserIndexedPrimitives(
PrimitiveType.LineList,
verts,
0,
8,
indices,
0,
indices.Length / 2);
}
}
示例15: LoadContent
protected override void LoadContent()
{
base.LoadContent();
BoundingBox box = new BoundingBox(new Vector3(-1,-1,-1),new Vector3(1,1,1) );
Vector3[] boxCornersVertices = box.GetCorners();
_boxCorners = new VertexPositionColor[boxCornersVertices.Length];
for (int i = 0; i < 8; i++)
_boxCorners[i] = new VertexPositionColor(boxCornersVertices[i], Color.White);
_boxIndices = new int[24];
_boxIndices[0] = 0;
_boxIndices[1] = 1;
_boxIndices[2] = 1;
_boxIndices[3] = 2;
_boxIndices[4] = 2;
_boxIndices[5] = 3;
_boxIndices[6] = 3;
_boxIndices[7] = 0;
_boxIndices[8] = 0;
_boxIndices[9] = 4;
_boxIndices[10] = 3;
_boxIndices[11] = 7;
_boxIndices[12] = 2;
_boxIndices[13] = 6;
_boxIndices[14] = 1;
_boxIndices[15] = 5;
_boxIndices[16] = 4;
_boxIndices[17] = 5;
_boxIndices[18] = 5;
_boxIndices[19] = 6;
_boxIndices[20] = 6;
_boxIndices[21] = 7;
_boxIndices[22] = 7;
_boxIndices[23] = 4;
effect = new BasicEffect(GraphicsDevice);
effect.EnableDefaultLighting();
effect.AmbientLightColor = new Vector3(150, 0, 0);
effect.PreferPerPixelLighting = true;
effect.LightingEnabled = true;
effect.TextureEnabled = false;
}