本文整理汇总了C#中Loon.Core.Geom.Vector2f.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2f.Set方法的具体用法?C# Vector2f.Set怎么用?C# Vector2f.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loon.Core.Geom.Vector2f
的用法示例。
在下文中一共展示了Vector2f.Set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateOrigin
private static Vector2f CreateOrigin(LObject o, Origin origin) {
Vector2f v = new Vector2f(o.X(), o.Y());
switch (origin) {
case Origin.CENTER:
v.Set(o.GetWidth() / 2f, o.GetHeight() / 2f);
return v;
case Origin.TOP_LEFT:
v.Set(0.0f, o.GetHeight());
return v;
case Origin.TOP_RIGHT:
v.Set(o.GetWidth(), o.GetHeight());
return v;
case Origin.BOTTOM_LEFT:
v.Set(0.0f, 0.0f);
return v;
case Origin.BOTTOM_RIGHT:
v.Set(o.GetWidth(), 0.0f);
return v;
case Origin.LEFT_CENTER:
v.Set(0.0f, o.GetHeight() / 2f);
return v;
case Origin.TOP_CENTER:
v.Set(o.GetWidth() / 2f, o.GetHeight());
return v;
case Origin.BOTTOM_CENTER:
v.Set(o.GetWidth() / 2f, 0.0f);
return v;
case Origin.RIGHT_CENTER:
v.Set(o.GetWidth(), o.GetHeight() / 2f);
return v;
default:
return v;
}
}
示例2: SplitEffect
public SplitEffect(LTexture t, RectBox limit_0, int d)
{
this.texture = t;
this.width = texture.GetWidth();
this.height = texture.GetHeight();
this.halfWidth = width / 2;
this.halfHeight = height / 2;
this.multiples = 2;
this.direction = d;
this.limit = limit_0;
this.timer = new LTimer(10);
this.visible = true;
this.v1 = new Vector2f();
this.v2 = new Vector2f();
switch (direction)
{
case Config.UP:
case Config.DOWN:
special = true;
{
v1.Set(0, 0);
v2.Set(halfWidth, 0);
break;
}
case Config.TLEFT:
case Config.TRIGHT:
v1.Set(0, 0);
v2.Set(halfWidth, 0);
break;
case Config.LEFT:
case Config.RIGHT:
special = true;
{
v1.Set(0, 0);
v2.Set(0, halfHeight);
break;
}
case Config.TUP:
case Config.TDOWN:
v1.Set(0, 0);
v2.Set(0, halfHeight);
break;
}
}
示例3: MulEqual
public void MulEqual(Vector2f v) {
v.Set(e00 * v.x + e10 * v.y, e01 * v.x + e11 * v.y);
}
示例4: Collide
public virtual int Collide(PShape s1, PShape s2, PContact[] cs) {
if (s1._type != PShapeType.CIRCLE_SHAPE
|| s2._type != PShapeType.CONVEX_SHAPE
&& s2._type != PShapeType.BOX_SHAPE) {
return 0;
}
PCircleShape c1 = (PCircleShape) s1;
PConvexPolygonShape p1 = (PConvexPolygonShape) s2;
float distance = -1F;
int edgeNumber = -1;
Vector2f[] vers = p1.vers;
int numVers = p1.numVertices;
Vector2f normal = new Vector2f();
Vector2f edgeNormal = new Vector2f();
Vector2f a = new Vector2f();
Vector2f b = new Vector2f();
int num = 0;
for (int i = 0; i < numVers; i++) {
a.Set(c1._pos.x - vers[i].x, c1._pos.y - vers[i].y);
distance = a.Length();
distance -= c1.rad;
if (distance <= 0.0F) {
PContact c = new PContact();
c.overlap = distance;
a.Normalize();
c.normal.Set(a.x, a.y);
c.pos.Set(vers[i].x, vers[i].y);
cs[num] = c;
if (++num == 2) {
return num;
}
}
}
if (num > 0) {
return num;
}
for (int i_0 = 0; i_0 < numVers; i_0++) {
Vector2f ver = vers[i_0];
Vector2f nextVer = vers[(i_0 + 1) % numVers];
float edgeX = nextVer.x - ver.x;
float edgeY = nextVer.y - ver.y;
edgeNormal.Set(edgeY, -edgeX);
edgeNormal.Normalize();
a.Set(c1._pos.x - ver.x, c1._pos.y - ver.y);
b.Set(c1._pos.x - nextVer.x, c1._pos.y - nextVer.y);
if ((a.x * edgeX + a.y * edgeY) * (b.x * edgeX + b.y * edgeY) <= 0.0F) {
float edgeLen = (float) System.Math.Sqrt(edgeX * edgeX + edgeY * edgeY);
float distanceToEdge = System.Math.Abs(a.x * edgeY - a.y * edgeX)
/ edgeLen;
if (distanceToEdge <= c1.rad) {
distanceToEdge -= c1.rad;
if (distance > distanceToEdge || distance == -1F) {
edgeNumber = i_0;
distance = distanceToEdge;
normal.Set(edgeNormal.x, edgeNormal.y);
}
}
}
}
if (edgeNumber > -1) {
PContact c_1 = new PContact();
c_1.overlap = distance;
c_1.normal = normal;
c_1.pos = c1._pos.Sub(normal.Mul(c1.rad));
cs[0] = c_1;
return 1;
}
bool hit = true;
for (int i_2 = 0; i_2 < numVers; i_2++) {
Vector2f ver = vers[i_2];
Vector2f nextVer = vers[(i_2 + 1) % numVers];
float v1x = nextVer.x - ver.x;
float v1y = nextVer.y - ver.y;
float v2x = c1._pos.x - ver.x;
float v2y = c1._pos.y - ver.y;
if (v1x * v2y - v1y * v2x >= 0.0F) {
continue;
}
hit = false;
break;
}
if (hit) {
distance = 1.0F;
normal = new Vector2f();
for (int i = 0; i < numVers; i++) {
Vector2f ver = vers[i];
Vector2f nextVer = vers[(i + 1) % numVers];
a.Set(nextVer.x - ver.x, nextVer.y - ver.y);
a.Normalize();
float d = c1._pos.Sub(ver).Cross(a);
if (d < 0.0F && (distance == 1.0F || distance < d)) {
distance = d;
normal.Set(a.y, -a.x);
}
}
if (distance != 1.0F) {
//.........这里部分代码省略.........
示例5: Intersect
public bool Intersect(Line other, bool limit, Vector2f result) {
float dx1 = end.GetX() - start.GetX();
float dx2 = other.end.GetX() - other.start.GetX();
float dy1 = end.GetY() - start.GetY();
float dy2 = other.end.GetY() - other.start.GetY();
float denom = (dy2 * dx1) - (dx2 * dy1);
if (denom == 0) {
return false;
}
float ua = (dx2 * (start.GetY() - other.start.GetY()))
- (dy2 * (start.GetX() - other.start.GetX()));
ua /= denom;
float ub = (dx1 * (start.GetY() - other.start.GetY()))
- (dy1 * (start.GetX() - other.start.GetX()));
ub /= denom;
if ((limit) && ((ua < 0) || (ua > 1) || (ub < 0) || (ub > 1))) {
return false;
}
float u = ua;
float ix = start.GetX() + (u * (end.GetX() - start.GetX()));
float iy = start.GetY() + (u * (end.GetY() - start.GetY()));
result.Set(ix, iy);
return true;
}
示例6: GetClosestPoint
public void GetClosestPoint(Vector2f point, Vector2f result) {
loc.Set(point);
loc.Sub(start);
float projDistance = vec.Dot(loc);
projDistance /= vec.LengthSquared();
if (projDistance < 0) {
result.Set(start);
return;
}
if (projDistance > 1) {
result.Set(end);
return;
}
result.x = start.GetX() + projDistance * vec.GetX();
result.y = start.GetY() + projDistance * vec.GetY();
}