本文整理汇总了C#中BEPUphysics.Space.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Space.Add方法的具体用法?C# Space.Add怎么用?C# Space.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEPUphysics.Space
的用法示例。
在下文中一共展示了Space.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: AddToSpace
public void AddToSpace(Space space)
{
LeftTread.AddToSpace(space);
RightTread.AddToSpace(space);
Turret.AddToSpace(space);
space.Add(Body);
}
示例3: SphereCharacterControllerInput
/// <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 SphereCharacterControllerInput(Space owningSpace, Camera camera, DemosGame game)
{
CharacterController = new SphereCharacterController();
CameraControlScheme = new FixedOffsetCameraControlScheme(CharacterController.Body, camera, game);
Space = owningSpace;
Space.Add(CharacterController);
}
示例4: SimpleCharacterControllerInput
/// <summary>
/// Constructs the character and internal physics character controller.
/// </summary>
/// <param name="owningSpace">Space to add the character to.</param>
/// <param name="CameraToUse">Camera to attach to the character.</param>
public SimpleCharacterControllerInput(Space owningSpace, Camera CameraToUse)
{
CharacterController = new SimpleCharacterController(Vector3.Zero, 2, .8f, 1f, 20);
Space = owningSpace;
Space.Add(CharacterController);
Camera = CameraToUse;
Deactivate();
}
示例5: CharacterControllerInput
/// <summary>
/// Constructs the character and internal physics character controller.
/// </summary>
/// <param name="owningSpace">Space to add the character to.</param>
/// <param name="cameraToUse">Camera to attach to the character.</param>
public CharacterControllerInput(Space owningSpace, Camera cameraToUse)
{
CharacterController = new CharacterController();
Space = owningSpace;
Space.Add(CharacterController);
Camera = cameraToUse;
Deactivate();
}
示例6: CharacterControllerInputOld
/// <summary>
/// Constructs the character and internal physics character controller.
/// </summary>
/// <param name="owningSpace">Space to add the character to.</param>
/// <param name="CameraToUse">Camera to attach to the character.</param>
public CharacterControllerInputOld(Space owningSpace, Camera CameraToUse)
{
CharacterController = new CharacterControllerOld(Vector3.Zero, 2, .4f, 30f, 1.1f);
Space = owningSpace;
Space.Add(CharacterController);
Camera = CameraToUse;
Deactivate();
}
示例7: RigidBody
/// <summary>
///
/// </summary>
/// <param name="game"></param>
/// <param name="space"></param>
public RigidBody ( Entity entity, World world, float w, float h, float d, float mass ) : base(entity,world)
{
this.space = ((MPWorld)world).PhysSpace;
var ms = new MotionState();
ms.AngularVelocity = MathConverter.Convert( entity.AngularVelocity );
ms.LinearVelocity = MathConverter.Convert( entity.LinearVelocity );
ms.Orientation = MathConverter.Convert( entity.Rotation );
ms.Position = MathConverter.Convert( entity.Position );
box = new Box( ms, w, h, d, mass );
box.PositionUpdateMode = PositionUpdateMode.Continuous;
box.Tag = entity;
space.Add( box );
}
示例8: Health
/// <summary>
/// Constructs a new wall.
/// </summary>
/// <param name="game">Game that this component belongs to.</param>
/// <param name="space">Space to which the entities of the wall belong to.</param>
/// <param name="detectorModel">Volume to detect incoming enemies.</param>
/// <param name="detectorWorldMatrix">Transformation matrix to apply to the detector volume.</param>
/// <param name="worldMatrix">Transformation matrix which positions and orients the entities of the wall.</param>
/// <param name="blocksAcross">Number of blocks across the wall.</param>
/// <param name="blocksTall">Number of blocks tall.</param>
/// <param name="wallLength">Total length of the wall.</param>
/// <param name="wallHeight">Total height of the wall.</param>
/// <param name="blockThickness">Thickness of the wall.</param>
public Health(Game game, Space space, Vector3 position)
: base(game)
{
this.space = space;
this.position = position;
this.game = game;
body = new Sphere(position, 15, 5);
body.Tag = this;
body.EventManager.InitialCollisionDetected += EntityEntersVolume;
space.Add(body);
isAlive = true;
lifeTime = 0f;
/*Sphere box = body as Sphere;
Matrix scaling = Matrix.CreateScale(body.Radius);
Model CubeModel;
CubeModel = game.Content.Load<Model>("Models/cube");
EntityModel model1 = new EntityModel(body, CubeModel, scaling, game);
game.Components.Add(model1); */
}
示例9: PhysicsEngine
public PhysicsEngine()
{
Display.AtExit += Display_AtExit;
for( int i = 0; i < ( Environment.ProcessorCount - 3 ); i++ )
{
parallelLooper.AddThread();
}
VoxelGridConvexPairHandler.EnsurePairsAreRegistered();
world = new Space();
world.ForceUpdater.Gravity = new Vector3( 0, -9.81f, 0 );
{
int n;
for( n = 0; n < 10; n++ )
{
Vector3 origin = new Vector3( 1800, n * 8, 0 );
test_entitites[n] = new Box( origin, 4, 4, 4, 1 );
world.Add( test_entitites[n] );
}
}
}
示例10: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
_spriteBatch = new SpriteBatch(GraphicsDevice);
// load models
_footballModel = Content.Load<Model>("mdl/football");
var pitchModel = Content.Load<Model>("mdl/pitch");
// initialise physics simulation space
_space = new Space();
_space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
Vector3[] vertices;
int[] indices;
TriangleMesh.GetVerticesAndIndicesFromModel(pitchModel, out vertices, out indices);
var mesh = new StaticMesh(vertices, indices, new BEPUphysics.MathExtensions.AffineTransform(new Vector3(0, -40.0f, 0)));
_space.Add(mesh);
Components.Add(new StaticModel(pitchModel, mesh.WorldTransform.Matrix, this));
var sphere = new Sphere(new Vector3(0, 4, 0), 1, 1);
_space.Add(sphere);
var scaling = Matrix.CreateScale(sphere.Radius);
var model = new EntityModel(sphere, _footballModel, scaling, this);
Components.Add(model);
//sphere.Tag = model;
}
示例11: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
hudFont = Content.Load<SpriteFont>(@"hudFont");
space = new Space();
space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
//space2 = new Space();
//space2.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
terrain = new BasicModel(this, Content.Load<Model>(@"Models/terrain"), true);
StaticMesh terrainMesh = GetTerrainMesh(terrain, Matrix.Identity);
//terrainMesh.Material.StaticFriction = 0;
//terrainMesh.Material.KineticFriction = 1;
space.Add(terrainMesh);
terrainMesh.Tag = terrain;
// StaticMesh terrainMesh2 = GetTerrainMesh(terrain, Matrix.Identity);
// space2.Add(terrainMesh2);
// ferns
for (int i = 0; i < 20; i++)
{
Vector3 position = getSafeSpawn(0);
Console.WriteLine(position);
BasicModel tree = new BasicModel(this, Content.Load<Model>(@"Models/fern"), position, true);
StaticMesh treeMesh = GetTerrainMesh(tree, Matrix.CreateTranslation(position));
Components.Add(tree);
}
// palm trees
for (int i = 0; i < 5; i++)
{
Vector3 position = getSafeSpawn(0);
Console.WriteLine(position);
BasicModel tree = new BasicModel(this, Content.Load<Model>(@"Models/palmTree"), position, true);
StaticMesh treeMesh = GetTerrainMesh(tree, Matrix.CreateTranslation(position));
Components.Add(tree);
}
//adding character
cube = new ControllableModel(this, Content.Load<Model>(@"Models/character"),
new Box(new Vector3(0, 10, 0), 1, 1, 1, 2));
space.Add(cube.entity);
cube.entity.Material.KineticFriction = 1;
cube.entity.Tag = cube;
//Adding skydome
Matrix skyDomeRotate = Matrix.CreateRotationX(MathHelper.Pi);
BasicModel skyDome = new BasicModel(this, Content.Load<Model>(@"Models/skyDome"), skyDomeRotate, true);
//adding rings
totalRings = 16;
for (int i = 0; i < totalRings; i++ )
{
makeCoin(getSafeSpawn(r.Next(25,35)));
}
// baobab trees
for (int i = 0; i < 5; i++)
{
Vector3 position = getSafeSpawn(0);
BasicModel tree = new BasicModel(this, Content.Load<Model>(@"Models/baobabTree"),position,true);
Cylinder treeBox = new Cylinder(position, 10,3, 1);
treeBox.Mass = float.PositiveInfinity;
space.Add(treeBox);
treeBox.Tag = tree;
Components.Add(tree);
}
Components.Add(skyDome);
Components.Add(terrain);
Components.Add(cube);
// turn off backface culling
//RasterizerState rs = new RasterizerState();
//rs.CullMode = CullMode.None;
//GraphicsDevice.RasterizerState = rs;
}
示例12: LoadContent
/// <summary>
/// Load content
/// </summary>
public void LoadContent ()
{
uberShader = Content.Load<Ubershader>("render");
factory = new StateFactory(uberShader, typeof(RenderFlags), Primitive.TriangleList, VertexInputElement.FromStructure<CubeVertex>());
texture = Content.Load<Texture2D>(@"Scenes\lena");
vb = new VertexBuffer(GraphicsDevice, typeof(CubeVertex), 24);
ib = new IndexBuffer(GraphicsDevice, 36);
// create a new space with physics
space = new Space();
// update gravity force
space.ForceUpdater.Gravity = new Vector3BEPU(0, -9.81f, 0);
// add ground, ground has infinite mass
Box ground = new Box(new Vector3BEPU(0, 0, 0), 50, 1, 50);
space.Add(ground);
// create boxes with random position and add color as a tag, then add box to space
for ( int i = 0; i < numberOfBoxes; i++ ) {
Vector3Fusion vector = RandomExt.NextVector3(random, new Vector3Fusion(-10, 20, -10), new Vector3Fusion(10, 80, 10));
Box box = new Box(new Vector3BEPU(vector.X, vector.Y, vector.Z), 1, 1, 1, 1);
box.Tag = RandomExt.NextColor(random);
space.Add(box);
}
}
示例13: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
space = new Space();
space.ForceUpdater.Gravity = new Vector3(0, -9.81f, 0);
Box groundBox = new Box(Vector3.Zero, ground.width, 0.1f, ground.height);
space.Add(groundBox);
cameraCylindar = new Cylinder(Camera.pos, 5, 5);
space.Add(cameraCylindar);
createTower();
createWall();
foreach (GameEntity child in children)
{
child.LoadContent();
}
}
示例14: AddToGame
public virtual void AddToGame(Space s)
{
TemporarilyMuteVoice = false;
MediaSystem.PlayTrack(levelTheme.Song);
overlay = new OpeningOverlay(levelNumber < 12 ? levelNumber : levelNumber - 11, levelNumber > 11, levelName);
time = new TimeSpan();
RebuildTiming();
foreach(OperationalMachine m in MachineList.Keys)
s.Add(m);
s.Add(levelModel);
foreach(Tube t in tubeList)
s.Add(t);
foreach(BaseModel m in glassModels)
if(m.Ent.Space == null)
s.Add(m);
s.Add(dispenser);
if(levelTheme.Fluid != null)
s.Add(levelTheme.Fluid);
addModelsToRenderer();
results = null;
ending = badEnding = false;
}
示例15: AddToGame
public void AddToGame(Space s)
{
RenderingDevice.Add(buff, blackTex);
if(Ent.Space == null)
s.Add(Ent);
if(BlackSquare.Space == null)
s.Add(BlackSquare);
}