本文整理汇总了C#中Scene.CreateJoint方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.CreateJoint方法的具体用法?C# Scene.CreateJoint怎么用?C# Scene.CreateJoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.CreateJoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadPhysics
protected override void LoadPhysics(Scene scene)
{
var material = scene.Physics.CreateMaterial(0.7f, 0.7f, 0.1f);
// Spherical Joint
{
// Actor 0
var rigidActor0 = scene.Physics.CreateRigidDynamic();
rigidActor0.CreateShape(new BoxGeometry(2, 2, 2), material);
rigidActor0.GlobalPose = Matrix.Translation(0, 10, 0);
rigidActor0.SetMassAndUpdateInertia(10);
// Actor 1
//var rigidActor1 = scene.Physics.CreateRigidDynamic();
//rigidActor1.CreateShape(new BoxGeometry(2, 2, 2), material);
//rigidActor1.GlobalPose = Matrix.Translation(-20, 10, 0);
//rigidActor1.SetMassAndUpdateInertia(10);
//rigidActor1.Flags = RigidDynamicFlags.Kinematic; // Pin this actor in space
//scene.AddActor(rigidActor1);
//
var sphericalJoint = scene.CreateJoint<SphericalJoint>(rigidActor0, Matrix.Translation(0, 4, 0), null, Matrix.Translation(0, 15, 0));
sphericalJoint.ConstraintFlag = ConstraintFlag.Visualization;
scene.AddActor(rigidActor0);
}
}
示例2: PrismaticJointWithLimit
public static PrismaticJoint PrismaticJointWithLimit(Scene scene)
{
Actor actorA, actorB;
{
BoxShapeDescription boxShapeDesc = new BoxShapeDescription(3, 3, 3);
BodyDescription bodyDesc = new BodyDescription(10.0f);
bodyDesc.BodyFlags |= BodyFlag.Kinematic;
ActorDescription actorDesc = new ActorDescription()
{
BodyDescription = bodyDesc,
GlobalPose = Matrix.Translation(70, 25, -65),
Shapes = { boxShapeDesc }
};
actorA = scene.CreateActor(actorDesc);
}
{
BoxShapeDescription boxShapeDesc = new BoxShapeDescription(3, 3, 3);
ActorDescription actorDesc = new ActorDescription()
{
BodyDescription = new BodyDescription(10.0f),
GlobalPose = Matrix.Translation(70, 15, -65),
Shapes = { boxShapeDesc }
};
actorB = scene.CreateActor(actorDesc);
}
PrismaticJointDescription prismaticJointDesc = new PrismaticJointDescription()
{
Actor1 = actorA,
Actor2 = actorB,
};
prismaticJointDesc.SetGlobalAnchor(new Vector3(70, 20, -65));
prismaticJointDesc.SetGlobalAxis(new Vector3(0, 1, 0));
PrismaticJoint prismaticJoint = scene.CreateJoint(prismaticJointDesc) as PrismaticJoint;
LimitPlane limitPlane = new LimitPlane(new Vector3(0, 1, 0), new Vector3(-30, 8, -30), 0);
prismaticJoint.AddLimitPlane(limitPlane);
return prismaticJoint;
}
示例3: RevoluteJoint
public static RevoluteJoint RevoluteJoint(Scene scene)
{
BoxShapeDescription boxShapeDescA = new BoxShapeDescription(3, 3, 3);
BoxShapeDescription boxShapeDescB = new BoxShapeDescription(3, 3, 3);
ActorDescription actorDescA = new ActorDescription()
{
BodyDescription = new BodyDescription(10.0f),
GlobalPose = Matrix.Translation(75, 1.5f, -55),
Shapes = { boxShapeDescA }
};
Actor actorA = scene.CreateActor(actorDescA);
ActorDescription actorDescB = new ActorDescription()
{
BodyDescription = new BodyDescription(10.0f),
GlobalPose = Matrix.Translation(70, 1.5f, -55),
Shapes = { boxShapeDescB }
};
Actor actorB = scene.CreateActor(actorDescB);
//
RevoluteJointDescription revoluteJointDesc = new RevoluteJointDescription()
{
Actor1 = actorA,
Actor2 = actorB,
Motor = new MotorDescription(20, 20.1f, true)
};
revoluteJointDesc.Flags |= RevoluteJointFlag.MotorEnabled;
revoluteJointDesc.SetGlobalAnchor(new Vector3(73.5f, 1.5f, -55));
revoluteJointDesc.SetGlobalAxis(new Vector3(1, 0, 0));
RevoluteJoint revoluteJoint = scene.CreateJoint(revoluteJointDesc) as RevoluteJoint;
return revoluteJoint;
}
示例4: LoadPhysics
protected override void LoadPhysics(Scene scene)
{
var material = scene.Physics.CreateMaterial(0.7f, 0.7f, 0.1f);
// Spherical Joint
{
var box = scene.Physics.CreateRigidDynamic();
box.CreateShape(new BoxGeometry(2, 2, 2), material);
box.GlobalPose = Matrix4x4.CreateTranslation(0, 10, 0);
box.SetMassAndUpdateInertia(10);
//
var sphericalJoint = scene.CreateJoint<SphericalJoint>(box, Matrix4x4.CreateTranslation(0, 4, 0), null, Matrix4x4.CreateTranslation(0, 15, 0));
sphericalJoint.ConstraintFlag = ConstraintFlag.Visualization;
scene.AddActor(box);
}
// Revolute Joint
{
var box = scene.Physics.CreateRigidDynamic();
box.CreateShape(new BoxGeometry(2, 2, 2), material);
box.GlobalPose = Matrix4x4.CreateTranslation(-10, 10, 0);
box.SetMassAndUpdateInertia(10);
//
var revoluteJoint = scene.CreateJoint<RevoluteJoint>(box, Matrix4x4.CreateTranslation(0, 4, 0), null, Matrix4x4.CreateTranslation(-10, 15, 0));
revoluteJoint.ConstraintFlag = ConstraintFlag.Visualization;
scene.AddActor(box);
}
// Breakable Revolute Joint
{
var box = scene.Physics.CreateRigidDynamic();
box.CreateShape(new BoxGeometry(2, 2, 2), material);
box.GlobalPose = Matrix4x4.CreateTranslation(10, 10, 0);
box.SetMassAndUpdateInertia(10);
//
var revoluteJoint = scene.CreateJoint<RevoluteJoint>(box, Matrix4x4.CreateTranslation(0, 4, 0), null, Matrix4x4.CreateTranslation(10, 15, 0));
revoluteJoint.ConstraintFlag = ConstraintFlag.Visualization;
revoluteJoint.BreakForce = 0.001f;
scene.AddActor(box);
}
// Distance Joint
{
var box = scene.Physics.CreateRigidDynamic();
box.CreateShape(new BoxGeometry(2, 2, 2), material);
box.GlobalPose = Matrix4x4.CreateTranslation(-20, 10, 0);
box.SetMassAndUpdateInertia(10);
//
var distanceJoint = scene.CreateJoint<DistanceJoint>(box, Matrix4x4.CreateTranslation(0, 4, 0), null, Matrix4x4.CreateTranslation(-20, 15, 0));
distanceJoint.ConstraintFlag = ConstraintFlag.Visualization;
distanceJoint.MinimumDistance = 1;
distanceJoint.MaximumDistance = 3;
scene.AddActor(box);
}
// Fixed Joint
{
var box = scene.Physics.CreateRigidDynamic();
box.CreateShape(new BoxGeometry(2, 2, 2), material);
box.GlobalPose = Matrix4x4.CreateTranslation(-30, 15, 0);
box.SetMassAndUpdateInertia(10);
//
var fixedJoint = scene.CreateJoint<FixedJoint>(box, Matrix4x4.Identity, null, Matrix4x4.CreateTranslation(-30, 15, 0));
fixedJoint.ConstraintFlag = ConstraintFlag.Visualization;
scene.AddActor(box);
}
// Prismatic Joint
{
var box = scene.Physics.CreateRigidDynamic();
box.CreateShape(new BoxGeometry(2, 2, 2), material);
box.GlobalPose = Matrix4x4.CreateTranslation(-40, 15, 0);
box.SetMassAndUpdateInertia(10);
//
var prismaticJoint = scene.CreateJoint<PrismaticJoint>(box, Matrix4x4.Identity, null, Matrix4x4.CreateTranslation(-40, 15, 0));
prismaticJoint.ConstraintFlag = ConstraintFlag.Visualization;
scene.AddActor(box);
}
// D6 Joint
{
var box = scene.Physics.CreateRigidDynamic();
//.........这里部分代码省略.........