本文整理汇总了C#中FarseerPhysics.Dynamics.Joints.Joint类的典型用法代码示例。如果您正苦于以下问题:C# Joint类的具体用法?C# Joint怎么用?C# Joint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Joint类属于FarseerPhysics.Dynamics.Joints命名空间,在下文中一共展示了Joint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Add
public void Add(Joint joint)
{
if (JointCount >= JointCapacity)
return;
// Debug.Assert(JointCount < JointCapacity);
_joints[JointCount++] = joint;
}
开发者ID:Kyle44,项目名称:Project-Jack,代码行数:7,代码来源:Island.cs
示例2: DestroyJoint
internal void DestroyJoint()
{
if (this.joint == null) return;
Scene.PhysicsWorld.RemoveJoint(this.joint);
this.joint.Broke -= this.joint_Broke;
this.joint = null;
}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:7,代码来源:JointInfo.cs
示例3: ConstructElement
public ConstructElement(ScrapGame game, Segment entity, Construct construct, Point offSet, Joint rootJoint)
{
branchJoints = new List<Joint>();
this.rootJoint = rootJoint;
this.segment = entity;
this.game = game;
this.construct = construct;
this.offSet = offSet;
}
开发者ID:MrMallet,项目名称:Scrap,代码行数:9,代码来源:ConstructElement.cs
示例4: Balance
public Balance(World worldFarseer, Vector2 posDepart, Texture2D tex)
: base(worldFarseer, posDepart, tex)
{
objPhys.IsStatic = false;
objPhys.BodyType = BodyType.Dynamic;
objPhys.AngularDamping = 0.8f;
objPhys.Inertia = 2;
Body rotor = BodyFactory.CreateCircle(worldFarseer, 0.1f, 3f);
pivot = JointFactory.CreateRevoluteJoint(worldFarseer,objPhys,rotor,objPhys.Position);
}
开发者ID:vipavaday,项目名称:RealiteV,代码行数:10,代码来源:Balance.cs
示例5: LoadContent
public override void LoadContent()
{
base.LoadContent();
World.Gravity = new Vector2(0, 140);
projection = Matrix.CreateOrthographicOffCenter(0f, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, 0f, 0f, 1f);
hookpointmanager = new HookPointManager(World);
MaterialType hookpointmaterial = MaterialType.Blank;
swingerbody = BodyFactory.CreateBody(World, new Vector2(3, 10));
swinger = FixtureFactory.AttachCircle(1, 40, swingerbody);
swinger.Body.BodyType = BodyType.Dynamic;
swinger.Friction = 0;
body3 = BodyFactory.CreateBody(World, new Vector2(-4, -10));
body3.IsStatic = true;
CircleShape circleShape3 = new CircleShape(.4f, .3f);
Fixture fixture3 = body3.CreateFixture(circleShape3, hookpointmaterial);
body3.IgnoreGravity = true;
fixture3.Body.BodyType = BodyType.Static;
body2 = BodyFactory.CreateBody(World, new Vector2(-8, -10));
body2.IsStatic = true;
CircleShape circleShape2 = new CircleShape(.4f, .3f);
fixture2 = body2.CreateFixture(circleShape2, hookpointmaterial);
body2.IgnoreGravity = true;
fixture2.Body.BodyType = BodyType.Static;
joint1 = JointFactory.CreateSliderJoint(World, swingerbody, fixture3.Body, Vector2.Zero, Vector2.Zero, 4, 5);
_border = new Border(World, this, ScreenManager.GraphicsDevice.Viewport);
//SetUserAgent(swingerbody, 100f, 100f);
// create sprite based on body
swingersprite = new Sprite(ScreenManager.Assets.TextureFromShape(swingerbody.FixtureList[0].Shape,
MaterialType.Dots,
Color.Red, 2f));
body3sprite = new Sprite(ScreenManager.Assets.TextureFromShape(swingerbody.FixtureList[0].Shape,
MaterialType.Dots,
Color.Red, 2f));
body2sprite = new Sprite(ScreenManager.Assets.TextureFromShape(swingerbody.FixtureList[0].Shape,
MaterialType.Dots,
Color.Red, 2f));
}
开发者ID:kbo4sho,项目名称:SG.WP7,代码行数:50,代码来源:SwingerScreen.cs
示例6: Wheel
public Wheel(ScrapGame game, Vector2 position)
: base(game)
{
texture = game.Content.Load<Texture2D>("wheel");
wheel = BodyFactory.CreateCircle(game.world, .49f, 1f, this);
wheel.Restitution = .5f;
wheel.BodyType = BodyType.Dynamic;
wheel.Position = position;
wheel.Friction = .9f;
//wheel.CollisionCategories = new Category();
body = BodyFactory.CreateRectangle(game.world, .5f, .5f, .5f, this);
body.Position = position;
body.BodyType = BodyType.Dynamic;
body.Restitution = .5f;
body.Friction = .9f;
bodyJoint = JointFactory.CreateRevoluteJoint(game.world, body, wheel, new Vector2(0, 0), new Vector2(0, 0));
}
开发者ID:MrMallet,项目名称:Scrap,代码行数:20,代码来源:Wheel.cs
示例7: DriveWheel
public DriveWheel(ScrapGame game, Vector2 position)
: base(game)
{
texture = game.Content.Load<Texture2D>("wheel");
wheel = BodyFactory.CreateCircle(game.world, .49f, 2f,this);
wheel.Restitution = 1f;
wheel.BodyType = BodyType.Dynamic;
wheel.Position = position;
wheel.Friction = 2f;
wheel.UserData = this;
body = BodyFactory.CreateRectangle(game.world, .1f, .1f, 2f);
body.Position = position;
body.BodyType = BodyType.Dynamic;
//body.IgnoreCCD = true;
wheelHubJoint = JointFactory.CreateRevoluteJoint(game.world, body, wheel, new Vector2(0, 0));
}
开发者ID:MrMallet,项目名称:Scrap,代码行数:21,代码来源:DriveWheel.cs
示例8: AddJoint
/// <summary>
/// Create a joint to constrain bodies together. This may cause the connected bodies to cease colliding.
/// </summary>
/// <param name="joint">The joint.</param>
public void AddJoint(Joint joint)
{
//You are adding the same joint twice?
Debug.Assert(!_jointAddList.Contains(joint));
if (!_jointAddList.Contains(joint))
_jointAddList.Add(joint);
}
开发者ID:dvgamer,项目名称:GhostLegend-XNA,代码行数:12,代码来源:World.cs
示例9: RemoveJoint
private void RemoveJoint(Joint joint, bool doCheck)
{
if (doCheck)
{
Debug.Assert(!_jointRemoveList.Contains(joint),
"The joint is already marked for removal. You are removing the joint more than once.");
}
if (!_jointRemoveList.Contains(joint))
_jointRemoveList.Add(joint);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:11,代码来源:World.cs
示例10: SerializeJoint
private void SerializeJoint(Joint joint)
{
if (joint.IsFixedType())
return;
_writer.WriteStartElement("Joint");
_writer.WriteAttributeString("Type", joint.JointType.ToString());
WriteElement("BodyA", FindBodyIndex(joint.BodyA));
WriteElement("BodyB", FindBodyIndex(joint.BodyB));
WriteElement("CollideConnected", joint.CollideConnected);
WriteElement("Breakpoint", joint.Breakpoint);
if (joint.UserData != null)
{
_writer.WriteStartElement("UserData");
WriteDynamicType(joint.UserData.GetType(), joint.UserData);
_writer.WriteEndElement();
}
switch (joint.JointType)
{
case JointType.Distance:
{
DistanceJoint djd = (DistanceJoint)joint;
WriteElement("DampingRatio", djd.DampingRatio);
WriteElement("FrequencyHz", djd.Frequency);
WriteElement("Length", djd.Length);
WriteElement("LocalAnchorA", djd.LocalAnchorA);
WriteElement("LocalAnchorB", djd.LocalAnchorB);
}
break;
case JointType.Friction:
{
FrictionJoint fjd = (FrictionJoint)joint;
WriteElement("LocalAnchorA", fjd.LocalAnchorA);
WriteElement("LocalAnchorB", fjd.LocalAnchorB);
WriteElement("MaxForce", fjd.MaxForce);
WriteElement("MaxTorque", fjd.MaxTorque);
}
break;
case JointType.Gear:
throw new Exception("Gear joint not supported by serialization");
case JointType.Line:
{
LineJoint ljd = (LineJoint)joint;
WriteElement("EnableMotor", ljd.MotorEnabled);
WriteElement("LocalAnchorA", ljd.LocalAnchorA);
WriteElement("LocalAnchorB", ljd.LocalAnchorB);
WriteElement("MotorSpeed", ljd.MotorSpeed);
WriteElement("DampingRatio", ljd.DampingRatio);
WriteElement("MaxMotorTorque", ljd.MaxMotorTorque);
WriteElement("FrequencyHz", ljd.Frequency);
WriteElement("LocalXAxis", ljd.LocalXAxis);
}
break;
case JointType.Prismatic:
{
PrismaticJoint pjd = (PrismaticJoint)joint;
//NOTE: Does not conform with Box2DScene
WriteElement("EnableLimit", pjd.LimitEnabled);
WriteElement("EnableMotor", pjd.MotorEnabled);
WriteElement("LocalAnchorA", pjd.LocalAnchorA);
WriteElement("LocalAnchorB", pjd.LocalAnchorB);
WriteElement("LocalXAxis1", pjd.LocalXAxis1);
WriteElement("LowerTranslation", pjd.LowerLimit);
WriteElement("UpperTranslation", pjd.UpperLimit);
WriteElement("MaxMotorForce", pjd.MaxMotorForce);
WriteElement("MotorSpeed", pjd.MotorSpeed);
}
break;
case JointType.Pulley:
{
PulleyJoint pjd = (PulleyJoint)joint;
WriteElement("GroundAnchorA", pjd.GroundAnchorA);
WriteElement("GroundAnchorB", pjd.GroundAnchorB);
WriteElement("LengthA", pjd.LengthA);
WriteElement("LengthB", pjd.LengthB);
WriteElement("LocalAnchorA", pjd.LocalAnchorA);
WriteElement("LocalAnchorB", pjd.LocalAnchorB);
WriteElement("MaxLengthA", pjd.MaxLengthA);
WriteElement("MaxLengthB", pjd.MaxLengthB);
WriteElement("Ratio", pjd.Ratio);
}
break;
case JointType.Revolute:
{
RevoluteJoint rjd = (RevoluteJoint)joint;
WriteElement("EnableLimit", rjd.LimitEnabled);
WriteElement("EnableMotor", rjd.MotorEnabled);
WriteElement("LocalAnchorA", rjd.LocalAnchorA);
//.........这里部分代码省略.........
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:101,代码来源:Serialization.cs
示例11: DrawJoint
private void DrawJoint(Joint joint)
{
if (!joint.Enabled)
return;
Body b1 = joint.BodyA;
Body b2 = joint.BodyB;
Transform xf1;
b1.GetTransform(out xf1);
Vector2 x2 = Vector2.Zero;
// WIP David
if (!joint.IsFixedType())
{
Transform xf2;
b2.GetTransform(out xf2);
x2 = xf2.p;
}
Vector2 p1 = joint.WorldAnchorA;
Vector2 p2 = joint.WorldAnchorB;
Vector2 x1 = xf1.p;
Color color = Color.FromArgb(255, 128, 205, 205);
switch (joint.JointType)
{
case JointType.Distance:
DrawSegment(p1, p2, color);
break;
case JointType.Pulley:
PulleyJoint pulley = (PulleyJoint)joint;
Vector2 s1 = b1.GetWorldPoint(pulley.LocalAnchorA);
Vector2 s2 = b2.GetWorldPoint(pulley.LocalAnchorB);
DrawSegment(p1, p2, color);
DrawSegment(p1, s1, color);
DrawSegment(p2, s2, color);
break;
case JointType.FixedMouse:
DrawPoint(p1, 0.5f, Color.FromArgb(255, 0, 255, 0));
DrawSegment(p1, p2, Color.FromArgb(255, 205, 205, 205));
break;
case JointType.Revolute:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
DrawSegment(x2, p2, color);
DrawSolidCircle(p2, 0.1f, Vector2.Zero, Colors.Red);
DrawSolidCircle(p1, 0.1f, Vector2.Zero, Colors.Blue);
break;
case JointType.FixedAngle:
//Should not draw anything.
break;
case JointType.FixedRevolute:
DrawSegment(x1, p1, color);
DrawSolidCircle(p1, 0.1f, Vector2.Zero, Colors.Purple);
break;
case JointType.FixedLine:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
break;
case JointType.FixedDistance:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
break;
case JointType.FixedPrismatic:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
break;
case JointType.Gear:
DrawSegment(x1, x2, color);
break;
default:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
DrawSegment(x2, p2, color);
break;
}
}
开发者ID:tinco,项目名称:Farseer-Physics,代码行数:80,代码来源:DebugViewSilverlight.cs
示例12: GearJoint
/// <summary>
/// Requires two existing revolute or prismatic joints (any combination will work).
/// The provided joints must attach a dynamic body to a static body.
/// </summary>
/// <param name="jointA">The first joint.</param>
/// <param name="jointB">The second joint.</param>
/// <param name="ratio">The ratio.</param>
public GearJoint(Joint jointA, Joint jointB, float ratio)
: base(jointA.BodyA, jointA.BodyB)
{
JointType = JointType.Gear;
JointA = jointA;
JointB = jointB;
Ratio = ratio;
m_typeA = jointA.JointType;
m_typeB = jointB.JointType;
// Make sure its the right kind of joint
Debug.Assert(m_typeA == JointType.Revolute || m_typeA == JointType.Prismatic || m_typeA == JointType.FixedRevolute || m_typeA == JointType.FixedPrismatic);
Debug.Assert(m_typeB == JointType.Revolute || m_typeB == JointType.Prismatic || m_typeB == JointType.FixedRevolute || m_typeB == JointType.FixedPrismatic);
float coordinateA = 0.0f, coordinateB = 0.0f;
m_bodyC = m_joint1.BodyA;
BodyA = m_joint1.BodyB;
// Get geometry of joint1
Transform xfA = BodyA.Xf;
float aA = BodyA.Sweep.A;
Transform xfC = m_bodyC.Xf;
float aC = m_bodyC.Sweep.A;
if (m_typeA == JointType.Revolute)
{
RevoluteJoint revolute = (RevoluteJoint)jointA;
m_localAnchorC = revolute.LocalAnchorA;
m_localAnchorA = revolute.LocalAnchorB;
m_referenceAngleA = revolute.ReferenceAngle;
m_localAxisC = Vector2.Zero;
coordinateA = aA - aC - m_referenceAngleA;
}
else
{
PrismaticJoint prismatic = (PrismaticJoint)jointA;
m_localAnchorC = prismatic.LocalAnchorA;
m_localAnchorA = prismatic.LocalAnchorB;
m_referenceAngleA = prismatic.ReferenceAngle;
m_localAxisC = prismatic.LocalXAxisA;
Vector2 pC = m_localAnchorC;
Vector2 pA = MathUtils.MulT(xfC.q, MathUtils.Mul(xfA.q, m_localAnchorA) + (xfA.p - xfC.p));
coordinateA = Vector2.Dot(pA - pC, m_localAxisC);
}
m_bodyD = m_joint2.BodyA;
BodyB = m_joint2.BodyB;
// Get geometry of joint2
Transform xfB = BodyB.Xf;
float aB = BodyB.Sweep.A;
Transform xfD = m_bodyD.Xf;
float aD = m_bodyD.Sweep.A;
if (m_typeB == JointType.Revolute)
{
RevoluteJoint revolute = (RevoluteJoint)jointB;
m_localAnchorD = revolute.LocalAnchorA;
m_localAnchorB = revolute.LocalAnchorB;
m_referenceAngleB = revolute.ReferenceAngle;
m_localAxisD = Vector2.Zero;
coordinateB = aB - aD - m_referenceAngleB;
}
else
{
PrismaticJoint prismatic = (PrismaticJoint)jointB;
m_localAnchorD = prismatic.LocalAnchorA;
m_localAnchorB = prismatic.LocalAnchorB;
m_referenceAngleB = prismatic.ReferenceAngle;
m_localAxisD = prismatic.LocalXAxisA;
Vector2 pD = m_localAnchorD;
Vector2 pB = MathUtils.MulT(xfD.q, MathUtils.Mul(xfB.q, m_localAnchorB) + (xfB.p - xfD.p));
coordinateB = Vector2.Dot(pB - pD, m_localAxisD);
}
_ratio = ratio;
m_constant = coordinateA + _ratio * coordinateB;
}
开发者ID:hilts-vaughan,项目名称:Farseer-Physics,代码行数:91,代码来源:GearJoint.cs
示例13: JointRemovedFired
private void JointRemovedFired(Joint joint)
{
if (joint is DistanceJoint)
_removedJoints++;
}
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:5,代码来源:WebTest.cs
示例14: SetCustomFloat
public void SetCustomFloat(Joint item, String propertyName, float val)
{
m_jointsWithCustomProperties.Add(item);
GetCustomPropertiesForItem(item, true).m_customPropertyMap_float.Add(propertyName, (float)val);
}
开发者ID:netonjm,项目名称:Rube.Net,代码行数:5,代码来源:Nb2dJson.cs
示例15: readCustomPropertiesFromJson
protected void readCustomPropertiesFromJson(Joint item, JObject value)
{
if (null == item)
return;
if (value["customProperties"] != null)
return;
int i = 0;
JArray propValues = (JArray)value["customProperties"];
if (null != propValues)
{
int numPropValues = propValues.Count;
for (i = 0; i < numPropValues; i++)
{
JObject propValue = (JObject)propValues[i];
String propertyName = propValue["name"].ToString();
if (propValue["int"] != null)
SetCustomInt(item, propertyName, (int)propValue["int"]);
if (propValue["float"] != null)
SetCustomFloat(item, propertyName, (float)propValue["float"]);
if (propValue["string"] != null)
SetCustomString(item, propertyName, propValue["string"].ToString());
if (propValue["vec2"] != null)
SetCustomVector(item, propertyName, this.jsonToVec("vec2", propValue));
if (propValue["bool"] != null)
SetCustomBool(item, propertyName, (bool)propValue["bool"]);
}
}
}
开发者ID:netonjm,项目名称:Rube.Net,代码行数:30,代码来源:Nb2dJson.cs
示例16: DrawJoint
private void DrawJoint(Joint joint)
{
Body b1 = joint.BodyA;
Body b2 = joint.BodyB;
Transform xf1, xf2;
b1.GetTransform(out xf1);
Vector2 x2 = new Vector2();
// WIP David
if (!joint.IsFixedType())
{
b2.GetTransform(out xf2);
x2 = xf2.Position;
}
Vector2 p2 = joint.WorldAnchorB;
Vector2 x1 = xf1.Position;
Vector2 p1 = joint.WorldAnchorA;
Color color = new Color(0.5f, 0.8f, 0.8f);
switch (joint.JointType)
{
case JointType.Distance:
DrawSegment(p1, p2, color);
break;
case JointType.Pulley:
{
PulleyJoint pulley = (PulleyJoint) joint;
Vector2 s1 = pulley.GroundAnchorA;
Vector2 s2 = pulley.GroundAnchorB;
DrawSegment(s1, p1, color);
DrawSegment(s2, p2, color);
DrawSegment(s1, s2, color);
}
break;
case JointType.FixedMouse:
FixedMouseJoint fixedMouseJoint = (FixedMouseJoint) joint;
p1 = fixedMouseJoint.Target;
DrawPoint(p2, 0.5f, new Color(0.0f, 1.0f, 0.0f));
DrawSegment(p1, p2, new Color(0.8f, 0.8f, 0.8f));
break;
case JointType.Revolute:
//DrawSegment(x2, p1, color);
DrawSegment(p2, p1, color);
DrawSolidCircle(p2, 0.1f, new Vector2(), Color.Red);
DrawSolidCircle(p1, 0.1f, new Vector2(), Color.Blue);
break;
case JointType.FixedRevolute:
DrawSolidCircle(p1, 0.1f, new Vector2(), Color.Pink);
break;
case JointType.FixedLine:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
break;
case JointType.FixedDistance:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
break;
case JointType.FixedPrismatic:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
break;
case JointType.Gear:
DrawSegment(x1, x2, color);
//DrawSegment(x1, p1, color);
//DrawSegment(p1, p2, color);
break;
default:
DrawSegment(x1, p1, color);
DrawSegment(p1, p2, color);
DrawSegment(x2, p2, color);
break;
}
}
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:81,代码来源:DebugViewXNA.cs
示例17: JointRemoved
protected virtual void JointRemoved(Joint joint)
{
if (_fixedMouseJoint == joint)
_fixedMouseJoint = null;
}
开发者ID:boris2,项目名称:mmogameproject2,代码行数:5,代码来源:Test.cs
示例18: SetCustomString
public void SetCustomString(Joint item, String propertyName, String val)
{
m_jointsWithCustomProperties.Add(item);
GetCustomPropertiesForItem(item, true).m_customPropertyMap_string.Add(propertyName, val);
}
开发者ID:netonjm,项目名称:Rube.Net,代码行数:5,代码来源:Nb2dJson.cs
示例19: JointRemoved
protected override void JointRemoved(Joint joint)
{
for (int i = 0; i < 8; ++i)
{
if (_joints[i] == joint)
{
_joints[i] = null;
break;
}
}
base.JointRemoved(joint);
}
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:13,代码来源:WebTest.cs
示例20: SetCustomVector
public void SetCustomVector(Joint item, String propertyName, Vector2 val)
{
m_jointsWithCustomProperties.Add(item);
GetCustomPropertiesForItem(item, true).m_customPropertyMap_vec2.Add(propertyName, val);
}
开发者ID:netonjm,项目名称:Rube.Net,代码行数:5,代码来源:Nb2dJson.cs
注:本文中的FarseerPhysics.Dynamics.Joints.Joint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论