本文整理汇总了C#中Box2CS.Vec2类的典型用法代码示例。如果您正苦于以下问题:C# Vec2类的具体用法?C# Vec2怎么用?C# Vec2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vec2类属于Box2CS命名空间,在下文中一共展示了Vec2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WeldJointDef
public WeldJointDef()
{
JointType = JointType.Weld;
_localAnchorA = Vec2.Empty;
_localAnchorB = Vec2.Empty;
_referenceAngle = 0.0f;
}
示例2: 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);
}
}
示例3: DrawSolidCircle
public override void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, ColorF color)
{
float k_segments = (int)(1024.0f * (radius / 50));
float k_increment = (float)(2.0f * Math.PI / k_segments);
float theta = 0.0f;
Gl.glEnable(Gl.GL_BLEND);
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glColor4f(0.5f * color.R, 0.5f * color.G, 0.5f * color.B, 0.5f);
Gl.glBegin(Gl.GL_TRIANGLE_FAN);
for (int i = 0; i < k_segments; ++i)
{
Vec2 v = center + radius * new Vec2((float)Math.Cos(theta), (float)Math.Sin(theta));
Gl.glVertex2f(v.X, v.Y);
theta += k_increment;
}
Gl.glEnd();
Gl.glDisable(Gl.GL_BLEND);
theta = 0.0f;
Gl.glColor4f(color.R, color.G, color.B, 1.0f);
Gl.glBegin(Gl.GL_LINE_LOOP);
for (int i = 0; i < k_segments; ++i)
{
Vec2 v = center + radius * new Vec2((float)Math.Cos(theta), (float)Math.Sin(theta));
Gl.glVertex2f(v.X, v.Y);
theta += k_increment;
}
Gl.glEnd();
Vec2 p = center + radius * axis;
Gl.glBegin(Gl.GL_LINES);
Gl.glVertex2f(center.X, center.Y);
Gl.glVertex2f(p.X, p.Y);
Gl.glEnd();
}
示例4: Report
void Report(Vec2 point, Vec2 normal)
{
_hit++;
Vec2 sub = _start - point;
float len = sub.Length();
if (_hit > 100 || _start == point || len == 0)
return;
starts.Add(_start);
ends.Add(point);
var reflect = Reflect(_start, point, normal);
_length -= len;
_start = point;
_normal = normal;
if (_length > 0)
{
_world.RayCast(_callback, _start, _start - (reflect * _length));
if (!_callback.m_hit || (_start == _callback.m_point))
{
starts.Add(_start);
ends.Add(_start - (reflect * _length));
}
Report(_callback.m_point, _callback.m_normal);
}
}
示例5: FrictionJointDef
public FrictionJointDef()
{
JointType = JointType.Friction;
_localAnchorA = Vec2.Empty;
_localAnchorB = Vec2.Empty;
_maxForce = 0.0f;
_maxTorque = 0.0f;
}
示例6: DrawSegment
public override void DrawSegment(Vec2 p1, Vec2 p2, ColorF color)
{
Gl.glColor3f(color.R, color.G, color.B);
Gl.glBegin(Gl.GL_LINES);
Gl.glVertex2f(p1.X, p1.Y);
Gl.glVertex2f(p2.X, p2.Y);
Gl.glEnd();
}
示例7: MouseMove
public override void MouseMove(Vec2 p)
{
if (_moving)
{
newPos = p;
}
base.MouseMove(p);
}
示例8: Initialize
/// Initialize the bodies, anchors, and reference angle using a world
/// anchor point.
public void Initialize(Body body1, Body body2, Vec2 anchor)
{
BodyA = body1;
BodyB = body2;
_localAnchorA = BodyA.GetLocalPoint(anchor);
_localAnchorB = BodyB.GetLocalPoint(anchor);
_referenceAngle = BodyB.Angle - BodyA.Angle;
}
示例9: DrawPoint
public void DrawPoint(Vec2 p, float size, ColorF color)
{
Gl.glPointSize(size);
Gl.glBegin(Gl.GL_POINTS);
Gl.glColor3f(color.R, color.G, color.B);
Gl.glVertex2f(p.X, p.Y);
Gl.glEnd();
Gl.glPointSize(1.0f);
}
示例10: DistanceJointDef
public DistanceJointDef()
{
JointType = JointType.Distance;
_localAnchorA = Vec2.Empty;
_localAnchorB = Vec2.Empty;
_length = 1.0f;
_frequencyHz = 0.0f;
_dampingRatio = 0.0f;
}
示例11: Contains
/// Does this aabb contain the provided AABB.
public bool Contains(Vec2 pt)
{
bool result = true;
result = result && LowerBound.X <= pt.X;
result = result && LowerBound.Y <= pt.Y;
result = result && pt.X <= UpperBound.X;
result = result && pt.Y <= UpperBound.Y;
return result;
}
示例12: DrawPolygon
public override void DrawPolygon(Vec2[] vertices, int vertexCount, ColorF color)
{
Gl.glColor3f(color.R, color.G, color.B);
Gl.glBegin(Gl.GL_LINE_LOOP);
for (int i = 0; i < vertexCount; ++i)
{
Gl.glVertex2f(vertices[i].X, vertices[i].Y);
}
Gl.glEnd();
}
示例13: DrawArc
public void DrawArc(Vec2 pos, float radius, float startAngle, float endAngle)
{
Gl.glPushMatrix();
Gl.glTranslatef(pos.X, pos.Y, 0);
var xx = Glu.gluNewQuadric();
Glu.gluQuadricDrawStyle(xx, Glu.GLU_SILHOUETTE);
Glu.gluPartialDisk(xx, radius, radius, 24, 1, b2Math.Rad2Deg(startAngle), b2Math.Rad2Deg(endAngle - startAngle));
Glu.gluDeleteQuadric(xx);
Gl.glPopMatrix();
}
示例14: PulleyJointDef
public PulleyJointDef()
{
JointType = JointType.Pulley;
_groundAnchorA = new Vec2(-1.0f, 1.0f);
_groundAnchorB = new Vec2(1.0f, 1.0f);
_localAnchorA = new Vec2(-1.0f, 0.0f);
_localAnchorB = new Vec2(1.0f, 0.0f);
_lengthA = 0.0f;
_maxLengthA = 0.0f;
_lengthB = 0.0f;
_maxLengthB = 0.0f;
_ratio = 1.0f;
CollideConnected = true;
}
示例15: DrawCircle
public override void DrawCircle(Vec2 center, float radius, ColorF color)
{
float k_segments = (int)(1024.0f * (radius / 50));
float k_increment = (float)(2.0f * Math.PI / k_segments);
float theta = 0.0f;
Gl.glColor3f(color.R, color.G, color.B);
Gl.glBegin(Gl.GL_LINE_LOOP);
for (int i = 0; i < k_segments; ++i)
{
Vec2 v = center + radius * new Vec2((float)Math.Cos(theta), (float)Math.Sin(theta));
Gl.glVertex2f(v.X, v.Y);
theta += k_increment;
}
Gl.glEnd();
}