本文整理汇总了C#中RigidBody类的典型用法代码示例。如果您正苦于以下问题:C# RigidBody类的具体用法?C# RigidBody怎么用?C# RigidBody使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RigidBody类属于命名空间,在下文中一共展示了RigidBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
}
}
示例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();
}
示例4: JitterBody
internal JitterBody(RigidBody jitterBody)
: base(null)
{
this.jitterBody = jitterBody;
this.jitterBody.Tag = this;
jitterShape = jitterBody.Shape;
}
示例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);
}
示例6: cRigidBodyGameObject
public cRigidBodyGameObject(float mass, Vertices v)
{
_rigidBody = new PolygonRigidBody(mass, v);
cPhysics.Instance.addObject(this);
_canAttachPortalTo = false;
_portaling = false;
}
示例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;
}
示例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;
// }
// }
//}
}
示例9: HNode
public HNode(HNode parent, BoundingSphere volume, RigidBody body = null)
{
Parent = parent;
Volume = volume;
Body = body;
Children = new HNode[2];
}
示例10: CollisionDetectedMessage
public CollisionDetectedMessage (RigidBody body1, RigidBody body2)
{
Body1 = body1;
Body2 = body2;
MessageId = (int) FreezingArcher.Messaging.MessageId.CollisionDetected;
}
示例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;
}
}
示例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);
}
示例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));
}
示例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;
}
示例15: TraceResult
public TraceResult(RigidBody body, float distance, JVector position, JVector normal)
{
this.Body = body;
this.Distance = distance;
this.Position = position;
this.Normal = normal;
}