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

C# Geom类代码示例

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

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



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

示例1: sprite

        //use this constructor when you want to add a sprite from the content pipeline
        //sprites should have a pure magenta background for
        //transparency
        public sprite(theGame reference, String contentAssetName,  float width, float height, float X, float Y)
        {
            asset = reference.Content.Load<Texture2D>(contentAssetName);
            spriteOrigin = new Vector2(asset.Width / 2f, asset.Height / 2f);

            this.X = X;
            this.Y = Y;
            this.width = width;
            this.height = height;

            rectangle = new Rectangle((int)this.X, (int)this.Y, (int)width, (int)height);
            this.identity = identity;
            this.reference = reference;

            rectBody = BodyFactory.Instance.CreateRectangleBody(reference.ps, width, height, 1);//PHYSICS
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);//PHYSICS
            rectGeom = GeomFactory.Instance.CreateRectangleGeom(reference.ps,rectBody, this.width, this.height);//PHYSICS
            rectGeom.SetBody(rectBody);
            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollisionCategories = CollisionCategory.All;
            this.rectGeom.CollidesWith = CollisionCategory.All;

            rectBody.Enabled = true;//PHYSICS
            rectGeom.OnSeparation += OnSeperation;
            rectGeom.OnCollision += OnCollision;

            reference.ps.BroadPhaseCollider.OnBroadPhaseCollision += OnBroadPhaseCollision;
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
开发者ID:SeaHarg,项目名称:Snake,代码行数:34,代码来源:sprite.cs


示例2: Table

        public Table(Vector2 position, float width, float height)
        {
            Random rand = new Random();

            _topBody = BodyFactory.Instance.CreateRectangleBody(width, 10, 6);
            _rightLegBody = BodyFactory.Instance.CreateRectangleBody(10, height, 3);
            _leftLegBody = BodyFactory.Instance.CreateRectangleBody(10, height, 3);

            _topGeom = GeomFactory.Instance.CreateRectangleGeom(_topBody, width, 10);
            _rightLegGeom = GeomFactory.Instance.CreateRectangleGeom(_rightLegBody, 10, height);
            _leftLegGeom = GeomFactory.Instance.CreateRectangleGeom(_leftLegBody, 10, height);

            _topBody.Position = position;
            _leftLegBody.Position = new Vector2(position.X - (width / 2) + 10, position.Y + (height / 2) + 5);
            _rightLegBody.Position = new Vector2(position.X + (width / 2) - 10, position.Y + (height / 2) + 5);

            int group = rand.Next(1, 100);

            _rightLegGeom.CollisionGroup = group;
            _leftLegGeom.CollisionGroup = group;
            _topGeom.CollisionGroup = group;

            _rightLegGeom.RestitutionCoefficient = 0;
            _leftLegGeom.RestitutionCoefficient = 0;
            _topGeom.RestitutionCoefficient = 0;

            _height = height;
        }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:28,代码来源:Table.cs


示例3: CalculateIndex

        private int CalculateIndex(Geom geom1, Geom geom2)
        {
            int x;
            int y;
            if (geom1.CollisionId < geom2.CollisionId)
            {
                x = geom1.CollisionId;
                y = geom2.CollisionId;
            }
            else
            {
                x = geom2.CollisionId;
                y = geom1.CollisionId;
            }

            int result = x * _geomCount;
            if (x % 2 == 0)
            {
                result -= ((x + 1) * (x / 2));
            }
            else
            {
                result -= (x + 1) * (x / 2) + (x + 1) / 2;
            }

            result += y - x - 1;

            return result;
        }
开发者ID:elefantstudio-se,项目名称:todesesser,代码行数:29,代码来源:GeomPairBitmap.cs


