本文整理汇总了C#中BulletSharp.RigidBody.SetAnisotropicFriction方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.SetAnisotropicFriction方法的具体用法?C# RigidBody.SetAnisotropicFriction怎么用?C# RigidBody.SetAnisotropicFriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletSharp.RigidBody
的用法示例。
在下文中一共展示了RigidBody.SetAnisotropicFriction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInitializePhysics
protected override void OnInitializePhysics()
{
// collision configuration contains default setup for memory, collision setup
CollisionConf = new DefaultCollisionConfiguration();
Dispatcher = new CollisionDispatcher(CollisionConf);
Broadphase = new DbvtBroadphase();
World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, null, CollisionConf);
World.Gravity = new Vector3(0, -10, 0);
// create the ground
CollisionShape groundShape = new BoxShape(20, 50, 10);
CollisionShapes.Add(groundShape);
CollisionObject ground = LocalCreateRigidBody(0,
Matrix.RotationAxis(new Vector3(0, 0, 1), (float)Math.PI * 0.03f) * Matrix.Translation(0, -50, 0),
groundShape);
ground.Friction = 1;
ground.RollingFriction = 1;
ground.UserObject = "Ground";
groundShape = new BoxShape(100, 50, 100);
CollisionShapes.Add(groundShape);
ground = LocalCreateRigidBody(0, Matrix.Translation(0, -54, 0), groundShape);
ground.Friction = 1;
ground.RollingFriction = 1;
ground.UserObject = "Ground";
// create a few dynamic rigidbodies
CollisionShape[] colShapes = {
new SphereShape(1),
new CapsuleShape(0.5f,1),
new CapsuleShapeX(0.5f,1),
new CapsuleShapeZ(0.5f,1),
new ConeShape(0.5f,1),
new ConeShapeX(0.5f,1),
new ConeShapeZ(0.5f,1),
new CylinderShape(new Vector3(0.5f,1,0.5f)),
new CylinderShapeX(new Vector3(1,0.5f,0.5f)),
new CylinderShapeZ(new Vector3(0.5f,0.5f,1)),
};
foreach (var collisionShape in colShapes)
{
CollisionShapes.Add(collisionShape);
}
const float mass = 1.0f;
CollisionShape colShape = new BoxShape(1);
CollisionShapes.Add(colShape);
Vector3 localInertia = colShape.CalculateLocalInertia(mass);
var rbInfo = new RigidBodyConstructionInfo(mass, null, null, localInertia);
const float startX = StartPosX - ArraySizeX / 2;
const float startY = StartPosY;
const float startZ = StartPosZ - ArraySizeZ / 2;
int shapeIndex = 0;
for (int k = 0; k < ArraySizeY; k++)
{
for (int i = 0; i < ArraySizeX; i++)
{
for (int j = 0; j < ArraySizeZ; j++)
{
Matrix startTransform = Matrix.Translation(
2 * i + startX,
2 * k + startY + 20,
2 * j + startZ
);
shapeIndex++;
// using motionstate is recommended, it provides interpolation capabilities
// and only synchronizes 'active' objects
rbInfo.MotionState = new DefaultMotionState(startTransform);
rbInfo.CollisionShape = colShapes[shapeIndex % colShapes.Length];
RigidBody body = new RigidBody(rbInfo);
body.Friction = 1;
body.RollingFriction = 0.3f;
body.SetAnisotropicFriction(colShape.AnisotropicRollingFrictionDirection, AnisotropicFrictionFlags.RollingFriction);
World.AddRigidBody(body);
}
}
}
rbInfo.Dispose();
}