本文整理汇总了C#中FVector2类的典型用法代码示例。如果您正苦于以下问题:C# FVector2类的具体用法?C# FVector2怎么用?C# FVector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FVector2类属于命名空间,在下文中一共展示了FVector2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MouseDrag
public virtual void MouseDrag()
{
// mouse press
if(Input.GetMouseButtonDown(0) && mouseJoint == null)
{
Body body = GetBodyAtMouse();
if(body != null)
{
FVector2 target = new FVector2(MouseXWorldPhys, MouseYWorldPhys);
mouseJoint = JointFactory.CreateFixedMouseJoint(FSWorldComponent.PhysicsWorld, body, target);
mouseJoint.CollideConnected = true;
mouseJoint.MaxForce = 300f * body.Mass;
body.Awake = true;
}
}
// mouse release
if(Input.GetMouseButtonUp(0))
{
if(mouseJoint != null)
{
FSWorldComponent.PhysicsWorld.RemoveJoint(mouseJoint);
mouseJoint = null;
}
}
// mouse move
if(mouseJoint != null)
{
FVector2 p2 = new FVector2(MouseXWorldPhys, MouseYWorldPhys);
mouseJoint.WorldAnchorB = p2;
}
}
示例2: CreateDistanceJoint
public static FSDistanceJoint CreateDistanceJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
FVector2 anchorB)
{
FSDistanceJoint distanceJoint = new FSDistanceJoint(bodyA, bodyB, anchorA, anchorB);
world.AddJoint(distanceJoint);
return distanceJoint;
}
示例3: EdgeShape
public EdgeShape(FVector2 start, FVector2 end)
: base(0)
{
ShapeType = ShapeType.Edge;
_radius = Settings.PolygonRadius;
Set(start, end);
}
示例4: FrictionJoint
public FrictionJoint(Body bodyA, Body bodyB, FVector2 localAnchorA, FVector2 localAnchorB)
: base(bodyA, bodyB)
{
JointType = JointType.Friction;
LocalAnchorA = localAnchorA;
LocalAnchorB = localAnchorB;
}
示例5: CreateFrictionJoint
public static FSFrictionJoint CreateFrictionJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
FVector2 anchorB)
{
FSFrictionJoint frictionJoint = new FSFrictionJoint(bodyA, bodyB, anchorA, anchorB);
world.AddJoint(frictionJoint);
return frictionJoint;
}
示例6: AttachBodiesWithSliderJoint
/// <summary>
/// Attaches the bodies with revolute joints.
/// </summary>
/// <param name="world">The world.</param>
/// <param name="bodies">The bodies.</param>
/// <param name="localAnchorA">The local anchor A.</param>
/// <param name="localAnchorB">The local anchor B.</param>
/// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
/// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
/// <param name="minLength">Minimum length of the slider joint.</param>
/// <param name="maxLength">Maximum length of the slider joint.</param>
/// <returns></returns>
public static List<FSSliderJoint> AttachBodiesWithSliderJoint(FSWorld world, List<FSBody> bodies, FVector2 localAnchorA,
FVector2 localAnchorB, bool connectFirstAndLast,
bool collideConnected, float minLength,
float maxLength)
{
List<FSSliderJoint> joints = new List<FSSliderJoint>(bodies.Count + 1);
for (int i = 1; i < bodies.Count; i++)
{
FSSliderJoint joint = new FSSliderJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB, minLength,
maxLength);
joint.CollideConnected = collideConnected;
world.AddJoint(joint);
joints.Add(joint);
}
if (connectFirstAndLast)
{
FSSliderJoint lastjoint = new FSSliderJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA, localAnchorB,
minLength, maxLength);
lastjoint.CollideConnected = collideConnected;
world.AddJoint(lastjoint);
joints.Add(lastjoint);
}
return joints;
}
示例7: CreateChainShape
public static Body CreateChainShape(World world, Vertices vertices, FVector2 position,
object userData)
{
Body body = CreateBody(world, position);
FixtureFactory.AttachChainShape(vertices, body, userData);
return body;
}
示例8: CircleShape
internal CircleShape()
: base(0)
{
ShapeType = ShapeType.Circle;
_radius = 0.0f;
_position = FVector2.Zero;
}
示例9: 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;
}
示例10: CreateDistanceJoint
public static DistanceJoint CreateDistanceJoint(World world, Body bodyA, Body bodyB, FVector2 anchorA,
FVector2 anchorB)
{
DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
world.AddJoint(distanceJoint);
return distanceJoint;
}
示例11: AbstractForceController
/// <summary>
/// Constructor
/// </summary>
public AbstractForceController()
: base(ControllerType.AbstractForceController)
{
Enabled = true;
Strength = 1.0f;
Position = new FVector2(0, 0);
MaximumSpeed = 100.0f;
TimingMode = TimingModes.Switched;
ImpulseTime = 0.0f;
ImpulseLength = 1.0f;
Triggered = false;
StrengthCurve = new Curve();
Variation = 0.0f;
Randomize = new Random(1234);
DecayMode = DecayModes.None;
DecayCurve = new Curve();
DecayStart = 0.0f;
DecayEnd = 0.0f;
StrengthCurve.Keys.Add(new CurveKey(0, 5));
StrengthCurve.Keys.Add(new CurveKey(0.1f, 5));
StrengthCurve.Keys.Add(new CurveKey(0.2f, -4));
StrengthCurve.Keys.Add(new CurveKey(1f, 0));
}
示例12: AttachRectangle
public static Fixture AttachRectangle(float width, float height, float density, FVector2 offset, Body body,
object userData)
{
Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
rectangleVertices.Translate(ref offset);
PolygonShape rectangleShape = new PolygonShape(rectangleVertices, density);
return body.CreateFixture(rectangleShape, userData);
}
示例13: Start
// Use this for initialization
void Start ()
{
Vector3 p = transform.position;
FVector2 aa = new FVector2(p.x + StartPoint.x, p.y + StartPoint.y);
FVector2 bb = new FVector2(p.x + EndPoint.x, p.y + EndPoint.y);
aabb = new AABB(aa, bb);
buoyancyController = new BuoyancyController(aabb, Density, LinearDragCoef, RotationalDragCoef, FSWorldComponent.PhysicsWorld.Gravity);
FSWorldComponent.PhysicsWorld.AddController(buoyancyController);
}
示例14: AttachCircle
public static Fixture AttachCircle(float radius, float density, Body body, FVector2 offset, object userData)
{
if (radius <= 0)
throw new ArgumentOutOfRangeException("radius", "Radius must be more than 0 meters");
CircleShape circleShape = new CircleShape(radius, density);
circleShape.Position = offset;
return body.CreateFixture(circleShape, userData);
}
示例15: Path
/// <summary>
/// Initializes a new instance of the <see cref="Path"/> class.
/// </summary>
/// <param name="vertices">The vertices to created the path from.</param>
public Path(FVector2[] vertices)
{
ControlPoints = new List<FVector2>(vertices.Length);
for (int i = 0; i < vertices.Length; i++)
{
Add(vertices[i]);
}
}