本文整理汇总了C#中AABB类的典型用法代码示例。如果您正苦于以下问题:C# AABB类的具体用法?C# AABB怎么用?C# AABB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AABB类属于命名空间,在下文中一共展示了AABB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: computeAABB
public override void computeAABB(AABB aabb, Transform xf, int childIndex)
{
Debug.Assert(childIndex < m_count);
Vec2 lower = aabb.lowerBound;
Vec2 upper = aabb.upperBound;
int i1 = childIndex;
int i2 = childIndex + 1;
if (i2 == m_count)
{
i2 = 0;
}
Vec2 vi1 = m_vertices[i1];
Vec2 vi2 = m_vertices[i2];
Rot xfq = xf.q;
Vec2 xfp = xf.p;
float v1x = (xfq.c*vi1.x - xfq.s*vi1.y) + xfp.x;
float v1y = (xfq.s*vi1.x + xfq.c*vi1.y) + xfp.y;
float v2x = (xfq.c*vi2.x - xfq.s*vi2.y) + xfp.x;
float v2y = (xfq.s*vi2.x + xfq.c*vi2.y) + xfp.y;
lower.x = v1x < v2x ? v1x : v2x;
lower.y = v1y < v2y ? v1y : v2y;
upper.x = v1x > v2x ? v1x : v2x;
upper.y = v1y > v2y ? v1y : v2y;
}
示例2: GetBodyAtMouse
public virtual Body GetBodyAtMouse(bool includeStatic)
{
// Make a small box
mousePVec.X = MouseXWorldPhys;
mousePVec.Y = MouseYWorldPhys;
FVector2 lowerBound = new FVector2(MouseXWorldPhys - 0.001f, MouseYWorldPhys - 0.001f);
FVector2 upperBound = new FVector2(MouseXWorldPhys + 0.001f, MouseYWorldPhys + 0.001f);
AABB aabb = new AABB(lowerBound, upperBound);
Body body = null;
// Query the world for overlapping shapes
System.Func<Fixture, bool> GetBodyCallback = delegate (Fixture fixture0)
{
Shape shape = fixture0.Shape;
if(fixture0.Body.BodyType != BodyType.Static || includeStatic)
{
FarseerPhysics.Common.Transform transform0;
fixture0.Body.GetTransform(out transform0);
bool inside = shape.TestPoint(ref transform0, ref mousePVec);
if(inside)
{
body = fixture0.Body;
return false;
}
}
return true;
};
FSWorldComponent.PhysicsWorld.QueryAABB(GetBodyCallback, ref aabb);
return body;
}
示例3: CalculateBounds
public void CalculateBounds()
{
Bounds = new AABB
{
Max = Zone.ZoneMax.ToVector3(),
Min = Zone.ZoneMin.ToVector3()
};
Max = Bounds.Max;
Min = Bounds.Min;
// Create a persistable way to uniquely identify a scene at a location
SceneHash = string.Format("{0}_[{1},{2}][{3},{4}]", _scene.Name, Min.X, Min.Y, Max.X, Max.Y);
EdgeLength = Bounds.Max.X - Bounds.Min.X / 2;
HalfEdgeLength = EdgeLength / 2;
SouthWest = new Vector3(Bounds.Max.X, Bounds.Min.Y, 0);
SouthEast = new Vector3(Bounds.Max.X, Bounds.Max.Y, 0);
NorthWest = new Vector3(Bounds.Min.X, Bounds.Min.Y, 0);
NorthEast = new Vector3(Bounds.Min.X, Bounds.Max.Y, 0);
CenterX = Bounds.Min.X + (Bounds.Max.X - Bounds.Min.X) / 2;
CenterY = Bounds.Min.Y + (Bounds.Max.Y - Bounds.Min.Y) / 2;
Center = new Vector3(CenterX, CenterY, 0);
}
示例4: MouseDown
/// <summary>
/// Handles what happens when a user clicks the mouse
/// </summary>
/// <param name="p">
/// The position of the mouse click in relative coordinates.
/// </param>
public void MouseDown(Vector point)
{
Vector p = RelativeToWorld(point);
if (mouseJoint != null)
throw new Exception("ASSERT: mouseJoint should be null");
// Make a small box.
Vector d = new Vector(.001f, .001f);
AABB aabb = new AABB(p - d, p + d);
// Query the world for overlapping shapes.
IList<Shape> shapes = world.Query(aabb);
Body body = null;
foreach (Shape shape in shapes)
{
if (shape.Body.Static == false &&
shape.TestPoint(shape.Body.GetXForm(), p))
{
body = shape.Body;
break;
}
}
if (body != null)
{
MouseJointDef md = new MouseJointDef();
md.Body1 = world.GetGroundBody();
md.Body2 = body;
md.Target = p;
md.MaxForce = 1000 * body.Mass;
mouseJoint = new MouseJoint(world.CreateJoint(md));
body.WakeUp();
}
}
示例5: DensityRegion
// DensityRegion Public Methods
public DensityRegion(Spectrum sa, Spectrum ss, float gg, Spectrum emit, AABB b) {
sig_a = sa;
sig_s = ss;
le = emit;
g = gg;
worldBound = b;
}
示例6: WorldBound
public AABB WorldBound(Point[] vertices)
{
var pts = vertices;
var res = new AABB(pts[this.v0.VertexIndex], pts[this.v1.VertexIndex]);
res.Union(pts[v2.VertexIndex]);
return res;
}
示例7: NavCell
public NavCell(float minX, float minY, float minZ, float maxX, float maxY, float maxZ, int flags)
{
BoundingBox = new AABB(
new Vector3f(minX, minY, minZ),
new Vector3f(maxX, maxY, maxZ));
Flags = (NavCellFlags)flags;
}
示例8: WorldBound
public AABB WorldBound(Point[] vertices)
{
var pts = vertices;
var res = new AABB(pts[this.v0], pts[this.v1]);
res.Union(pts[v2]);
return res;
}
示例9: ExploreCell
public ExploreCell(AABB aabb, List<Cell> cells, Vec3 position, int id = -1)
: base(aabb.Min.X, aabb.Min.Y, 0, aabb.Max.X, aabb.Max.Y, 0, MovementFlag.None, id)
{
InitExploreCell();
Position = position;
Cells = cells;
}
示例10: QuadTreeBroadPhase
/// <summary>
/// Creates a new quad tree broadphase with the specified span.
/// </summary>
/// <param name="span">the maximum span of the tree (world size)</param>
public QuadTreeBroadPhase(AABB span)
{
_quadTree = new QuadTree<FixtureProxy>(span, 5, 10);
_idRegister = new Dictionary<int, Element<FixtureProxy>>();
_moveBuffer = new List<Element<FixtureProxy>>();
_pairBuffer = new List<Pair>();
}
示例11: GetFatAABB
public void GetFatAABB(int proxyID, out AABB aabb)
{
if (_idRegister.ContainsKey(proxyID))
aabb = _idRegister[proxyID].Span;
else
throw new KeyNotFoundException("proxyID not found in register");
}
示例12: createProxy
public int createProxy(AABB aabb, object userData)
{
int proxyId = m_tree.createProxy(aabb, userData);
++m_proxyCount;
bufferMove(proxyId);
return proxyId;
}
示例13: KdTreePhotonMap
public KdTreePhotonMap(int max) {
this.max_photons = max;
this.prev_scale = 1;
this.photonsCount = 0;
this.bbox = new AABB();
this.photons = new Photon[max];
}
示例14: DungeonRoom
public DungeonRoom(int id, AABB b)
{
boundary = b;
this.id = id;
this.color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
this.tiles = new List<DungeonTile>();
}
示例15: SetProxyAABB
public void SetProxyAABB(BroadphaseProxy proxy, ref AABB aabb)
{
// maintain the uniform grid as the aabb moves. this works by removing
// the stale aabb proxies and then adding the fresh aabb proxies.
RemoveProxyFromCells(proxy);
proxy.AABB = aabb;
AddProxyToCells(proxy);
}