示例4: Initialize

        public override void Initialize()
        {
            ClearCanvas();
            physicsSimulator = new PhysicsSimulator(new Vector2(0, 100));
            physicsSimulator.BiasFactor = .4f;
            int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
            _border = new Border(ScreenManager.ScreenWidth + borderWidth*2, ScreenManager.ScreenHeight + borderWidth*2,
                                 borderWidth, ScreenManager.ScreenCenter);
            _border.Load(this, physicsSimulator);
            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, 32, 32, 1f);
            _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _rectangleBody, 32, 32);
            _rectangleGeom.FrictionCoefficient = .4f;
            _rectangleGeom.RestitutionCoefficient = 0f;

            //create the pyramid near the bottom of the screen.
            _pyramid = new Pyramid(_rectangleBody, _rectangleGeom, 32f/3f, 32f/3f, 32, 32, _pyramidBaseBodyCount,
                                   new Vector2(ScreenManager.ScreenCenter.X - _pyramidBaseBodyCount*.5f*(32 + 32/3),
                                               ScreenManager.ScreenHeight - 125));
            _pyramid.Load(this, physicsSimulator);

            _floor = new Floor(ScreenManager.ScreenWidth, 100,
                               new Vector2(ScreenManager.ScreenCenter.X, ScreenManager.ScreenHeight - 50));
            _floor.Load(this, physicsSimulator);

            _agent = new Agent(ScreenManager.ScreenCenter - new Vector2(320, 300));
            _agent.Load(this, physicsSimulator);
            controlledBody = _agent.Body;
            base.Initialize();
        }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:29,代码来源:Demo4.cs


示例5: LoadContent

        public override void LoadContent()
        {
            _lineBrush.Load(ScreenManager.GraphicsDevice);

            _rectangleTexture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 32, 32, 2, 0, 0,
                                                                     Color.White, Color.Black);

            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(32, 32, 1f); //template              
            _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(_rectangleBody, 32, 32); //template
            _rectangleGeom.FrictionCoefficient = .4f;
            _rectangleGeom.RestitutionCoefficient = 0f;

            //create the _pyramid near the bottom of the screen.
            _pyramid = new Pyramid(_rectangleBody, _rectangleGeom, 32f / 3f, 32f / 3f, 32, 32, _pyramidBaseBodyCount,
                                   new Vector2(ScreenManager.ScreenCenter.X - _pyramidBaseBodyCount * .5f * (32 + 32 / 3),
                                               ScreenManager.ScreenHeight - 125));

            _pyramid.Load(PhysicsSimulator);

            _floor = new Floor(ScreenManager.ScreenWidth, 100,
                               new Vector2(ScreenManager.ScreenCenter.X, ScreenManager.ScreenHeight - 50));
            _floor.Load(ScreenManager.GraphicsDevice, PhysicsSimulator);

            _agent = new Agent(ScreenManager.ScreenCenter - new Vector2(320, 300));
            _agent.Load(ScreenManager.GraphicsDevice, PhysicsSimulator);

            base.LoadContent();
        }
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:28,代码来源:Demo4Screen.cs


示例6: Vector2

 void ItemBase.InitSelf()
 { 
     X = 200;
     Y = 100;
     body = BodyFactory.Instance.CreateRectangleBody(PhysicsSys.Instance.PhysicsSimulator,100.0f, 100.0f,100.0f);
     body.Position = new Vector2(X, Y);
     geom = GeomFactory.Instance.CreateRectangleGeom(PhysicsSys.Instance.PhysicsSimulator, body, 100, 100);
 }
开发者ID:elefantstudio-se,项目名称:survivaldf,代码行数:8,代码来源:aBox.cs


示例7: load

 public void load(ContentManager Content)
 {
     Vector2 origin;
     texture = Content.Load<Texture2D>(textureName);
     body = BodyFactory.Instance.CreateBody(1f, 1f);
     geom = GeomFactory.Instance.CreateRectangleGeom(body, texture.Width, texture.Height);           
     geom.Tag = _id;
 }
开发者ID:danielselnick,项目名称:Sentry-Smash,代码行数:8,代码来源:gunit.cs


示例8: TestAndSet

        public bool TestAndSet(Geom geom1, Geom geom2)
        {
            int index = CalculateIndex(geom1, geom2);

            bool result = _bitmap[index];
            _bitmap[index] = true;
            return result;
        }
