本文整理汇总了C#中Vec2.addLocal方法的典型用法代码示例。如果您正苦于以下问题:C# Vec2.addLocal方法的具体用法?C# Vec2.addLocal怎么用?C# Vec2.addLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec2
的用法示例。
在下文中一共展示了Vec2.addLocal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getReactionForce
public override void getReactionForce(float inv_dt, ref Vec2 argOut)
{
Vec2 temp = pool.popVec2();
temp.set(m_ay);
temp.mulLocal(m_impulse);
argOut.set(m_ax);
argOut.mulLocal(m_springImpulse);
argOut.addLocal(temp);
argOut.mulLocal(inv_dt);
pool.pushVec2(1);
}
示例3: 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);
}
示例4: computeCentroidToOut
public void computeCentroidToOut(Vec2[] vs, int count, ref Vec2 v)
{
Debug.Assert(count >= 3);
v.set(0.0f, 0.0f);
float area = 0.0f;
// pRef is the reference point for forming triangles.
// It's location doesn't change the result (except for rounding error).
Vec2 pRef = pool1;
pRef.setZero();
Vec2 e1 = pool2;
Vec2 e2 = pool3;
float inv3 = 1.0f/3.0f;
for (int i = 0; i < count; ++i)
{
// Triangle vertices.
Vec2 p1 = pRef;
Vec2 p2 = vs[i];
Vec2 p3 = i + 1 < count ? vs[i + 1] : vs[0];
e1.set(p2); e1.subLocal(p1);
e2.set(p3); e2.subLocal(p1);
float D = Vec2.cross(e1, e2);
float triangleArea = 0.5f*D;
area += triangleArea;
// Area weighted centroid
e1.set(p1);
e1.addLocal(p2);
e1.addLocal(p3);
e1.mulLocal(triangleArea*inv3);
v.addLocal(e1);
}
// Centroid
Debug.Assert(area > Settings.EPSILON);
v.mulLocal(1.0f/area);
}
示例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: getCenter
/**
* Get the center of the AABB
*
* @return
*/
public Vec2 getCenter()
{
Vec2 center = new Vec2(lowerBound);
center.addLocal(upperBound);
center.mulLocal(.5f);
return center;
}
示例7: getWitnessPoints
public void getWitnessPoints(Vec2 pA, Vec2 pB)
{
switch (m_count)
{
case 0:
Debug.Assert(false);
break;
case 1:
pA.set(m_v1.wA);
pB.set(m_v1.wB);
break;
case 2:
case2.set(m_v1.wA);
case2.mulLocal(m_v1.a);
pA.set(m_v2.wA);
pA.mulLocal(m_v2.a);
pA.addLocal(case2);
// m_v1.a * m_v1.wA + m_v2.a * m_v2.wA;
// *pB = m_v1.a * m_v1.wB + m_v2.a * m_v2.wB;
case2.set(m_v1.wB);
case2.mulLocal(m_v1.a);
pB.set(m_v2.wB);
pB.mulLocal(m_v2.a);
pB.addLocal(case2);
break;
case 3:
pA.set(m_v1.wA);
pA.mulLocal(m_v1.a);
case3.set(m_v2.wA);
case3.mulLocal(m_v2.a);
case33.set(m_v3.wA);
case33.mulLocal(m_v3.a);
pA.addLocal(case3);
pA.addLocal(case33);
pB.set(pA);
// *pA = m_v1.a * m_v1.wA + m_v2.a * m_v2.wA + m_v3.a * m_v3.wA;
// *pB = *pA;
break;
default:
Debug.Assert(false);
break;
}
}