本文整理汇总了C#中Vec2.subLocal方法的典型用法代码示例。如果您正苦于以下问题:C# Vec2.subLocal方法的具体用法?C# Vec2.subLocal怎么用?C# Vec2.subLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec2
的用法示例。
在下文中一共展示了Vec2.subLocal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getWorldToScreen
/// <seealso cref="IViewportTransform.getWorldToScreen(Vec2, Vec2)">
/// </seealso>
public virtual void getWorldToScreen(Vec2 argWorld, Vec2 argScreen)
{
argScreen.set_Renamed(argWorld);
argScreen.subLocal(box.center);
box.R.mulToOut(argScreen, argScreen);
if (yFlip)
{
yFlipMat.mulToOut(argScreen, argScreen);
}
argScreen.addLocal(box.extents);
}
示例2: getScreenToWorld
/// <seealso cref="IViewportTransform.getScreenToWorld(Vec2, Vec2)">
/// </seealso>
public virtual void getScreenToWorld(Vec2 argScreen, Vec2 argWorld)
{
argWorld.set_Renamed(argScreen);
argWorld.subLocal(box.extents);
box.R.invertToOut(inv2);
inv2.mulToOut(argWorld, argWorld);
if (yFlip)
{
yFlipMatInv.mulToOut(argWorld, argWorld);
}
argWorld.addLocal(box.center);
}
示例3: validate
/**
* Validate convexity. This is a very time consuming operation.
*
* @return
*/
public bool validate()
{
for (int i = 0; i < m_count; ++i)
{
int i1 = i;
int i2 = i < m_count - 1 ? i1 + 1 : 0;
Vec2 p = m_vertices[i1];
Vec2 e =new Vec2(m_vertices[i2]);
e.subLocal(p);
for (int j = 0; j < m_count; ++j)
{
if (j == i1 || j == i2)
{
continue;
}
Vec2 v = new Vec2(m_vertices[j]);
v.subLocal(p);
float c = Vec2.cross(e, v);
if (c < 0.0f)
{
return false;
}
}
}
return true;
}
示例4: set
/**
* Create a convex hull from the given array of points. The count must be in the range [3,
* Settings.maxPolygonVertices]. This method takes an arraypool for pooling.
*
* @warning the points may be re-ordered, even if they form a convex polygon.
* @warning collinear points are removed.
*/
public void set(Vec2[] verts, int num, Vec2Array vecPool,
IntArray intPool)
{
Debug.Assert(3 <= num && num <= Settings.maxPolygonVertices);
if (num < 3)
{
setAsBox(1.0f, 1.0f);
return;
}
int n = MathUtils.min(num, Settings.maxPolygonVertices);
// Perform welding and copy vertices into local buffer.
Vec2[] ps =
(vecPool != null)
? vecPool.get(Settings.maxPolygonVertices)
: new Vec2[Settings.maxPolygonVertices];
int tempCount = 0;
for (int i = 0; i < n; ++i)
{
Vec2 v = verts[i];
bool unique = true;
for (int j = 0; j < tempCount; ++j)
{
if (MathUtils.distanceSquared(v, ps[j]) < 0.5f*Settings.linearSlop)
{
unique = false;
break;
}
}
if (unique)
{
ps[tempCount++] = v;
}
}
n = tempCount;
if (n < 3)
{
// Polygon is degenerate.
Debug.Assert(false);
setAsBox(1.0f, 1.0f);
return;
}
// Create the convex hull using the Gift wrapping algorithm
// http://en.wikipedia.org/wiki/Gift_wrapping_algorithm
// Find the right most point on the hull
int i0 = 0;
float x0 = ps[0].x;
for (int i = 1; i < n; ++i)
{
float x = ps[i].x;
if (x > x0 || (x == x0 && ps[i].y < ps[i0].y))
{
i0 = i;
x0 = x;
}
}
int[] hull =
(intPool != null)
? intPool.get(Settings.maxPolygonVertices)
: new int[Settings.maxPolygonVertices];
int m = 0;
int ih = i0;
while (true)
{
hull[m] = ih;
int ie = 0;
for (int j = 1; j < n; ++j)
{
if (ie == ih)
{
ie = j;
continue;
}
Vec2 r = new Vec2(ps[ie]);
r.subLocal(ps[hull[m]]);
Vec2 v = new Vec2(ps[j]);
v.subLocal(ps[hull[m]]);
float c = Vec2.cross(r, v);
if (c < 0.0f)
{
ie = j;
}
//.........这里部分代码省略.........
示例5: launchBomb
private void launchBomb(Vec2 position, Vec2 velocity)
{
if (bomb != null)
{
m_world.destroyBody(bomb);
bomb = null;
}
// todo optimize this
BodyDef bd = new BodyDef();
bd.type = BodyType.DYNAMIC;
bd.position.set(position);
bd.bullet = true;
bomb = m_world.createBody(bd);
bomb.setLinearVelocity(velocity);
CircleShape circle = new CircleShape();
circle.m_radius = 0.3f;
FixtureDef fd = new FixtureDef();
fd.shape = circle;
fd.density = 20f;
fd.restitution = 0;
Vec2 minV = new Vec2(position);
Vec2 maxV = new Vec2(position);
minV.subLocal(new Vec2(.3f, .3f));
maxV.addLocal(new Vec2(.3f, .3f));
aabb.lowerBound.set(minV);
aabb.upperBound.set(maxV);
bomb.createFixture(fd);
}
示例6: getExtents
/**
* Get the extents of the AABB (half-widths).
*
* @return
*/
public Vec2 getExtents()
{
Vec2 center = new Vec2(upperBound);
center.subLocal(lowerBound);
center.mulLocal(.5f);
return center;
}