本文整理汇总了C#中BulletSharp.DiscreteDynamicsWorld.AddAction方法的典型用法代码示例。如果您正苦于以下问题:C# DiscreteDynamicsWorld.AddAction方法的具体用法?C# DiscreteDynamicsWorld.AddAction怎么用?C# DiscreteDynamicsWorld.AddAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletSharp.DiscreteDynamicsWorld
的用法示例。
在下文中一共展示了DiscreteDynamicsWorld.AddAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
conf = new DefaultCollisionConfiguration();
dispatcher = new CollisionDispatcher(conf);
broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf);
action = new Action();
world.AddAction(action);
world.AddAction(action);
world.RemoveAction(action);
world.RemoveAction(action);
world.AddAction(action);
}
示例2: OnInitializePhysics
protected override void OnInitializePhysics()
{
// collision configuration contains default setup for memory, collision setup
CollisionConf = new DefaultCollisionConfiguration();
Dispatcher = new CollisionDispatcher(CollisionConf);
Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
Solver = new SequentialImpulseConstraintSolver();
World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
World.DispatchInfo.AllowedCcdPenetration = 0.0001f;
//World.Gravity = Freelook.Up * -10.0f;
Matrix startTransform = Matrix.Translation(10.210098f, -1.6433364f, 16.453260f);
ghostObject = new PairCachingGhostObject();
ghostObject.WorldTransform = startTransform;
Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());
const float characterHeight = 1.75f;
const float characterWidth = 1.75f;
ConvexShape capsule = new CapsuleShape(characterWidth, characterHeight);
ghostObject.CollisionShape = capsule;
ghostObject.CollisionFlags = CollisionFlags.CharacterObject;
const float stepHeight = 0.35f;
character = new KinematicCharacterController(ghostObject, capsule, stepHeight);
BspLoader bspLoader = new BspLoader();
bspLoader.LoadBspFile("data/BspDemo.bsp");
BspConverter bsp2Bullet = new BspToBulletConverter(this);
bsp2Bullet.ConvertBsp(bspLoader, 0.1f);
World.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
World.AddAction(character);
convexResultCallback = new ClosestConvexResultCallback();
convexResultCallback.CollisionFilterMask = (short)CollisionFilterGroups.StaticFilter;
cameraSphere = new SphereShape(0.2f);
}
示例3: OnInitializePhysics
//.........这里部分代码省略.........
data.Write(j * width + i);
data.Write((j + 1) * width + i);
data.Write((j + 1) * width + i + 1);
}
else
{
data.Write(j * width + i);
data.Write((j + 1) * width + i);
data.Write(j * width + i + 1);
data.Write(j * width + i + 1);
data.Write((j + 1) * width + i);
data.Write((j + 1) * width + i + 1);
}
/ *
// Not using diamond subdivision
data.Write(j * width + i);
data.Write((j + 1) * width + i);
data.Write(j * width + i + 1);
data.Write(j * width + i + 1);
data.Write((j + 1) * width + i);
data.Write((j + 1) * width + i + 1);
* /
}
}
game.groundMesh.UnlockIndexBuffer();
game.groundMesh.ComputeNormals();
}*/
CollisionShapes.Add(groundShape);
//create ground object
RigidBody ground = LocalCreateRigidBody(0, tr, groundShape);
ground.UserObject = "Ground";
CollisionShape chassisShape = new BoxShape(1.0f, 0.5f, 2.0f);
CollisionShapes.Add(chassisShape);
CompoundShape compound = new CompoundShape();
CollisionShapes.Add(compound);
//localTrans effectively shifts the center of mass with respect to the chassis
Matrix localTrans = Matrix.Translation(Vector3.UnitY);
compound.AddChildShape(localTrans, chassisShape);
RigidBody carChassis = LocalCreateRigidBody(800, Matrix.Identity, compound);
carChassis.UserObject = "Chassis";
//carChassis.SetDamping(0.2f, 0.2f);
//CylinderShapeX wheelShape = new CylinderShapeX(wheelWidth, wheelRadius, wheelRadius);
// clientResetScene();
// create vehicle
VehicleTuning tuning = new VehicleTuning();
IVehicleRaycaster vehicleRayCaster = new DefaultVehicleRaycaster(World);
//vehicle = new RaycastVehicle(tuning, carChassis, vehicleRayCaster);
vehicle = new CustomVehicle(tuning, carChassis, vehicleRayCaster);
carChassis.ActivationState = ActivationState.DisableDeactivation;
World.AddAction(vehicle);
const float connectionHeight = 1.2f;
bool isFrontWheel = true;
// choose coordinate system
vehicle.SetCoordinateSystem(rightIndex, upIndex, forwardIndex);
BulletSharp.Math.Vector3 connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
isFrontWheel = false;
connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
for (i = 0; i < vehicle.NumWheels; i++)
{
WheelInfo wheel = vehicle.GetWheelInfo(i);
wheel.SuspensionStiffness = suspensionStiffness;
wheel.WheelsDampingRelaxation = suspensionDamping;
wheel.WheelsDampingCompression = suspensionCompression;
wheel.FrictionSlip = wheelFriction;
wheel.RollInfluence = rollInfluence;
}
vehicle.RigidBody.WorldTransform = vehicleTr;
}