本文整理汇总了C#中Box2CS.Vec2.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Vec2.Normalize方法的具体用法?C# Vec2.Normalize怎么用?C# Vec2.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2CS.Vec2
的用法示例。
在下文中一共展示了Vec2.Normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LineJoint
public LineJoint()
{
Body ground = null;
{
PolygonShape shape = new PolygonShape();
shape.SetAsEdge(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
BodyDef bd = new BodyDef();
ground = m_world.CreateBody(bd);
ground.CreateFixture(shape, 0.0f);
}
{
PolygonShape shape = new PolygonShape();
shape.SetAsBox(0.5f, 2.0f);
BodyDef bd = new BodyDef();
bd.BodyType = BodyType.Dynamic;
bd.Position = new Vec2(0.0f, 7.0f);
Body body = m_world.CreateBody(bd);
body.CreateFixture(shape, 1.0f);
LineJointDef jd = new LineJointDef();
Vec2 axis = new Vec2(2.0f, 1.0f);
axis.Normalize();
jd.Initialize(ground, body, new Vec2(0.0f, 8.5f), axis);
jd.MotorSpeed = 0.0f;
jd.MaxMotorForce = 100.0f;
jd.EnableMotor = true;
jd.LowerTranslation = -4.0f;
jd.UpperTranslation = 4.0f;
jd.EnableLimit = true;
m_world.CreateJoint(jd);
}
}
示例2: Prismatic
public Prismatic()
{
Body ground = null;
{
BodyDef bd = new BodyDef();
ground = m_world.CreateBody(bd);
PolygonShape shape = new PolygonShape();
shape.SetAsEdge(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
ground.CreateFixture(shape, 0.0f);
}
{
PolygonShape shape = new PolygonShape();
shape.SetAsBox(2.0f, 0.5f);
BodyDef bd = new BodyDef();
bd.BodyType = BodyType.Dynamic;
bd.Position = new Vec2(-10.0f, 10.0f);
bd.Angle = 0.5f * (float)Math.PI;
bd.AllowSleep = false;
Body body = m_world.CreateBody(bd);
body.CreateFixture(shape, 5.0f);
PrismaticJointDef pjd = new PrismaticJointDef();
// Bouncy limit
Vec2 axis = new Vec2(2.0f, 1.0f);
axis.Normalize();
pjd.Initialize(ground, body, new Vec2(0.0f, 0.0f), axis);
// Non-bouncy limit
//pjd.Initialize(ground, body, new Vec2(-10.0f, 10.0f), new Vec2(1.0f, 0.0f));
pjd.MotorSpeed = 10.0f;
pjd.MaxMotorForce = 10000.0f;
pjd.EnableMotor = true;
pjd.LowerTranslation = 0.0f;
pjd.UpperTranslation = 20.0f;
pjd.EnableLimit = false;
m_joint = (PrismaticJoint)m_world.CreateJoint(pjd);
}
}