开发者ID:elefantstudio-se,项目名称:todesesser,代码行数:8,代码来源:GeomPairBitmap.cs


示例9: Collide

        /// <summary>
        /// Finds the contactpoints between the two geometries.
        /// </summary>
        /// <param name="geomA">The first geom.</param>
        /// <param name="geomB">The second geom.</param>
        /// <param name="contactList">The contact list.</param>
        public void Collide(Geom geomA, Geom geomB, ContactList contactList)
        {
            int vertexIndex = -1;

            //Lookup distancegrid A data from list
            DistanceGridData geomAGridData = _distanceGrids[geomA.id];

            //Iterate the second geometry vertices
            for (int i = 0; i < geomB.worldVertices.Count; i++)
            {
                if (contactList.Count == PhysicsSimulator.MaxContactsToDetect)
                    break;

                vertexIndex += 1;
                _vertRef = geomB.WorldVertices[i];
                geomA.TransformToLocalCoordinates(ref _vertRef, out _localVertex);

                //The geometry intersects when distance <= 0
                //Continue in the list if the current vector does not intersect
                if (!geomAGridData.Intersect(ref _localVertex, out _feature))
                    continue;

                //If the geometries collide, create a new contact and add it to the contact list.
                if (_feature.Distance < 0f)
                {
                    geomA.TransformNormalToWorld(ref _feature.Normal, out _feature.Normal);
                    Contact contact = new Contact(geomB.WorldVertices[i], _feature.Normal, _feature.Distance,
                                                  new ContactId(1, vertexIndex, 2));
                    contactList.Add(contact);
                }
            }

            //Lookup distancegrid B data from list
            DistanceGridData geomBGridData = _distanceGrids[geomB.id];

            //Iterate the first geometry vertices
            for (int i = 0; i < geomA.WorldVertices.Count; i++)
            {
                if (contactList.Count == PhysicsSimulator.MaxContactsToDetect)
                    break;

                vertexIndex += 1;
                _vertRef = geomA.WorldVertices[i];
                geomB.TransformToLocalCoordinates(ref _vertRef, out _localVertex);

                if (!geomBGridData.Intersect(ref _localVertex, out _feature))
                    continue;

                if (_feature.Distance < 0f)
                {
                    geomB.TransformNormalToWorld(ref _feature.Normal, out _feature.Normal);
                    _feature.Normal = -_feature.Normal;
                    Contact contact = new Contact(geomA.WorldVertices[i], _feature.Normal, _feature.Distance,
                                                  new ContactId(2, vertexIndex, 1));
                    contactList.Add(contact);
                }
            }
        }
开发者ID:rpwjanzen,项目名称:2HourGame,代码行数:64,代码来源:DistanceGrid.cs


示例10: Planet

 public Planet(PhysicsSimulator sim, Texture2D tex, Vector2 pos, float size, float mass)
 {
     body = BodyFactory.Instance.CreateCircleBody(sim, size, mass);
     geometry = GeomFactory.Instance.CreateCircleGeom(body, size, 64);
     body.Position = pos;
     geometry.RestitutionCoefficient = 0.2f;
     geometry.FrictionCoefficient = 0.9f;
     texture = tex;
 }
开发者ID:northdocks,项目名称:ggj-2010-honeymoon,代码行数:9,代码来源:Planet.cs


示例11: EntryEventHandler

 public void EntryEventHandler(Geom geom, Vertices verts)
 {
     for (int i = 0; i < verts.Count; i++)
     {
         Vector2 vel, point = verts[i];
         geom.Body.GetVelocityAtWorldPoint(ref point, out vel);
         WaveController.Disturb(verts[i].X, (vel.Y * geom.Body.Mass) / (100.0f * geom.Body.Mass));
     }
 }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:9,代码来源:WaterModel.cs


