本文整理汇总了C#中Microsoft.Xna.Framework.BoundingBox类的典型用法代码示例。如果您正苦于以下问题:C# BoundingBox类的具体用法?C# BoundingBox怎么用?C# BoundingBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundingBox类属于Microsoft.Xna.Framework命名空间,在下文中一共展示了BoundingBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PhysxGhostObject
/// <summary>
/// Initializes a new instance of the GhostObject class.
/// DEfault Object in 0,0,0 identity rotation and 1,1,1 scale
/// </summary>
/// <param name="bb">The bb.</param>
public PhysxGhostObject(BoundingBox? bb = null)
{
this.pos = Vector3.Zero;
this.ori = Matrix.Identity;
this.scale = Vector3.One;
this.bb = bb;
}
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:12,代码来源:PhysxGhostObject.cs
示例2: Convert
public bool Convert(string s, out object value)
{
BoundingBox v = new BoundingBox();
value = v;
object corner;
string[] splits = s.Split(VALUE_DELIMITERS, StringSplitOptions.RemoveEmptyEntries);
if(splits.Length < 2) return false;
int vi = 0;
foreach(var sv in splits) {
if(vi == 2) break;
if(string.IsNullOrWhiteSpace(sv))
continue;
if(vec3Conv.Convert(sv, out corner)) {
switch(vi) {
case 0: v.Min = (Vector3)corner; break;
case 1: v.Max = (Vector3)corner; break;
}
vi++;
}
}
if(vi < 2) return false;
value = v;
return true;
}
开发者ID:RegrowthStudios,项目名称:VoxelRTS,代码行数:25,代码来源:ZXPCExt.cs
示例3: DrawBoundingBox
public void DrawBoundingBox(BoundingBox box)
{
IGraphicsDeviceService graphicsService =
(IGraphicsDeviceService)base.Game.Services.GetService(
typeof(IGraphicsDeviceService));
GraphicsDevice device = graphicsService.GraphicsDevice;
vertices[0].Position = new Vector3(box.Min.X, box.Min.Y, box.Min.Z);
vertices[1].Position = new Vector3(box.Max.X, box.Min.Y, box.Min.Z);
vertices[2].Position = new Vector3(box.Max.X, box.Min.Y, box.Max.Z);
vertices[3].Position = new Vector3(box.Min.X, box.Min.Y, box.Max.Z);
vertices[4].Position = new Vector3(box.Min.X, box.Max.Y, box.Min.Z);
vertices[5].Position = new Vector3(box.Max.X, box.Max.Y, box.Min.Z);
vertices[6].Position = new Vector3(box.Max.X, box.Max.Y, box.Max.Z);
vertices[7].Position = new Vector3(box.Min.X, box.Max.Y, box.Max.Z);
Predraw(0);
device.DrawUserIndexedPrimitives<VertexPositionColor>(
PrimitiveType.LineList, vertices,
0,
8,
indices,
0,
12);
Postdraw();
}
开发者ID:jhauberg-archived,项目名称:LD10,代码行数:28,代码来源:VectorRenderer.cs
示例4: RedHead
public RedHead(Game game, Vector3 pos, Level l)
: base(game, pos, l)
{
//Parameters for this specific enemy
life = 5;
textures = new Texture2D[life];
Damage = 5;
this.level = l;
this.position = pos;
RotationSpeed = 0.1f;
ForwardSpeed = 6f;
boxMin = new Vector3(-0.235f, 0, -0.235f);
boxMax = new Vector3(0.235f, 0.8f, 0.235f);
boundingBox = new BoundingBox(position + boxMin, position + boxMax);
//Different textures for each life count
textures[4] = ContentPreImporter.GetTexture("RedHead");
textures[3] = ContentPreImporter.GetTexture("RedHead4");
textures[2] = ContentPreImporter.GetTexture("RedHead3");
textures[1] = ContentPreImporter.GetTexture("RedHead2");
textures[0] = ContentPreImporter.GetTexture("RedHead1");
hurtSound = ContentPreImporter.GetSound("enemyHurt");
billboard = new Billboard(game, textures[life - 1], Vector2.One / 2);
billboard.Move(position + new Vector3(0, 0.25f, 0));
billboard.ForceUpdate();
target = pos;
//Set new values for the fog if required
billboard.OverrideFog(GlobalSettings.FogEnabled, GlobalSettings.FogColor, GlobalSettings.FogStart, GlobalSettings.FogEnd * 2.1f);
}
开发者ID:RichyHBM,项目名称:WrenchGame,代码行数:29,代码来源:RedHead.cs
示例5: GetBoundingBox
/// <summary>
/// Model 全体を包む BoundingBox を取得します。
/// </summary>
/// <param name="model">Model。</param>
/// <param name="result">Model 全体を包む BoundingBox。</param>
public static void GetBoundingBox(this Model model, out BoundingBox result)
{
var boneTransforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(boneTransforms);
var points = new List<Vector3>();
foreach (var mesh in model.Meshes)
{
foreach (var part in mesh.MeshParts)
{
var vertexBuffer = part.VertexBuffer;
var data = new float[vertexBuffer.VertexCount * vertexBuffer.VertexDeclaration.VertexStride / sizeof(float)];
vertexBuffer.GetData<float>(data);
var boneTransform = boneTransforms[mesh.ParentBone.Index];
var increment = vertexBuffer.VertexDeclaration.VertexStride / sizeof(float);
for (int i = 0; i < data.Length; i += increment)
{
Vector3 point;
point.X = data[i];
point.Y = data[i + 1];
point.Z = data[i + 2];
point = Vector3.Transform(point, boneTransform);
points.Add(point);
}
}
}
result = BoundingBox.CreateFromPoints(points);
}
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:35,代码来源:ModelExtension.cs
示例6: Contains
public ContainmentType Contains(ref BoundingBox boundingBox)
{
ContainmentType result;
_boundingSphere.Contains(ref boundingBox, out result);
return result;
}
开发者ID:jwvdiermen,项目名称:LD28,代码行数:7,代码来源:CircleBrush.cs
示例7: QuadNode
public QuadNode(NodeType nodeType, int nodeSize, int nodeDepth, QuadNode parent, QuadTree parentTree, int positionIndex)
{
NodeType = nodeType;
_nodeSize = nodeSize;
_nodeDepth = nodeDepth;
_positionIndex = positionIndex;
_parent = parent;
_parentTree = parentTree;
//Add the 9 vertices
AddVertices();
Bounds = new BoundingBox(_parentTree.Vertices[VertexTopLeft.Index].Position,
_parentTree.Vertices[VertexBottomRight.Index].Position);
if (nodeSize >= 4)
AddChildren();
//Make call to UpdateNeighbors from the parent node.
//This will update all neighbors recursively for the
//children as well. This ensures all nodes are created
//prior to updating neighbors.
if (_nodeDepth == 1)
{
AddNeighbors();
VertexTopLeft.Activated = true;
VertexTopRight.Activated = true;
VertexCenter.Activated = true;
VertexBottomLeft.Activated = true;
VertexBottomRight.Activated = true;
}
}
开发者ID:MenosGrandes,项目名称:mrowisko-pbl,代码行数:35,代码来源:QuadNode.cs
示例8: SplitBaseArena
/// <summary>
/// Constructs the arena. Also constructs several platforms and physics elements
/// which need to get added to the EntityManager and PhysicsSimulator.
/// </summary>
/// <param name="entityManager"></param>
/// <param name="physicsSimulator"></param>
public SplitBaseArena(EntityManager entityManager, PhysicsSimulator physicsSimulator)
{
// Create the platforms.
float focus = 15.0f;
Platform leftGround = new Platform(new Vector3(-focus, 0, 0), 22.0f, 2.0f, 5.0f);
Platform rightGround = new Platform(new Vector3(focus, 0, 0), 22.0f, 2.0f, 5.0f);
Platforms.Add(leftGround);
entityManager.AddEntity(leftGround);
physicsSimulator.AddPhysicsEntity(leftGround.GetBox());
Platforms.Add(rightGround);
entityManager.AddEntity(rightGround);
physicsSimulator.AddPhysicsEntity(rightGround.GetBox());
// Create the Spawn Positions
spawnPositions = new List<Vector3>();
spawnPositions.Add(new Vector3(-15, 10, 0));
spawnPositions.Add(new Vector3(-5, 15, 0));
spawnPositions.Add(new Vector3(5, 15, 0));
spawnPositions.Add(new Vector3(15, 10, 0));
// Create the Bounding box.
boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20));
}
开发者ID:regenvanwalbeek,项目名称:BattleFury,代码行数:31,代码来源:SplitBaseArena.cs
示例9: DrawBoundingBox
public static void DrawBoundingBox(BoundingBox bBox, GraphicsDevice device, BasicEffect basicEffect, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
{
Vector3 v1 = bBox.Min;
Vector3 v2 = bBox.Max;
VertexPositionColor[] cubeLineVertices = new VertexPositionColor[8];
cubeLineVertices[0] = new VertexPositionColor(v1, Color.White);
cubeLineVertices[1] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v1.Z), Color.Red);
cubeLineVertices[2] = new VertexPositionColor(new Vector3(v2.X, v1.Y, v2.Z), Color.Green);
cubeLineVertices[3] = new VertexPositionColor(new Vector3(v1.X, v1.Y, v2.Z), Color.Blue);
cubeLineVertices[4] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v1.Z), Color.White);
cubeLineVertices[5] = new VertexPositionColor(new Vector3(v2.X, v2.Y, v1.Z), Color.Red);
cubeLineVertices[6] = new VertexPositionColor(v2, Color.Green);
cubeLineVertices[7] = new VertexPositionColor(new Vector3(v1.X, v2.Y, v2.Z), Color.Blue);
short[] cubeLineIndices = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };
basicEffect.World = worldMatrix;
basicEffect.View = viewMatrix;
basicEffect.Projection = projectionMatrix;
basicEffect.VertexColorEnabled = true;
device.RasterizerState = _solidRasterizer;
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineList, cubeLineVertices, 0, 8, cubeLineIndices, 0, 12);
}
}
开发者ID:vvolkgang,项目名称:WarZ,代码行数:30,代码来源:XNAUtils.cs
示例10: Collision
public BoundingBox Collision()
{
Vector3 Middle= new Vector3(Position.X+100,Position.Y+100,Position.Z-75);
Vector3 abc = new Vector3(80);
BoundingBox bb= new BoundingBox(Middle - new Vector3(40), Middle + new Vector3(40));
return bb;
}
开发者ID:TorgeirH90,项目名称:Programming,代码行数:7,代码来源:EnemyCube.cs
示例11: BSP
private BSP(Node root, BoundingBox? bounds, object[] description, bool createDescription = true)
{
_root = root;
Bounds = bounds;
_description = description;
_createDescription = createDescription;
}
开发者ID:martindevans,项目名称:csg.js,代码行数:7,代码来源:BSP.cs
示例12: Transform
public static BoundingBox Transform(BoundingBox bounds, Matrix matrix)
{
BoundingBox t;
t.Min = matrix.Translation;
t.Max = matrix.Translation;
t.Min.X += (matrix.M11 < 0) ? bounds.Max.X * matrix.M11 : bounds.Min.X * matrix.M11;
t.Min.X += (matrix.M21 < 0) ? bounds.Max.Y * matrix.M21 : bounds.Min.Y * matrix.M21;
t.Min.X += (matrix.M31 < 0) ? bounds.Max.Z * matrix.M31 : bounds.Min.Z * matrix.M31;
t.Max.X += (matrix.M11 > 0) ? bounds.Max.X * matrix.M11 : bounds.Min.X * matrix.M11;
t.Max.X += (matrix.M21 > 0) ? bounds.Max.Y * matrix.M21 : bounds.Min.Y * matrix.M21;
t.Max.X += (matrix.M31 > 0) ? bounds.Max.Z * matrix.M31 : bounds.Min.Z * matrix.M31;
t.Min.Y += (matrix.M12 < 0) ? bounds.Max.X * matrix.M12 : bounds.Min.X * matrix.M12;
t.Min.Y += (matrix.M22 < 0) ? bounds.Max.Y * matrix.M22 : bounds.Min.Y * matrix.M22;
t.Min.Y += (matrix.M32 < 0) ? bounds.Max.Z * matrix.M32 : bounds.Min.Z * matrix.M32;
t.Max.Y += (matrix.M12 > 0) ? bounds.Max.X * matrix.M12 : bounds.Min.X * matrix.M12;
t.Max.Y += (matrix.M22 > 0) ? bounds.Max.Y * matrix.M22 : bounds.Min.Y * matrix.M22;
t.Max.Y += (matrix.M32 > 0) ? bounds.Max.Z * matrix.M32 : bounds.Min.Z * matrix.M32;
t.Min.Z += (matrix.M13 < 0) ? bounds.Max.X * matrix.M13 : bounds.Min.X * matrix.M13;
t.Min.Z += (matrix.M23 < 0) ? bounds.Max.Y * matrix.M23 : bounds.Min.Y * matrix.M23;
t.Min.Z += (matrix.M33 < 0) ? bounds.Max.Z * matrix.M33 : bounds.Min.Z * matrix.M33;
t.Max.Z += (matrix.M13 > 0) ? bounds.Max.X * matrix.M13 : bounds.Min.X * matrix.M13;
t.Max.Z += (matrix.M23 > 0) ? bounds.Max.Y * matrix.M23 : bounds.Min.Y * matrix.M23;
t.Max.Z += (matrix.M33 > 0) ? bounds.Max.Z * matrix.M33 : bounds.Min.Z * matrix.M33;
return t;
}
开发者ID:djmacgames,项目名称:MonoCollisionFramework,代码行数:30,代码来源:BoundingBoxHelper.cs
示例13: Update
public override void Update(GameTime gametime)
{
min = MIN + currentPosition;
max = MAX + currentPosition;
tankBox = new BoundingBox(min, max);
turretRorationValue = (float)Math.Sin(gametime.TotalGameTime.TotalSeconds);
}
开发者ID:HeatherXi,项目名称:game-programming,代码行数:7,代码来源:pursuit.cs
示例14: AbstractBonus
/// <summary>
/// konstruktor
/// </summary>
/// <param name="game">instance hry</param>
/// <param name="x">poloha v hernim poli na ose x</param>
/// <param name="y">poloha v hernim poli na ose y</param>
public AbstractBonus(Game game, AbstractWall wall)
: base(game)
{
base.modelPosition = new Vector3(wall.ModelPosition.X, 0, wall.ModelPosition.Z);
boundingBox = new BoundingBox(new Vector3(modelPosition.X - 10, modelPosition.Y, modelPosition.Z - 10),
new Vector3(modelPosition.X + 10, modelPosition.Y + 20, modelPosition.Z + 10));
}
开发者ID:CTU-FEE-Y39PHA-43-2010,项目名称:BombermanAdventure,代码行数:13,代码来源:AbstractBonus.cs
示例15: GhostObject
/// <summary>
/// Initializes a new instance of the <see cref="GhostObject"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="orientation">The orientation.</param>
/// <param name="scale">The scale.</param>
public GhostObject(Vector3 position, Matrix orientation, Vector3 scale, BoundingBox? bb = null) : base(MaterialDescription.DefaultBepuMaterial(), 0)
{
this.pos = position;
this.ori = orientation;
this.scale = scale;
this.bb = bb;
}
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:13,代码来源:GhostObject.cs
示例16: 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);
}
}
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:32,代码来源:BoundingBoxRenderer.cs
示例17: GameObject
public GameObject()
{
Model = null;
Position = Vector3.Zero;
BoundingSphere = new BoundingSphere();
boundingBox = new BoundingBox();
}
开发者ID:khoatle,项目名称:game,代码行数:7,代码来源:GameObject.cs
示例18: colisao
public void colisao()
{
Vector3 A = new Vector3(screen.player.positionPlayer.X+5, screen.player.positionPlayer.Y+10, 0);
Vector3 B = new Vector3(screen.player.positionPlayer.X + 44, screen.player.positionPlayer.Y + screen.player.imgPlayer.Height - 13, 0);
Vector3 C = new Vector3(posicao.X, posicao.Y, 0);
Vector3 D = new Vector3(posicao.X + largura, posicao.Y + image.Height, 0);
BoundingBox boxPlayer = new BoundingBox(A, B);
BoundingBox boxEnemy = new BoundingBox(C, D);
if (boxEnemy.Intersects(boxPlayer))
{
screen.removeComponent(this);
screen.addComponent(new Explosao(mygame, C + new Vector3(0, 10, 0), 1, screen));
screen.player.hp--;
if (screen.player.hp < 0) {
screen.addComponent(new Explosao(mygame, new Vector3(screen.player.positionPlayer.X, screen.player.positionPlayer.Y, 0), 2, screen));
screen.player.vida--;
screen.player.hp = 5;
}
if(screen.player.vida < 0){
screen.removeComponent(screen.player);
mygame.setScreen(new ScreenSplash(mygame));
}
}
}
开发者ID:rodrigocamina,项目名称:spaceshooterunivali2011,代码行数:28,代码来源:TiroMissel.cs
示例19: Chunk
/// <summary>
/// Creates a new chunk.
/// </summary>
/// <param name="world">The world this chunk belongs to.</param>
/// <param name="index">The index of the chunk.</param>
/// <param name="generateTerrain">True to generate some initial terrain, false to leave each block empty.</param>
private Chunk( World world, Vector3 index, bool generateTerrain )
{
_world = world;
_data = new ChunkData( index );
_terrain = new VoxelBuffer();
// create bounds
var sizeOffs = ChunkData.SizeXZ * 0.5f - 0.5f;
Vector3 boundsMin = new Vector3(
index.X - sizeOffs,
-0.5f,
index.Z - sizeOffs
);
Vector3 boundsMax = new Vector3(
index.X + sizeOffs,
0.5f + ChunkData.SizeY,
index.Z + sizeOffs
);
_bounds = new BoundingBox( boundsMin, boundsMax );
_octree = new ChunkOctree( _bounds );
// check if we need to populate
if ( generateTerrain )
{
PopulateTerrain();
}
}
开发者ID:TheCodeInside,项目名称:kyoob,代码行数:33,代码来源:Chunk.cs
示例20: 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);
}
}
开发者ID:MenosGrandes,项目名称:mrowisko-pbl,代码行数:29,代码来源:BBoxRender.cs
注:本文中的Microsoft.Xna.Framework.BoundingBox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论