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

C# Common.Vec2类代码示例

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

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



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

示例1: UpdateSweepRadius

		internal override void UpdateSweepRadius(Vec2 center)
		{
			// Update the sweep radius (maximum radius) as measured from
			// a local center point.
			Vec2 d = _localPosition - center;
			_sweepRadius = d.Length() + _radius - Settings.ToiSlop;
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:7,代码来源:CircleShape.cs


示例2: DrawSolidCircle

		public override void DrawSolidCircle(Vec2 center, float radius, Vec2 axis, Color color)
		{
			float k_segments = 16.0f;
			float k_increment = 2.0f * Box2DX.Common.Settings.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)SysMath.Cos(theta), (float)SysMath.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)SysMath.Cos(theta), (float)SysMath.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:colgreen,项目名称:box2dx,代码行数:35,代码来源:Render.cs


示例3: World

 public World(AABB worldAABB, Vec2 gravity, bool doSleep)
 {
     this._destructionListener = null;
     this._boundaryListener = null;
     this._contactFilter = WorldCallback.DefaultFilter;
     this._contactListener = null;
     this._debugDraw = null;
     this._bodyList = null;
     this._contactList = null;
     this._jointList = null;
     this._bodyCount = 0;
     this._contactCount = 0;
     this._jointCount = 0;
     this._warmStarting = true;
     this._continuousPhysics = true;
     this._allowSleep = doSleep;
     this._gravity = gravity;
     this._lock = false;
     this._inv_dt0 = 0f;
     this._contactManager = new ContactManager();
     this._contactManager._world = this;
     this._broadPhase = new BroadPhase(worldAABB, this._contactManager);
     BodyDef def = new BodyDef();
     this._groundBody = this.CreateBody(def);
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:25,代码来源:World.cs


示例4: DrawSolidCircle

        public override void DrawSolidCircle(Vec2 center, float radius, Box2DX.Common.Vec2 axis, Color color)
        {
            float k_segments = 16.0f;
            float k_increment = 2.0f * (float)System.Math.PI / k_segments;
            float theta = 0.0f;
            GL.Color3(0.5f * color.R, 0.5f * color.G, 0.5f * color.B);
            GL.Disable(EnableCap.Texture2D);
            GL.Begin(BeginMode.TriangleFan);
            for (int i = 0; i < k_segments; ++i) {
                Vec2 v = center + radius * new Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta));
                GL.Vertex3(v.X, v.Y, ZLayer);
                theta += k_increment;
            }
            GL.End();

            theta = 0.0f;
            GL.Color4(color.R, color.G, color.B, 1.0f);
            GL.Begin(BeginMode.LineLoop);
            for (int i = 0; i < k_segments; ++i) {
                Vec2 v = center + radius * new Vec2((float)System.Math.Cos(theta), (float)System.Math.Sin(theta));
                GL.Vertex3(v.X, v.Y, ZLayer);
                theta += k_increment;
            }
            GL.End();

            Vec2 p = center + radius * axis;
            GL.Begin(BeginMode.Lines);
            GL.Vertex3(center.X, center.Y, ZLayer);
            GL.Vertex3(p.X, p.Y, 0);
            GL.End();
            GL.Enable(EnableCap.Texture2D);
        }
开发者ID:CloneDeath,项目名称:PokemonSmash,代码行数:32,代码来源:OpenTKDebugDraw.cs


