本文整理汇总了C#中RigidBody类的典型用法代码示例。如果您正苦于以下问题:C# RigidBody类的具体用法?C# RigidBody怎么用?C# RigidBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RigidBody类属于命名空间,在下文中一共展示了RigidBody类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Caligo
public Caligo (GameState state, AIManager aiManager, RendererContext rendererContext,
CompositorWarpingNode warpingNode)
{
caligoEmitter = new CaligoParticleEmitter ();
particleCaligo = new ParticleSceneObject (caligoEmitter.ParticleCount);
particleCaligo.Priority = 7000;
state.Scene.AddObject (particleCaligo);
caligoEmitter.Init (particleCaligo, rendererContext);
CaligoGameState = state;
CaligoEntity = EntityFactory.Instance.CreateWith ("Caligo." + InstanceCount++, state.MessageProxy,
new[] { typeof (ArtificialIntelligenceComponent) },
new[] { typeof (ParticleSystem), typeof (PhysicsSystem) });
CaligoEntity.GetComponent<ParticleComponent> ().Emitter = caligoEmitter;
CaligoEntity.GetComponent<ParticleComponent> ().Particle = particleCaligo;
RigidBody caligoBody = new RigidBody (new SphereShape (1.2f));
caligoBody.AffectedByGravity = false;
caligoBody.AllowDeactivation = false;
caligoBody.Mass = 20;
CaligoEntity.GetComponent<PhysicsComponent> ().RigidBody = caligoBody;
CaligoEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
CaligoEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;
state.PhysicsManager.World.AddBody (caligoBody);
var AIcomp = CaligoEntity.GetComponent<ArtificialIntelligenceComponent>();
AIcomp.AIManager = aiManager;
AIcomp.ArtificialIntelligence = new CaligoAI (CaligoEntity, state, warpingNode);
aiManager.RegisterEntity (CaligoEntity);
}
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:33,代码来源:Caligo.cs
示例2: objectCollisionOccured
public void objectCollisionOccured(RigidBody rb, string command)
{
cRigidBodyGameObject obj = cPhysics.Instance.getOwnerOf(rb);
if (obj == null)
{
Console.WriteLine("gettin null");
return;
}
if (command == "fire")
{
if (obj.Equals(cPlayer.Instance))
{
if (cPlayer.Instance.State == (int)cPlayer.STATES.DIEING) { return; }
cParticleEngine.Instance.spawnParticleEffect("ObjectDeath", obj.Position, Vector2.Zero);
cPlayer.Instance.respawn();
cPlayer.Instance.LivesRemain = cPlayer.Instance.LivesRemain - 1;
cPostProcessor.Instance.goBrightThenDark(3000);
}
else
{
cParticleEngine.Instance.spawnParticleEffect("ObjectDeath", obj.Position, Vector2.Zero);
cParticleEngine.Instance.spawnParticleEffect("ObjectDeath", obj.Position, Vector2.Zero);
cPhysics.Instance.removeObject(obj);
cScene.Instance.removeSceneObject(obj);
obj = null;
}
}
}
开发者ID:mikecann,项目名称:Portal2D-XNA,代码行数:29,代码来源:cFlameEffect.cs
示例3: LoadContent
protected override void LoadContent()
{
boxModel = Content.Load<Model>("box");
torusModel = Content.Load<Model>("torus");
// Get the vertex information out of the model
List<JVector> positions = new List<JVector>();
List<JOctree.TriangleVertexIndices> indices = new List<JOctree.TriangleVertexIndices>();
ExtractData(positions, indices, torusModel);
// Build an octree of it
JOctree octree = new JOctree(positions, indices);
octree.BuildOctree();
// Pass it to a new instance of the triangleMeshShape
TriangleMeshShape triangleMeshShape = new TriangleMeshShape(octree);
// Create a body, using the triangleMeshShape
RigidBody triangleBody = new RigidBody(triangleMeshShape);
triangleBody.Tag = Color.LightGray;
triangleBody.Position = new JVector(0, 3, 0);
// Add the mesh to the world.
world.AddBody(triangleBody);
base.LoadContent();
}
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:27,代码来源:Game1.cs
示例4: JitterBody
internal JitterBody(RigidBody jitterBody)
: base(null)
{
this.jitterBody = jitterBody;
this.jitterBody.Tag = this;
jitterShape = jitterBody.Shape;
}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:JitterBody.cs
示例5: Passus
public Passus (CompositorColorCorrectionNode colorCorrectionNode,
GameState state, AIManager aiManager, RendererContext rendererContext)
{
passusEmitter = new PassusGhostParticleEmitter ();
PassusGameState = state;
particlePassus = new ParticleSceneObject (passusEmitter.ParticleCount);
particlePassus.Priority = 7001;
state.Scene.AddObject (particlePassus);
passusEmitter.Init (particlePassus, rendererContext);
PassusEntity = EntityFactory.Instance.CreateWith ("Passus." + InstanceCount++, state.MessageProxy,
new[] { typeof (ArtificialIntelligenceComponent) },
new[] { typeof (ParticleSystem), typeof (PhysicsSystem) });
PassusEntity.GetComponent<ParticleComponent> ().Emitter = passusEmitter;
PassusEntity.GetComponent<ParticleComponent> ().Particle = particlePassus;
RigidBody passusBody = new RigidBody (new SphereShape (1.2f));
passusBody.AffectedByGravity = false;
passusBody.AllowDeactivation = false;
passusBody.Mass = 20;
PassusEntity.GetComponent<PhysicsComponent> ().RigidBody = passusBody;
PassusEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
PassusEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;
state.PhysicsManager.World.AddBody (passusBody);
var AIcomp = PassusEntity.GetComponent<ArtificialIntelligenceComponent>();
AIcomp.AIManager = aiManager;
AIcomp.ArtificialIntelligence = new PassusAI (PassusEntity, state, colorCorrectionNode);
aiManager.RegisterEntity (PassusEntity);
}
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:34,代码来源:Passus.cs
示例6: cRigidBodyGameObject
public cRigidBodyGameObject(float mass, Vertices v)
{
_rigidBody = new PolygonRigidBody(mass, v);
cPhysics.Instance.addObject(this);
_canAttachPortalTo = false;
_portaling = false;
}
开发者ID:mikecann,项目名称:Portal2D-XNA,代码行数:7,代码来源:cRigidBodyGameObject.cs
示例7: CanJump
public bool CanJump(RigidBody body)
{
Body = WorldItems[body];
Jitter.Dynamics.RigidBody resultingBody = null;
JVector normal;
float fraction;
var positions = new JVector[] { new JVector(body.Position.X, body.Position.Y, body.Position.Z),
new JVector(body.Position.X + 0.5f, body.Position.Y, body.Position.Z),
new JVector(body.Position.X - 0.5f, body.Position.Y, body.Position.Z),
new JVector(body.Position.X, body.Position.Y, body.Position.Z - 0.5f),
new JVector(body.Position.X, body.Position.Y, body.Position.Z + 0.5f)};
for (int i = 0; i < positions.Length; i++)
{
bool result = World.CollisionSystem.Raycast(new JVector(positions[i].X, positions[i].Y, positions[i].Z),
new JVector(0, -1, 0),
RaycastCallback,
out resultingBody,
out normal,
out fraction);
if (result && fraction <= 1.3f && Body.LinearVelocity.Y < 0.5f)
{
return true;
}
}
return false;
}
开发者ID:JohanGl,项目名称:Outworld-XNA,代码行数:31,代码来源:CollisionSystem.cs
示例8: Build
public override void Build()
{
AddGround();
for (int i = 0; i < 30; i++)
{
for (int e = i; e < 30; e++)
{
RigidBody body = new RigidBody(new BoxShape(new JVector(1.0f, 1.0f, 1.0f)));
body.Position = new JVector((e - i * 0.5f) * 1.01f + 7, 0.5f + i * 1.0f, 3.0f);
Demo.World.AddBody(body);
//body.IsParticle = true;
//body.AffectedByGravity = false;
body.Material.Restitution = 0.0f;
}
}
//BoxShape shape = new BoxShape(JVector.One);
//for (int i = 0; i < 20; i++)
//{
// for (int e = 0; e < 20; e++)
// {
// for (int k = 0; k < 20; k++)
// {
// RigidBody b = new RigidBody(shape);
// Demo.World.AddBody(b);
// b.Position = new JVector(i, e, k) * 2.0f;
// b.AffectedByGravity = false;
// }
// }
//}
}
开发者ID:reidyd,项目名称:jitterphysics,代码行数:33,代码来源:Pyramid.cs
示例9: HNode
public HNode(HNode parent, BoundingSphere volume, RigidBody body = null)
{
Parent = parent;
Volume = volume;
Body = body;
Children = new HNode[2];
}
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:7,代码来源:HNode.cs
示例10: CollisionDetectedMessage
public CollisionDetectedMessage (RigidBody body1, RigidBody body2)
{
Body1 = body1;
Body2 = body2;
MessageId = (int) FreezingArcher.Messaging.MessageId.CollisionDetected;
}
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:7,代码来源:CollisionDetectedMessage.cs
示例11: Build
public override void Build()
{
AddGround();
for (int i = 0; i < 11; i++)
{
RigidBody box = new RigidBody(new BoxShape(1,0.01f,1));
this.Demo.World.AddBody(box);
JVector boxPos = new JVector(-15 + i * 3 + 1, 5, 0);
box.Position = boxPos;
box.IsStatic = true;
RigidBody sphere = new RigidBody(new SphereShape(0.5f));
this.Demo.World.AddBody(sphere);
sphere.Position = boxPos + JVector.Up * 30;
sphere.EnableSpeculativeContacts = true;
// set restitution
sphere.Material.Restitution = box.Material.Restitution = 1.0f / 10.0f * i;
sphere.LinearVelocity = new JVector(0, 0, 0);
sphere.Damping = RigidBody.DampingType.Angular;
}
}
开发者ID:RainsSoft,项目名称:jitterphysics,代码行数:29,代码来源:Restitution.cs
示例12: BlockObject
public BlockObject(PrehenderGame bbg,Vector3 pLocation, Vector3 pSize, Vector3 pVelocity)
{
_Location = pLocation;
_Size = pSize;
_Velocity = pVelocity;
FaceTextures = new Dictionary<BlockFaceConstants, string>(){
{BlockFaceConstants.Front, "Generic_1"},
{BlockFaceConstants.Back, "Generic_2"},
{BlockFaceConstants.Top, "Generic_3"},
{BlockFaceConstants.Bottom,"Generic_4"},
{BlockFaceConstants.Left,"Invincible"},
{BlockFaceConstants.Right,"Strong1"}};
foreach (var iterate in Enum.GetValues(typeof(BlockFaceConstants)))
{
FaceColors.Add((BlockFaceConstants)iterate, Color.FromArgb(128,Color.White));
}
foreach (var iterate in Enum.GetValues(typeof(BlockFaceConstants)))
{
ActiveFaceColors.Add((BlockFaceConstants)iterate, Color.FromArgb(128, Color.Orange));
}
BlockBody = new RigidBody(new BoxShape(_Size.X, _Size.Y, _Size.Z));
BlockBody.AffectedByGravity = false;
BlockBody.IsStatic = true;
BlockBody.Mass = 5;
BlockBody.Tag = this;
BlockBody.Position = new JVector(_Location.X, _Location.Y, _Location.Z);
//bbg.PhysicsWorld.AddBody(BlockBody);
}
开发者ID:BCProgramming,项目名称:Prehender,代码行数:30,代码来源:BlockObject.cs
示例13: Build
public override void Build()
{
model = Demo.Content.Load<Model>("staticmesh");
boneTransforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(boneTransforms);
List<TriangleVertexIndices> indices = new List<TriangleVertexIndices>();
List<Vector3> vertices = new List<Vector3>();
ExtractData(vertices, indices, model);
List<JVector> jvertices = new List<JVector>(vertices.Count);
foreach(Vector3 vertex in vertices) jvertices.Add(Conversion.ToJitterVector(vertex));
Octree octree = new Octree(jvertices, indices);
TriangleMeshShape tms = new TriangleMeshShape(octree);
RigidBody body = new RigidBody(tms);
body.IsStatic = true;
//body.EnableDebugDraw = true;
body.Tag = BodyTag.DontDrawMe;
Demo.World.AddBody(body);
AddCar(new JVector(-20, 20, 0));
}
开发者ID:reidyd,项目名称:jitterphysics,代码行数:26,代码来源:TriangleMesh.cs
示例14: Build
public override void Build()
{
AddGround();
for (int i = 0; i < 15; i++)
{
bool even = (i % 2 == 0);
for (int e = 0; e < 3; e++)
{
JVector size = (even) ? new JVector(1, 1, 3) : new JVector(3, 1, 1);
RigidBody body = new RigidBody(new BoxShape(size));
body.Position = new JVector(3.0f + (even ? e : 1.0f), i + 0.5f,-13.0f + (even ? 1.0f : e));
Demo.World.AddBody(body);
}
}
//BoxShape bs = new BoxShape(10, 10, 0.01f);
//RigidBody bb = new RigidBody(bs);
//bb.Position = new JVector(10, 5, 0);
//Demo.World.AddBody(bb);
//bb.IsStatic = true;
}
开发者ID:reignstudios,项目名称:jitterphysics,代码行数:28,代码来源:Jenga.cs
示例15: TraceResult
public TraceResult(RigidBody body, float distance, JVector position, JVector normal)
{
this.Body = body;
this.Distance = distance;
this.Position = position;
this.Normal = normal;
}
开发者ID:MasterQ32,项目名称:BlocksWorld,代码行数:7,代码来源:TraceResult.cs
示例16: BuildScene
private void BuildScene()
{
// creating two boxShapes with different sizes
Shape boxShape = new BoxShape(JVector.One);
Shape groundShape = new BoxShape(new JVector(10, 1, 10));
// create new instances of the rigid body class and pass
// the boxShapes to them
RigidBody boxBody1 = new RigidBody(boxShape);
RigidBody boxBody2 = new RigidBody(boxShape);
boxBody1.Tag = Color.LightPink;
boxBody2.Tag = Color.LightSkyBlue;
RigidBody groundBody = new RigidBody(groundShape);
groundBody.Tag = Color.LightGreen;
// set the position of the box size=(1,1,1)
// 2 and 5 units above the ground box size=(10,1,10)
boxBody1.Position = new JVector(0, 2, 0.0f);
boxBody2.Position = new JVector(0, 5, 0.2f);
// make the body static, so it can't be moved
groundBody.IsStatic = true;
// add the bodies to the world.
world.AddBody(boxBody1);
world.AddBody(boxBody2);
world.AddBody(groundBody);
}
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:31,代码来源:Game1.cs
示例17: AddGround
//protected CarObject car = null;
public void AddGround(bool solid)
{
if (solid)
{
ground = new RigidBody(new BoxShape(3600, 1f));
//ground.SetMassProperties(float.MaxValue, float.MaxValue, false);
ground.Position = new JVector(0, 0);
ground.IsStatic = true;
Demo.World.AddBody(ground);
ground.Material.DynamicFriction = 1.0f;
ground.Material.StaticFriction = 1.0f;
ground.Material.Restitution = 0.0f;
}
else
{
List<JVector> groundLine = new List<JVector> { new JVector(-40f, 0f), new JVector(40f, 0f) };
ground = new RigidBody(new BoxShape(new JVector(1.0f, 1.0f)));
ground.Position = new JVector(0, -10);
ground.Orientation = 0;
ground.IsStatic = true;
ground.SetMassProperties(float.MaxValue, float.MaxValue, false);
Demo.World.AddBody(ground);
ground.Material.DynamicFriction = 1.0f;
ground.Material.Restitution = 0.0f;
}
}
开发者ID:reidyd,项目名称:jitterphysics,代码行数:28,代码来源:Scene.cs
示例18: PointOnPoint
/// <summary>
/// Initializes a new instance of the DistanceConstraint class.
/// </summary>
/// <param name="body1">The first body.</param>
/// <param name="body2">The second body.</param>
/// <param name="anchor1">The anchor point of the first body in world space.
/// The distance is given by the initial distance between both anchor points.</param>
/// <param name="anchor2">The anchor point of the second body in world space.
/// The distance is given by the initial distance between both anchor points.</param>
public PointOnPoint(RigidBody body, JVector localAnchor)
: base(body, null)
{
localAnchor1 = localAnchor;
this.anchor = body.position + JVector.Transform(localAnchor, body.orientation);
}
开发者ID:BenjaminMoore,项目名称:JPhysics,代码行数:16,代码来源:PointOnPoint.cs
示例19: Roaches
public Roaches (GameState state, AIManager aiManager, RendererContext rendererContext)
{
RoachGameState = state;
roachGroup = new RoachGroup (state.Scene);
RoachEntity = EntityFactory.Instance.CreateWith("Roach." + InstanceCount++, state.MessageProxy,
new[] { typeof (ArtificialIntelligenceComponent) },
new[] { typeof (PhysicsSystem), typeof (RoachGroupSystem) });
RoachEntity.GetComponent<RoachGroupComponent>().RoachGroup = roachGroup;
RigidBody roachBody = new RigidBody (new CylinderShape (0.05f, 1));
roachBody.AffectedByGravity = false;
roachBody.AllowDeactivation = false;
roachBody.Mass = 20;
roachBody.Tag = roachGroup;
RoachEntity.GetComponent<PhysicsComponent> ().RigidBody = roachBody;
RoachEntity.GetComponent<PhysicsComponent> ().World = state.PhysicsManager.World;
RoachEntity.GetComponent<PhysicsComponent> ().PhysicsApplying = AffectedByPhysics.Position;
state.PhysicsManager.World.AddBody (roachBody);
RoachEntity.GetComponent<ArtificialIntelligenceComponent>().AIManager = aiManager;
RoachEntity.GetComponent<ArtificialIntelligenceComponent>().ArtificialIntelligence =
new RoachesAI (roachGroup, RoachEntity, state);
aiManager.RegisterEntity (RoachEntity);
}
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:28,代码来源:Roaches.cs
示例20: RigidBodyMassFrame
public RigidBodyMassFrame(RigidBody rigidBody)
{
_rigidBody = rigidBody;
var defaultMassFrameDescriptor = new MassFrameDescriptor();
defaultMassFrameDescriptor.ToDefault();
Descriptor = defaultMassFrameDescriptor;
}
开发者ID:sandygk,项目名称:System.Physics,代码行数:7,代码来源:RigidBodyMassFrame.cs
注:本文中的RigidBody类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论