本文整理汇总了C#中DemosGame类的典型用法代码示例。如果您正苦于以下问题:C# DemosGame类的具体用法?C# DemosGame怎么用?C# DemosGame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DemosGame类属于命名空间,在下文中一共展示了DemosGame类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MoreConstraintsTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public MoreConstraintsTestDemo(DemosGame game)
: base(game)
{
Box boxA = new Box(new Vector3(0, 5, 0), 1, 2, 1, 10);
Box boxB = new Box(new Vector3(0, 8, 0), 1, 2, 1, 10);
boxA.Orientation = Quaternion.CreateFromYawPitchRoll(0, MathHelper.PiOver4, 0);
boxB.Orientation = Quaternion.CreateFromYawPitchRoll(MathHelper.PiOver4, 0, 0);
WeldJoint weld = new WeldJoint(boxA, boxB);
Space.Add(boxA);
Space.Add(boxB);
Space.Add(weld);
boxA = new Box(new Vector3(3, 5, 0), 1, 2, 1, 10);
boxB = new Box(new Vector3(3, 8, 0), 1, 2, 1, 10);
boxA.Orientation = Quaternion.CreateFromYawPitchRoll(0, MathHelper.PiOver4, 0);
boxB.Orientation = Quaternion.CreateFromYawPitchRoll(MathHelper.PiOver4, 0, 0);
BallSocketJoint ballSocket = new BallSocketJoint(boxA, boxB, (boxA.Position + boxB.Position) / 2);
AngularMotor angularMotor = new AngularMotor(boxA, boxB);
angularMotor.Settings.Mode = MotorMode.Servomechanism;
Space.Add(boxA);
Space.Add(boxB);
Space.Add(ballSocket);
Space.Add(angularMotor);
Box ground = new Box(new Vector3(0, 0, 0), 10, 1, 10);
Space.Add(ground);
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:Raverenx,项目名称:GameEngine,代码行数:38,代码来源:MoreConstraintsTestDemo.cs
示例2: PlanetDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public PlanetDemo(DemosGame game)
: base(game)
{
Space.ForceUpdater.Gravity = Vector3.Zero;
//By pre-allocating a bunch of box-box pair handlers, the simulation will avoid having to allocate new ones at runtime.
NarrowPhaseHelper.Factories.BoxBox.EnsureCount(1000);
var planet = new Sphere(new Vector3(0, 0, 0), 30);
Space.Add(planet);
var field = new GravitationalField(new InfiniteForceFieldShape(), planet.Position, 66730 / 2f, 100);
Space.Add(field);
//Drop the "meteorites" on the planet.
Entity toAdd;
int numColumns = 10;
int numRows = 10;
int numHigh = 10;
float separation = 5;
for (int i = 0; i < numRows; i++)
for (int j = 0; j < numColumns; j++)
for (int k = 0; k < numHigh; k++)
{
toAdd = new Box(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1f, 1f, 1f, 5);
toAdd.LinearVelocity = new Vector3(30, 0, 0);
toAdd.LinearDamping = 0;
toAdd.AngularDamping = 0;
Space.Add(toAdd);
}
game.Camera.Position = new Vector3(0, 0, 150);
}
开发者ID:gpforde,项目名称:GPBrakes,代码行数:36,代码来源:PlanetDemo.cs
示例3: TwistTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public TwistTestDemo(DemosGame game)
: base(game)
{
var a = new Box(new Vector3(-2, 2, 0), 1, 2, 2, 5);
var b = new Box(new Vector3(2, 2, 0), 1, 2, 2, 5);
b.Orientation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.PiOver4);
Space.Add(a);
Space.Add(b);
var twistJoint = new TwistJoint(a, b, a.OrientationMatrix.Right, b.OrientationMatrix.Right);
var twistMotor = new TwistMotor(a, b, a.OrientationMatrix.Right, b.OrientationMatrix.Right);
twistMotor.Settings.Mode = MotorMode.Servomechanism;
//Space.Add(twistJoint);
Space.Add(twistMotor);
var ballSocketJoint = new BallSocketJoint(a, b, (a.Position + b.Position) * 0.5f);
var swingLimit = new SwingLimit(a, b, a.OrientationMatrix.Right, a.OrientationMatrix.Right, MathHelper.PiOver2);
Space.Add(ballSocketJoint);
Space.Add(swingLimit);
Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
Space.Add(ground);
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:30,代码来源:TwistTestDemo.cs
示例4: Demo
protected Demo(DemosGame game)
{
Game = game;
parallelLooper = new ParallelLooper();
//This section lets the engine know that it can make use of multithreaded systems
//by adding threads to its thread pool.
#if XBOX360
parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 1 }); });
parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 3 }); });
parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 4 }); });
parallelLooper.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 5 }); });
#else
if (Environment.ProcessorCount > 1)
{
for (int i = 0; i < Environment.ProcessorCount; i++)
{
parallelLooper.AddThread();
}
}
#endif
Space = new Space(parallelLooper);
game.Camera.LockedUp = Vector3.Up;
game.Camera.ViewDirection = new Vector3(0, 0, -1);
}
开发者ID:karrtmomil,项目名称:coms437_assignment2,代码行数:27,代码来源:Demo.cs
示例5: RayCastTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public RayCastTestDemo(DemosGame game)
: base(game)
{
Space.Add(new Box(new Vector3(0, -0.5f, 0), 50, 1, 50));
//Put whatever you'd like to ray cast here.
var capsule = new Capsule(new Vector3(0, 1.2f, 0), 1, 0.6f);
capsule.AngularVelocity = new Vector3(1, 1, 1);
Space.Add(capsule);
var cylinder = new Cylinder(new Vector3(0, 5, 0), 2, .5f);
cylinder.AngularVelocity = new Vector3(1, -1, 1);
Space.Add(cylinder);
var points = new List<Vector3>();
var random = new Random(0);
for (int k = 0; k < 40; k++)
{
points.Add(new Vector3(1 * (float)random.NextDouble(), 3 * (float)random.NextDouble(), 2 * (float)random.NextDouble()));
}
var convexHull = new ConvexHull(new Vector3(0, 10, 0), points);
convexHull.AngularVelocity = new Vector3(-1, 1, 1);
Space.Add(convexHull);
game.Camera.Position = new Vector3(-10, 5, 10);
game.Camera.Yaw((float)Math.PI / -4f);
game.Camera.Pitch(-(float)Math.PI / 9f);
//Starter ray.
origin = new Vector3(10, 5, 0);
direction = new Vector3(-3, -1, 0);
}
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:39,代码来源:RayCastTestDemo.cs
示例6: WallDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public WallDemo(DemosGame game)
: base(game)
{
int width = 10;
int height = 10;
float blockWidth = 2f;
float blockHeight = 1f;
float blockLength = 1f;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
var toAdd =
new Box(
new Vector3(
i * blockWidth + .5f * blockWidth * (j % 2) - width * blockWidth * .5f,
blockHeight * .5f + j * (blockHeight),
0),
blockWidth, blockHeight, blockLength, 10);
Space.Add(toAdd);
}
}
Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
Space.Add(ground);
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:32,代码来源:WallDemo.cs
示例7: MultithreadedScalingTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public MultithreadedScalingTestDemo(DemosGame game)
: base(game)
{
simulationBuilders = new Func<Space, int>[]
{
BuildPileSimulation,
BuildWallSimulation,
BuildPlanetSimulation
};
#if WINDOWS
int coreCountMax = Environment.ProcessorCount;
testResults = new double[coreCountMax, simulationBuilders.Length];
int reruns = 1;
for (int i = 0; i < reruns; i++)
{
GC.Collect();
var threadManager = new SpecializedThreadManager();
//Try different thread counts.
for (int j = 0; j < coreCountMax; j++)
{
threadManager.AddThread();
for (int k = 0; k < simulationBuilders.Length; k++)
testResults[j, k] = RunTest(threadManager, simulationBuilders[k]);
GC.Collect();
}
}
#else
testResults = new double[4, simulationBuilders.Length];
int reruns = 10;
for (int i = 0; i < reruns; i++)
{
GC.Collect();
var threadManager = new SpecializedThreadManager();
threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 1 }); }, null);
for (int k = 0; k < simulationBuilders.Length; k++)
testResults[0, k] += RunTest(threadManager, simulationBuilders[k]);
GC.Collect();
threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 3 }); }, null);
for (int k = 0; k < simulationBuilders.Length; k++)
testResults[1, k] += RunTest(threadManager, simulationBuilders[k]);
GC.Collect();
threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 5 }); }, null);
for (int k = 0; k < simulationBuilders.Length; k++)
testResults[2, k] += RunTest(threadManager, simulationBuilders[k]);
GC.Collect();
threadManager.AddThread(delegate { Thread.CurrentThread.SetProcessorAffinity(new[] { 4 }); }, null);
for (int k = 0; k < simulationBuilders.Length; k++)
testResults[3, k] += RunTest(threadManager, simulationBuilders[k]);
GC.Collect();
}
#endif
}
开发者ID:gpforde,项目名称:GPBrakes,代码行数:64,代码来源:MultithreadedScalingTestDemo.cs
示例8: ColosseumDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public ColosseumDemo(DemosGame game)
: base(game)
{
double angle;
int numBoxesPerRing = 12;
float blockWidth = 2;
float blockHeight = 2;
float blockLength = 6f;
float radius = 15;
Entity toAdd;
Space.Add(new Box(new Vector3(0, -blockHeight / 2 - 1, 0), 100, 2f, 100));
double increment = MathHelper.TwoPi / numBoxesPerRing;
for (int i = 0; i < 8; i++)
{
for (int k = 0; k < numBoxesPerRing; k++)
{
if (i % 2 == 0)
{
angle = k * increment;
toAdd = new Box(new Vector3(-(float) Math.Cos(angle) * radius, i * blockHeight, (float) Math.Sin(angle) * radius), blockWidth, blockHeight, blockLength, 20);
toAdd.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float) angle);
Space.Add(toAdd);
}
else
{
angle = (k + .5f) * increment;
toAdd = new Box(new Vector3(-(float)Math.Cos(angle) * radius, i * blockHeight, (float)Math.Sin(angle) * radius), blockWidth, blockHeight, blockLength, 20);
toAdd.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float) angle);
Space.Add(toAdd);
}
}
}
game.Camera.Position = new Vector3(0, 2, 2);
}
开发者ID:gpforde,项目名称:GPBrakes,代码行数:38,代码来源:ColosseumDemo.cs
示例9: FishInABarrelDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public FishInABarrelDemo(DemosGame game)
: base(game)
{
game.Camera.Position = new Vector3(0, 7, 30);
var detector = new Box(new Vector3(0, 0, 0), 1.5f, 1.5f, 1.5f);
detector.CollisionInformation.CollisionRules.Personal = CollisionRule.NoSolver;
var acceptedTriggerEntity = new Box(new Vector3(5, 0, 0), 1.6f, .7f, .4f, 1);
acceptedTrigger = acceptedTriggerEntity.CollisionInformation;
detector.Tag = "noDisplayObject";
acceptedTriggerEntity.Tag = "noDisplayObject";
Space.Add(detector);
Space.Add(acceptedTriggerEntity);
var fish = game.Content.Load<Model>("fish");
game.ModelDrawer.Add(new DisplayEntityModel(acceptedTriggerEntity, fish, game.ModelDrawer));
var barrelAndPlatform = game.Content.Load<Model>("barrelAndPlatform");
Vector3[] staticTriangleVertices;
int[] staticTriangleIndices;
ModelDataExtractor.GetVerticesAndIndicesFromModel(barrelAndPlatform, out staticTriangleVertices, out staticTriangleIndices);
//Note that the final 'margin' parameter is optional, but can be used to specify a collision margin on triangles in the static triangle group.
var fishDepositoryGroup = new StaticMesh(staticTriangleVertices, staticTriangleIndices);
CollisionRules.AddRule(fishDepositoryGroup, detector, CollisionRule.NoBroadPhase);
Space.Add(fishDepositoryGroup);
game.ModelDrawer.Add(fishDepositoryGroup);
movedBox = new Box(new Vector3(-4, 5, 0), 1, 1, 1, 1);
detector.Space.Add(movedBox);
detector.CollisionInformation.Events.InitialCollisionDetected += InitialCollisionDetected;
detector.CollisionInformation.Events.CollisionEnded += CollisionEnded;
}
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:38,代码来源:FishInABarrelDemo.cs
示例10: GeneralConvexPairStressDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public GeneralConvexPairStressDemo(DemosGame game)
: base(game)
{
Space.Remove(vehicle.Vehicle);
//Enable simplex caching.
ConfigurationHelper.ApplySuperSpeedySettings(Space);
for (int i = 0; i < 2000; i++)
{
EntityShape shape;
switch (i % 3)
{
case 0:
shape = new CylinderShape(0.5f + (float)random.NextDouble() * 1.5f, 0.5f + (float)random.NextDouble() * 1.5f);
break;
case 1:
shape = new ConeShape(0.5f + (float)random.NextDouble() * 1.5f, 0.5f + (float)random.NextDouble() * 1.5f);
break;
default:
shape = new CapsuleShape(0.5f + (float)random.NextDouble() * 1.5f, 0.5f + (float)random.NextDouble() * 1.5f);
break;
}
var toAdd = new Entity(shape, 2);
//toAdd.LocalInertiaTensorInverse = new BEPUutilities.Matrix3x3();
RandomizeEntityState(toAdd);
Space.Add(toAdd);
}
Space.ForceUpdater.Gravity = new Vector3();
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:38,代码来源:GeneralConvexPairStressDemo.cs
示例11: BroadPhaseDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public BroadPhaseDemo(DemosGame game)
: base(game)
{
//Make a fatter kapow sphere.
Space.Remove(kapow);
kapow = new Sphere(new Vector3(11000, 0, 0), 1.5f, 1000);
Space.Add(kapow);
Space.Solver.IterationLimit = 1; //Essentially no sustained contacts, so don't need to worry about accuracy.
Space.ForceUpdater.Gravity = Vector3.Zero;
int numColumns = 15;
int numRows = 15;
int numHigh = 15;
float separation = 3;
Entity toAdd;
for (int i = 0; i < numRows; i++)
for (int j = 0; j < numColumns; j++)
for (int k = 0; k < numHigh; k++)
{
toAdd = new Box(new Vector3(separation * i, k * separation, separation * j), 1, 1, 1, 1);
toAdd.Material.Bounciness = 1; //Superbouncy boxes help propagate shock waves.
toAdd.LinearDamping = 0f;
toAdd.AngularDamping = 0f;
Space.Add(toAdd);
}
game.Camera.Position = new Vector3(0, 3, -10);
game.Camera.ViewDirection = new Vector3(0, 0, 1);
}
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:35,代码来源:BroadPhaseDemo.cs
示例12: BoxBoxTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public BoxBoxTestDemo(DemosGame game)
: base(game)
{
//float blockWidth = 2;
//float blockHeight = 2;
//float blockLength = 6f;
//Entity toAdd;
//toAdd = new Box(new Vector3(0, 2,0), blockWidth, blockHeight, blockLength, 20);
//toAdd.ActivityInformation.IsAlwaysActive = true;
//toAdd.AllowStabilization = false;
//Space.Add(toAdd);
int numColumns = 3;
int numRows = 3;
int numHigh = 30;
float xSpacing = 1.01f;
float ySpacing = 1.01f;
float zSpacing = 1.01f;
for (int i = 0; i < numRows; i++)
for (int j = 0; j < numColumns; j++)
for (int k = 0; k < numHigh; k++)
{
Space.Add(new Box(new Vector3(
xSpacing * i - (numRows - 1) * xSpacing / 2f,
1f + k * (ySpacing),
zSpacing * j - (numColumns - 1) * zSpacing / 2f),
.5f, .5f, .5f, 5));
}
Space.Add(new Box(new Vector3(0, 0, 0), 20, 1f, 20));
game.Camera.Position = new Vector3(0, 3, 10);
}
开发者ID:gpforde,项目名称:GPBrakes,代码行数:37,代码来源:BoxBoxTestDemo.cs
示例13: IncomingDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public IncomingDemo(DemosGame game)
: base(game)
{
Entity toAdd;
//Build the stack...
for (int k = 1; k <= 12; k++)
{
if (k % 2 == 1)
{
toAdd = new Box(new Vector3(-3, k, 0), 1, 1, 7, 10);
Space.Add(toAdd);
toAdd = new Box(new Vector3(3, k, 0), 1, 1, 7, 10);
Space.Add(toAdd);
}
else
{
toAdd = new Box(new Vector3(0, k, -3), 7, 1, 1, 10);
Space.Add(toAdd);
toAdd = new Box(new Vector3(0, k, 3), 7, 1, 1, 10);
Space.Add(toAdd);
}
}
//And then smash it!
toAdd = new Sphere(new Vector3(0, 150, 0), 3, 100);
Space.Add(toAdd);
Space.Add(new Box(new Vector3(0, 0, 0), 10, 1f, 10));
game.Camera.Position = new Vector3(0, 6, 30);
}
开发者ID:gpforde,项目名称:GPBrakes,代码行数:33,代码来源:IncomingDemo.cs
示例14: ConvexHullTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public ConvexHullTestDemo(DemosGame game)
: base(game)
{
var random = new Random(5);
for (int i = 0; i < 500000; ++i)
{
List<Vector3> points = new List<Vector3>();
for (int k = 0; k < random.Next(8, 60); k++)
{
points.Add(new Vector3(-100 + 30 * (float)random.NextDouble(), 100 + 500 * (float)random.NextDouble(), 100 + 30 * (float)random.NextDouble()));
}
var convexHull = new ConvexHull(new Vector3(0, 7, 0), points, 10);
Console.WriteLine(convexHull.CollisionInformation.Shape.Vertices.Count);
}
var vertices = new[]
{
new Vector3(0, -1.750886E-9f, -1.5f),
new Vector3(1, 1, 0.5f),
new Vector3(1, -1, 0.5f),
new Vector3(-1, 1, 0.5f),
new Vector3(-1, -1, 0.5f),
};
var hullVertices = new RawList<Vector3>();
ConvexHullHelper.GetConvexHull(vertices, hullVertices);
ConvexHull hull = new ConvexHull(vertices, 5);
Space.Add(hull);
Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
Space.Add(ground);
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:39,代码来源:ConvexHullTestDemo.cs
示例15: AddRemoveStressDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public AddRemoveStressDemo(DemosGame game)
: base(game)
{
NarrowPhaseHelper.Factories.BoxBox.EnsureCount(5000);
NarrowPhaseHelper.Factories.CompoundCompound.EnsureCount(5000);
Space.Remove(vehicle.Vehicle);
for (int i = 0; i < 1000; i++)
{
var position = new Vector3(
(float)(random.NextDouble() - 0.5) * width,
(float)(random.NextDouble() - 0.5) * height,
(float)(random.NextDouble() - 0.5) * length);
var toAdd =
new CompoundBody(new List<CompoundShapeEntry>
{
new CompoundShapeEntry(new BoxShape(1,1,1), position, 1)
}, 10);
//var toAdd = new Box(position, 1, 1, 1, 1);
toAdd.IsAffectedByGravity = false;
toAdd.LinearVelocity = 3 * Vector3.Normalize(toAdd.Position);
Space.Add(toAdd);
addedEntities.Add(toAdd);
}
//Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
//Space.Add(ground);
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:Raverenx,项目名称:GameEngine,代码行数:35,代码来源:AddRemoveStressDemo.cs
示例16: BridgeDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public BridgeDemo(DemosGame game)
: base(game)
{
//Form a long chain of planks connected by revolute joints.
//The revolute joints control the three linear degrees of freedom and two angular degrees of freedom.
//The third allowed angular degree of freedom allows the bridge to flex like a rope bridge.
Vector3 startPosition = new Vector3(0, 0, 0);
var startPlatform = new Box(startPosition - new Vector3(0, 0, 3.2f), 8, .5f, 8);
Space.Add(startPlatform);
Vector3 offset = new Vector3(0, 0, 1.7f);
Box previousLink = startPlatform;
Vector3 position = new Vector3();
for (int i = 1; i <= 200; i++)
{
position = startPosition + offset * i;
Box link = new Box(position, 4.5f, .3f, 1.5f, 50);
Space.Add(link);
Space.Add(new RevoluteJoint(previousLink, link, position - offset * .5f, Vector3.Right));
previousLink = link;
}
var endPlatform = new Box(position - new Vector3(0, 0, -4.8f), 8, .5f, 8);
Space.Add(endPlatform);
Space.Add(new RevoluteJoint(previousLink, endPlatform, position + offset * .5f, Vector3.Right));
game.Camera.Position = startPosition + new Vector3(0, 1, offset.Z * 200 + 5);
}
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:32,代码来源:BridgeDemo.cs
示例17: ParallelSpaceTestDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public ParallelSpaceTestDemo(DemosGame game)
: base(game)
{
for (int i = 0; i < 32; i++)
{
var space = new Space(null);
space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
var box = new Box(new Vector3(20 * i, 0, 0), 100, 1, 100);
space.Add(box);
//game.ModelDrawer.Add(box);
for (int j = 0; j < 30; j++)
{
for (int k = 0; k < 10; k++)
{
box = new Box(new Vector3(20 * i, 2 + j * 1.1f, 0), 1, 1, 1, 1);
entities.Add(box);
space.Add(box);
//game.ModelDrawer.Add(box);
}
}
spaces.Add(space);
}
game.Camera.Position = new Vector3(20, 10, 70);
}
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:29,代码来源:ParallelSpaceTestDemo.cs
示例18: StackDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public StackDemo(DemosGame game)
: base(game)
{
kapow.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
int height = 50;
float blockWidth = 3f;
float blockHeight = 1f;
float blockLength = 3f;
for (int i = 0; i < height; i++)
{
var toAdd =
new Box(
new Vector3(
0,
blockHeight * .5f + i * (blockHeight),
0),
blockWidth, blockHeight, blockLength, 10);
Space.Add(toAdd);
}
Box ground = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
Space.Add(ground);
game.Camera.Position = new Vector3(0, 6, 15);
}
开发者ID:Raverenx,项目名称:GameEngine,代码行数:30,代码来源:StackDemo.cs
示例19: CollisionFilteringDemo
/// <summary>
/// Constructs a new demo.
/// </summary>
/// <param name="game">Game owning this demo.</param>
public CollisionFilteringDemo(DemosGame game)
: base(game)
{
Entity toAdd;
toAdd = new Box(new Vector3(0, -.5f, 0), 50, 1, 50);
Space.Add(toAdd);
//Set up two stacks which go through each other
var firstStackGroup = new CollisionGroup();
var secondStackGroup = new CollisionGroup();
//Adding this rule to the space's collision group rules will prevent entities belong to these two groups from generating collision pairs with each other.
groupPair = new CollisionGroupPair(firstStackGroup, secondStackGroup);
CollisionRules.CollisionGroupRules.Add(groupPair, CollisionRule.NoBroadPhase);
for (int k = 0; k < 10; k++)
{
toAdd = new Box(
new Vector3(-4 + .12f * k, .5f + k, 0), 1f, 1f, 1f,
10);
toAdd.CollisionInformation.CollisionRules.Group = firstStackGroup;
Space.Add(toAdd);
toAdd = new Box(new Vector3(4 - .12f * k, .5f + k, 0),
1f, 1f, 1f, 10);
toAdd.CollisionInformation.CollisionRules.Group = secondStackGroup;
Space.Add(toAdd);
}
//Add another two boxes which ignore each other using the specific entities method; they will still collide with the stacks since they will have the default dynamic collision group.
toAdd = new Box(new Vector3(1, 3, 0), 1f, 4f, 2f, 10);
var toAdd2 = new Box(new Vector3(-1, 3, 0), 1f, 4f, 2f, 15);
CollisionRules.AddRule(toAdd, toAdd2, CollisionRule.NoBroadPhase);
Space.Add(toAdd);
Space.Add(toAdd2);
game.Camera.Position = new Vector3(0, 6, 20);
}
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:38,代码来源:CollisionFilteringDemo.cs
示例20: CharacterControllerInput
/// <summary>
/// Constructs the character and internal physics character controller.
/// </summary>
/// <param name="owningSpace">Space to add the character to.</param>
/// <param name="camera">Camera to attach to the character.</param>
/// <param name="game">The running game.</param>
public CharacterControllerInput(Space owningSpace, Camera camera, DemosGame game)
{
CharacterController = new CharacterController();
Camera = camera;
CameraControlScheme = new CharacterCameraControlScheme(CharacterController, camera, game);
Space = owningSpace;
}
开发者ID:Raverenx,项目名称:GameEngine,代码行数:14,代码来源:CharacterControllerInput.cs
注:本文中的DemosGame类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论