示例12: SetSize

        /// <summary>
        /// 重载AnimItem的SetSize方法
        /// 1. 调用基类方法修改scale
        /// 2. 创建或重建物理体 构造尺寸
        /// 注意: 物理体Mass需要通过PhysicsItem.Mass单独设置
        /// </summary>
        public override void SetSize(Vector2 size)
        {
            // 设置图形尺寸
            base.SetSize(size);

            // 创建或重建物理体 
            // 默认取质量10
            body = BodyFactory.Instance.CreateRectangleBody(PhysicsSys.Instance.PhysicsSimulator,Size.X, Size.Y,10);
            geom = GeomFactory.Instance.CreateRectangleGeom(PhysicsSys.Instance.PhysicsSimulator, body, Size.X, Size.Y);
        }
开发者ID:elefantstudio-se,项目名称:survivaldf,代码行数:16,代码来源:PhysicsItem.cs


示例13: oncollision

 protected bool oncollision(Geom geom1, Geom geom2, ContactList contact)
 {
     Iid id1 = (Iid)geom1.Tag;
     Iid id2 = (Iid)geom2.Tag;
     if (id1.UnitID == UnitID.obstacle && id2.UnitID == UnitID.player)
     {
         master.players[id2.NodeID].body.ApplyForce(this.rotationV2 * 4333333);
         master.players[id2.NodeID].addPush(4000f);
     }
     return false;
 }
开发者ID:danielselnick,项目名称:Sentry-Smash,代码行数:11,代码来源:obstacle.cs


示例14: InitSelf

        public void InitSelf()
        {
            X = 200;
            Y = 500;
            rotation=0;
            body = BodyFactory.Instance.CreateRectangleBody(PhysicsSys.Instance.PhysicsSimulator,100.0f, 100.0f,100.0f);
            body.Position = new Vector2(X, Y);
            body.Rotation = 0.1f;
            body.IsStatic = true;//静态

            geom = GeomFactory.Instance.CreateRectangleGeom(PhysicsSys.Instance.PhysicsSimulator, body, 100, 100);
        }
开发者ID:elefantstudio-se,项目名称:survivaldf,代码行数:12,代码来源:sBox.cs


示例15: Pyramid

 public Pyramid(Body referenceBody, Geom referenceGeom, float horizontalSpacing, float verticleSpacing,
     float blockWidth, float blockHeight, int bottomRowBlockCount, Vector2 bottomRightBlockPosition)
 {
     _referenceBody = referenceBody;
     _referenceGeom = referenceGeom;
     _horizontalSpacing = horizontalSpacing;
     _verticleSpacing = verticleSpacing;
     _blockWidth = blockWidth;
     _blockHeight = blockHeight;
     _bottomRowBlockCount = bottomRowBlockCount;
     _bottomRightBlockPosition = bottomRightBlockPosition;
 }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:12,代码来源:Pyramid.cs


示例16: Box

        public Box(PhysicsSimulator pS, Texture2D tex, float x, float y, float width, float heigth, float mass)
        {
            boxTex = tex;
            wdth = width;
            hgth = heigth;
            boxBody = BodyFactory.Instance.CreateRectangleBody(pS, width, heigth, mass);
            boxBody.Position = new Vector2(x, y);
            boxGeom = GeomFactory.Instance.CreateRectangleGeom(pS, boxBody, 0.9f*width, 0.9f*heigth);
            boxGeom.FrictionCoefficient = 0.8f;

            boxOrigin = new Vector2(boxTex.Width / 2, boxTex.Height / 2);
        }
开发者ID:robobot3000,项目名称:Crates,代码行数:12,代码来源:Box.cs


