• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Box2CS.Vec2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Box2CS.Vec2的典型用法代码示例。如果您正苦于以下问题:C# Vec2类的具体用法?C# Vec2怎么用?C# Vec2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Vec2类属于Box2CS命名空间,在下文中一共展示了Vec2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WeldJointDef

 public WeldJointDef()
 {
     JointType = JointType.Weld;
     _localAnchorA = Vec2.Empty;
     _localAnchorB = Vec2.Empty;
     _referenceAngle = 0.0f;
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:7,代码来源:WeldJoint.cs


示例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);
            }
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:35,代码来源:LineJoint.cs


示例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();
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:35,代码来源:Render.cs


示例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);
            }
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:31,代码来源:Mirrors.cs


示例5: FrictionJointDef

 public FrictionJointDef()
 {
     JointType = JointType.Friction;
     _localAnchorA = Vec2.Empty;
     _localAnchorB = Vec2.Empty;
     _maxForce = 0.0f;
     _maxTorque = 0.0f;
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:8,代码来源:FrictionJoint.cs


示例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();
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:8,代码来源:Render.cs


示例7: MouseMove

 public override void MouseMove(Vec2 p)
 {
     if (_moving)
     {
         newPos = p;
     }
     base.MouseMove(p);
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:8,代码来源:MovingJoint.cs


示例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;
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:10,代码来源:WeldJoint.cs


示例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);
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:9,代码来源:Render.cs


示例10: DistanceJointDef

 public DistanceJointDef()
 {
     JointType = JointType.Distance;
     _localAnchorA = Vec2.Empty;
     _localAnchorB = Vec2.Empty;
     _length = 1.0f;
     _frequencyHz = 0.0f;
     _dampingRatio = 0.0f;
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:9,代码来源:DistanceJoint.cs


示例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;
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:10,代码来源:Math.cs


示例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();
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:10,代码来源:Render.cs


示例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();
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:10,代码来源:Render.cs


示例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;
 }
开发者ID:pixeltasim,项目名称:Conform,代码行数:14,代码来源:PulleyJoint.cs


示例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();
 }
开发者ID:RubisetCie,项目名称:box2c,代码行数:15,代码来源:Render.cs


示例16: 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);
            }
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:44,代码来源:Prismatic.cs


示例17: ElasticBody

        /// Main...
        public ElasticBody()
        {
            Program.MainForm.ViewZoom = 0.25f;

            /// Bottom static body
            {
                PolygonShape sd = new PolygonShape();
                sd.SetAsBox(50.0f, 2.0f);
                BodyDef bd = new BodyDef();
                bd.Position = new Vec2(-1.0f, -7.5f);

                m_ground = m_world.CreateBody(bd);
                m_ground.CreateFixture(new FixtureDef(sd, 0.0f, 0.1f, 0.1f));
            }

            /// "Elastic body" 64 bodies - something like a lin. elastic compound
            /// connected via dynamic forces (springs)
            {
                PolygonShape sd = new PolygonShape();
                sd.SetAsBox(width, height);

                FixtureDef sdf = new FixtureDef();
                sdf.Density    = 1.5f;
                sdf.Friction   = 0.01f;
                sdf.Filter.GroupIndex = -1;
                sdf.Shape = sd;
                Vec2 startpoint = new Vec2(0, 0);
                BodyDef    bd = new BodyDef();
                bd.BodyType = BodyType.Dynamic;
                bd.Bullet = false;
              	 			//bd.AllowSleep = false;
                for (int i = 0; i < BodyCountY; ++i)
                {
                    for (int j = 0; j < BodyCountX; ++j)
                    {
                        bd.Position = new Vec2(j*(width*2), 2.51f + (height*2) * i);
                        bd.Position  += startpoint;
                        Body body  = m_world.CreateBody(bd);
                        bodies[BodyCountX*i+j] = body;
                        body.CreateFixture(sdf);
                    }
                }
            }
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:45,代码来源:ElasticBody.cs


示例18: Apply

        public void Apply()
        {
            if (!string.IsNullOrEmpty(toolStripStatusLabel1.Text))
            {
                MessageBox.Show("You have errors in your polygon. Please fix these before applying:\n\n"+toolStripStatusLabel1.ToolTipText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Vec2[] vertices = new Vec2[PolyData.Vertices.Count];

            for (int i = 0; i < PolyData.Vertices.Count; ++i)
            {
                vertices[i] = (new Vec2((PolyData.Vertices[i].X - (pictureBox1.Width / 2)) / pictureBox1.Width, (PolyData.Vertices[i].Y - (pictureBox1.Height / 2)) / pictureBox1.Height)) * (float)PolyData.Scale;
            }

            SelectedShape.Vertices = vertices;

            if ((Program.MainForm.SelectedNode.Node.Parent as FixtureNode).OwnedBody != null &&
                (Program.MainForm.SelectedNode.Node.Parent as FixtureNode).OwnedBody.AutoMassRecalculate)
                (Program.MainForm.SelectedNode.Node.Parent as FixtureNode).OwnedBody.RecalculateMass();
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:20,代码来源:PolygonPanel.cs


示例19: GenerateBodies

        public Body[] GenerateBodies(World world, Vec2 basePosition, FixtureDef def)
        {
            if (_vecs.Count <= 1)
                throw new ArgumentOutOfRangeException("Vecs");

            Body[] bodies = new Body[_vecs.Count - 1];

            for (int i = 0; i < _vecs.Count - 1; ++i)
            {
                PolygonShape edge = new PolygonShape(_vecs[i], _vecs[i + 1]);

                BodyDef bd = new BodyDef();
                bd.Position = basePosition;

                bodies[i] = world.CreateBody(bd);
                bodies[i].CreateFixture(new FixtureDef(edge, 0, def.Restitution, def.Friction, false, def.UserData));
            }

            return bodies;
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:20,代码来源:EdgeChain.cs


示例20: CreateCircle

        void CreateCircle()
        {
            float radius = 2.0f;
            CircleShape shape = new CircleShape();
            shape.Position = Vec2.Empty;
            shape.Radius = radius;

            FixtureDef fd = new FixtureDef();
            fd.Shape = shape;
            fd.Density = 1.0f;
            fd.Friction = 0.0f;

            Vec2 p = new Vec2(Rand.RandomFloat(), 3.0f + Rand.RandomFloat());
            BodyDef bd = new BodyDef();
            bd.BodyType = BodyType.Dynamic;
            bd.Position = p;
            //bd.allowSleep = false;
            Body body = m_world.CreateBody(bd);

            body.CreateFixture(fd);
        }
开发者ID:RubisetCie,项目名称:box2c,代码行数:21,代码来源:Confined.cs



注:本文中的Box2CS.Vec2类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Box2D.Vec2类代码示例发布时间:2022-05-24
下一篇:
C# Models.PortugalVillasContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap