本文整理汇总了C#中Geom类的典型用法代码示例。如果您正苦于以下问题:C# Geom类的具体用法?C# Geom怎么用?C# Geom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Geom类属于命名空间,在下文中一共展示了Geom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例8: TestAndSet
public bool TestAndSet(Geom geom1, Geom geom2)
{
int index = CalculateIndex(geom1, geom2);
bool result = _bitmap[index];
_bitmap[index] = true;
return result;
}
示例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);
}
}
}
示例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;
}
示例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));
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}