示例17: Collide

        /// <summary>
        /// Returns the contact list from two possibly intersecting Geom's. 
        /// This is the stationary version of this function. It doesn't 
        /// account for linear or angular motion.
        /// </summary>
        /// <param name="geomA">The first Geom.</param>
        /// <param name="geomB">The second Geom.</param>
        /// <param name="contactList">Set of Contacts between the two Geoms.
        /// NOTE- this will be empty if no contacts are present.</param>
        public void Collide(Geom geomA, Geom geomB, ContactList contactList)
        {
            PolygonCollisionResult result = PolygonCollision(geomA.WorldVertices, geomB.WorldVertices, geomB.body.LinearVelocity - geomA.body.LinearVelocity);
            float distance = result.MinimumTranslationVector.Length();
            int contactsDetected = 0;
            Vector2 normal = Vector2.Normalize(-result.MinimumTranslationVector);

            if (result.Intersect)
            {
                for (int i = 0; i < geomA.WorldVertices.Count; i++)
                {
                    if (contactsDetected <= PhysicsSimulator.MaxContactsToDetect)
                    {
                        if (InsidePolygon(geomB.WorldVertices, geomA.WorldVertices[i]))
                        {
                            if (!geomA.Body.IsStatic)
                            {
                                if (distance > 0.001f)
                                {
                                    Contact c = new Contact(geomA.WorldVertices[i], normal, -distance, new ContactId(geomA.id, i, geomB.id));
                                    contactList.Add(c);
                                    contactsDetected++;
                                }
                            }
                        }
                    }
                    else break;
                }

                contactsDetected = 0;

                for (int i = 0; i < geomB.WorldVertices.Count; i++)
                {
                    if (contactsDetected <= PhysicsSimulator.MaxContactsToDetect)
                    {
                        if (InsidePolygon(geomA.WorldVertices, geomB.WorldVertices[i]))
                        {
                            if (!geomB.Body.IsStatic)
                            {
                                if (distance > 0.001f)
                                {
                                    Contact c = new Contact(geomB.WorldVertices[i], normal, -distance, new ContactId(geomB.id, i, geomA.id));
                                    contactList.Add(c);
                                    contactsDetected++;
                                }
                            }
                        }
                    }
                    else break;
                }
            }
        }
开发者ID:rpwjanzen,项目名称:2HourGame,代码行数:61,代码来源:SAT.cs


示例18: Load

        public void Load(SimulatorView view, PhysicsSimulator physicsSimulator)
        {
            //use the body factory to create the physics body
            _platformBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _width, _height, 1);
            view.AddRectangleToCanvas(_platformBody, Colors.White, new Vector2(_width, _height));
            _platformBody.IsStatic = true;
            _platformBody.Position = _position;

            _platformGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _platformBody, _width, _height);
            _platformGeom.CollisionGroup = 100;
            _platformGeom.CollisionGroup = _collisionGroup;
            _platformGeom.FrictionCoefficient = 1;
        }
开发者ID:rbrother,项目名称:seikkailulaakso,代码行数:13,代码来源:RectanglePlatform.cs


示例19: Rectangle

 public Rectangle(PhysicsSimulator pS, Vector2 pos)
 {
     physicsS = pS;
     xSize = 50;
     ySize = 50;
     xSizePrev = xSize;
     ySizePrev = ySize;
     placing = true;
     rBody = BodyFactory.Instance.CreateRectangleBody(pS, 50, 50, 1);
     rBody.IgnoreGravity = true;
     rBody.Position = pos;
     rGeom = GeomFactory.Instance.CreateRectangleGeom(pS, rBody, 50, 50);
 }
开发者ID:robobot3000,项目名称:Crates,代码行数:13,代码来源:Rectangle.cs


示例20: clonegeom

 public static void clonegeom(ref Geom newgeom, ref Geom oldgeom)
 {
     newgeom.Id = Geom.GetNextId();
     newgeom.RestitutionCoefficient = oldgeom.RestitutionCoefficient;
     newgeom.FrictionCoefficient = oldgeom.FrictionCoefficient;
     newgeom.GridCellSize = oldgeom.GridCellSize;
     newgeom.CollisionGroup = oldgeom.CollisionGroup;
     newgeom.CollisionEnabled = oldgeom.CollisionEnabled;
     newgeom.CollisionResponseEnabled = oldgeom.CollisionResponseEnabled;
     newgeom.CollisionCategories = oldgeom.CollisionCategories;
     newgeom.CollidesWith = oldgeom.CollidesWith;
     newgeom.SetVertices(oldgeom.LocalVertices);
     DistanceGrid.Instance.CreateDistanceGrid(newgeom);
 }
开发者ID:danielselnick,项目名称:Sentry-Smash,代码行数:14,代码来源:cloner.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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