示例5: Set

 public void Set(Vec2 x1, float a1, Vec2 x2, float a2)
 {
     this.Linear1 = x1;
     this.Angular1 = a1;
     this.Linear2 = x2;
     this.Angular2 = a2;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:7,代码来源:Jacobian.cs


示例6: TestSegment

 public bool TestSegment(out float lambda, out Vec2 normal, Segment segment, float maxLambda)
 {
     lambda = 0f;
     normal = default(Vec2);
     Vec2 p = segment.P1;
     Vec2 a = segment.P2 - p;
     Vec2 a2 = this.P2 - this.P1;
     Vec2 vec = Vec2.Cross(a2, 1f);
     float num = 100f * Settings.FLT_EPSILON;
     float num2 = -Vec2.Dot(a, vec);
     bool result;
     if (num2 > num)
     {
         Vec2 a3 = p - this.P1;
         float num3 = Vec2.Dot(a3, vec);
         if (0f <= num3 && num3 <= maxLambda * num2)
         {
             float num4 = -a.X * a3.Y + a.Y * a3.X;
             if (-num * num2 <= num4 && num4 <= num2 * (1f + num))
             {
                 num3 /= num2;
                 vec.Normalize();
                 lambda = num3;
                 normal = vec;
                 result = true;
                 return result;
             }
         }
     }
     result = false;
     return result;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:32,代码来源:Segment.cs


示例7: Step

 public override void Step(TimeStep step)
 {
     if (_bodyList == null) return;
     if (useWorldGravity)
     {
         gravity = _world.Gravity;
     }
     for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
     {
         Body body = i.body;
         if (body.IsSleeping())
         {
             //Buoyancy force is just a function of position,
             //so unlike most forces, it is safe to ignore sleeping bodes
             continue;
         }
         Vec2 areac = new Vec2(0, 0);
         Vec2 massc = new Vec2(0, 0);
         float area = 0;
         float mass = 0;
         for (Shape shape = body.GetShapeList(); shape != null; shape = shape.GetNext())
         {
             Vec2 sc;
             float sarea = shape.ComputeSubmergedArea(normal, offset, body.GetXForm(), out sc);
             area += sarea;
             areac.X += sarea * sc.X;
             areac.Y += sarea * sc.Y;
             float shapeDensity = 0;
             if (useDensity)
             {
                 //TODO: Expose density publicly
                 shapeDensity = shape.Density;
             }
             else
             {
                 shapeDensity = 1;
             }
             mass += sarea * shapeDensity;
             massc.X += sarea * sc.X * shapeDensity;
             massc.Y += sarea * sc.Y * shapeDensity;
         }
         areac.X /= area;
         areac.Y /= area;
         massc.X /= mass;
         massc.Y /= mass;
         if (area < Box2DX.Common.Settings.FLT_EPSILON)
             continue;
         //Buoyancy
         Vec2 buoyancyForce = -density * area * gravity;
         body.ApplyForce(buoyancyForce, massc);
         //Linear drag
         Vec2 dragForce = body.GetLinearVelocityFromWorldPoint(areac) - velocity;
         dragForce *= -linearDrag * area;
         body.ApplyForce(dragForce, areac);
         //Angular drag
         //TODO: Something that makes more physical sense?
         body.ApplyTorque(-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * angularDrag);
     }
 }
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:59,代码来源:BuoyancyController.cs


示例8: Initialize

 public void Initialize(Body body1, Body body2, Vec2 anchor)
 {
     this.Body1 = body1;
     this.Body2 = body2;
     this.LocalAnchor1 = body1.GetLocalPoint(anchor);
     this.LocalAnchor2 = body2.GetLocalPoint(anchor);
     this.ReferenceAngle = body2.GetAngle() - body1.GetAngle();
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:RevoluteJointDef.cs


示例9: Initialize

 public void Initialize(Body body1, Body body2, Vec2 anchor, Vec2 axis)
 {
     this.Body1 = body1;
     this.Body2 = body2;
     this.localAnchor1 = body1.GetLocalPoint(anchor);
     this.localAnchor2 = body2.GetLocalPoint(anchor);
     this.localAxis1 = body1.GetLocalVector(axis);
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:LineJointDef.cs


示例10: ReportFixture

        public override float ReportFixture(Fixture fixture, Vec2 point, Vec2 normal, float fraction)
        {
            _fixture = fixture;
            _point = point;
            _normal = normal;

            return fraction;
        }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:8,代码来源:RayCast.cs


示例11: SetTarget

 public void SetTarget(Vec2 target)
 {
     if (this._body2.IsSleeping())
     {
         this._body2.WakeUp();
     }
     this._target = target;
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:MouseJoint.cs


示例12: Initialize

 public void Initialize(Body body1, Body body2, Vec2 anchor1, Vec2 anchor2)
 {
     this.Body1 = body1;
     this.Body2 = body2;
     this.LocalAnchor1 = body1.GetLocalPoint(anchor1);
     this.LocalAnchor2 = body2.GetLocalPoint(anchor2);
     this.Length = (anchor2 - anchor1).Length();
 }
开发者ID:litdev1,项目名称:LitDev,代码行数:8,代码来源:DistanceJointDef.cs


示例13: DrawSegment

 public static void DrawSegment(Vec2 p1, Vec2 p2, Color color, params object[] p)
 {
     Gl.Color3(color.R, color.G, color.B);
                 Gl.Begin(BeginMode.Lines);
                 Gl.Vertex2(p1.X, p1.Y);
                 Gl.Vertex2(p2.X, p2.Y);
                 Gl.End();
 }
开发者ID:vbdetlevvb,项目名称:VBD-Engine,代码行数:8,代码来源:OpenGLDebugDraw.cs


示例14: Initialize

		/// <summary>
		/// Initialize the bodies, anchors, axis, and reference angle using the world
		/// anchor and world axis.
		/// </summary>
		/// <param name="body1"></param>
		/// <param name="body2"></param>
		/// <param name="anchor"></param>
		/// <param name="axis"></param>
		public void Initialize(Body body1, Body body2, Vec2 anchor, Vec2 axis)
		{
			Body1 = body1;
			Body2 = body2;
			LocalAnchor1 = body1.GetLocalPoint(anchor);
			LocalAnchor2 = body2.GetLocalPoint(anchor);
			LocalAxis1 = body1.GetLocalVector(axis);
			ReferenceAngle = body2.GetAngle() - body1.GetAngle();
		}
开发者ID:colgreen,项目名称:box2dx,代码行数:17,代码来源:PrismaticJoint.cs


示例15: DrawPoint

 public static void DrawPoint(Vec2 p, float size, Color 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:rbrother,项目名称:seikkailulaakso,代码行数:9,代码来源:Render.cs


示例16: DrawPoint

 public static void DrawPoint(Vec2 p, float size, Color color)
 {
     Gl.PointSize(size);
                 Gl.Begin(BeginMode.Points);
                 Gl.Color3(color.R, color.G, color.B);
                 Gl.Vertex2(p.X, p.Y);
                 Gl.End();
                 Gl.PointSize(1.0f);
 }
开发者ID:vbdetlevvb,项目名称:VBD-Engine,代码行数:9,代码来源:OpenGLDebugDraw.cs


示例17: Initialize

		/// <summary>
		/// Initialize the bodies, anchors, and length using the world anchors.
		/// </summary>
		public void Initialize(Body body1, Body body2, Vec2 anchor1, Vec2 anchor2)
		{
			Body1 = body1;
			Body2 = body2;
			LocalAnchor1 = body1.GetLocalPoint(anchor1);
			LocalAnchor2 = body2.GetLocalPoint(anchor2);
			Vec2 d = anchor2 - anchor1;
			Length = d.Length();
		}
开发者ID:ajmaya,项目名称:box2dx,代码行数:12,代码来源:DistanceJoint.cs


示例18: DrawPolygon

		public override void DrawPolygon(Vec2[] vertices, int vertexCount, Color 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:colgreen,项目名称:box2dx,代码行数:10,代码来源:Render.cs


示例19: DrawPolygon

 public override void DrawPolygon(Vec2[] vertices, int vertexCount, Color color)
 {
     GL.Color3(color.R, color.G, color.B);
     GL.Disable(EnableCap.Texture2D);
     GL.Begin(BeginMode.LineLoop);
     for (int i = 0; i < vertexCount; ++i) {
         GL.Vertex3(vertices[i].X, vertices[i].Y, ZLayer);
     }
     GL.End();
     GL.Enable(EnableCap.Texture2D);
 }
开发者ID:CloneDeath,项目名称:PokemonSmash,代码行数:11,代码来源:OpenTKDebugDraw.cs


示例20: Solve22

 /// <summary>
 /// Solve A * x = b, where b is a column vector. This is more efficient
 /// than computing the inverse in one-shot cases. Solve only the upper
 /// 2-by-2 matrix equation.
 /// </summary>
 public Vec2 Solve22(Vec2 b)
 {
     float a11 = Col1.X, a12 = Col2.X, a21 = Col1.Y, a22 = Col2.Y;
     float det = a11 * a22 - a12 * a21;
     Box2DXDebug.Assert(det != 0.0f);
     det = 1.0f / det;
     Vec2 x = new Vec2();
     x.X = det * (a22 * b.X - a12 * b.Y);
     x.Y = det * (a11 * b.Y - a21 * b.X);
     return x;
 }
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:16,代码来源:Mat33.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Dynamics.Body类代码示例发布时间:2022-05-24
下一篇:
C# Dynamics.b2World类代码示例发布时间: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