本文整理汇总了C++中PhysicsWorld::get_pc方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsWorld::get_pc方法的具体用法?C++ PhysicsWorld::get_pc怎么用?C++ PhysicsWorld::get_pc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsWorld
的用法示例。
在下文中一共展示了PhysicsWorld::get_pc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_outline_body
Body Collision::create_outline_body(PhysicsWorld &phys_world)
{
PhysicsContext pc = phys_world.get_pc();
BodyDescription box_desc(phys_world);
box_desc.set_type(body_dynamic);
Body box(pc, box_desc);
//Setup box fixture description.
//
//Outlines shouldn't be too complex. Keep it Under 100 points.
//If it has more, think about splitting it into couple smaller groups.
//Then create separate fixtures for the same body.
CollisionOutline outline("test_outline.out");
ChainShape outline_shape(phys_world);
outline_shape.create_loop(outline);
FixtureDescription fixture_desc2(phys_world);
fixture_desc2.set_shape(outline_shape);
fixture_desc2.set_restitution(0.6f);
fixture_desc2.set_friction(0.001f);
fixture_desc2.set_density(50.0f);
Fixture box_fixture(pc, box,fixture_desc2);
return box;
}
示例2: joint_desc
std::shared_ptr<Joint> Joints::create_joint(PhysicsWorld &phys_world, Body &bodyA, Body &bodyB, int type)
{
//Get the Physics Context
PhysicsContext pc = phys_world.get_pc();
switch(type)
{
default:
case 0: // Distance joint
{
DistanceJointDescription joint_desc(phys_world);
joint_desc.set_bodies(bodyA, bodyB, bodyA.get_position(), bodyB.get_position());
joint_desc.set_damping_ratio(1.0f);
joint_desc.set_length(100.0f);
std::shared_ptr<Joint> joint( static_cast<Joint *> (new DistanceJoint(pc, joint_desc)));
return joint;
}
case 1: // Revolute joint
{
RevoluteJointDescription joint_desc(phys_world);
joint_desc.set_bodies(bodyA, bodyB, bodyA.get_position());
joint_desc.set_as_motor();
joint_desc.set_motor_speed(Angle(60,angle_degrees));
joint_desc.set_max_motor_torque(1000);
std::shared_ptr<Joint> joint( static_cast<Joint *> (new RevoluteJoint(pc, joint_desc)));
return joint;
}
case 2: // Prismatic joint
{
PrismaticJointDescription joint_desc(phys_world);
joint_desc.set_bodies(bodyA, bodyB, bodyA.get_position(), bodyB.get_position());
joint_desc.set_as_motor();
joint_desc.enable_limit();
joint_desc.set_axis_a(Vec2f(0.0f,1.0f));
joint_desc.set_motor_speed(Angle(20,angle_degrees));
joint_desc.set_translation_limits(10.0f,100.0f);
joint_desc.set_max_motor_force(1000);
std::shared_ptr<Joint> joint( static_cast<Joint *> (new PrismaticJoint(pc, joint_desc)));
return joint;
}
}
}
示例3: create_ground_body
Body Collision::create_ground_body(PhysicsWorld &phys_world)
{
PhysicsContext pc = phys_world.get_pc();
BodyDescription ground_desc(phys_world);
ground_desc.set_position(Vec2f((float)window_x_size/2.0f,(float)window_y_size));
ground_desc.set_type(body_static);
Body ground(pc, ground_desc);
//Setup ground fixture
PolygonShape ground_shape(phys_world);
ground_shape.set_as_box((float)window_x_size/2,20.0f);
FixtureDescription fixture_desc(phys_world);
fixture_desc.set_shape(ground_shape);
fixture_desc.set_friction(1.0f);
fixture_desc.set_density(1000.0f);
Fixture ground_fixture(pc, ground, fixture_desc);
return ground;
}
示例4: create_box_body
Body Joints::create_box_body(PhysicsWorld &phys_world)
{
//Get the Physics Context
PhysicsContext pc = phys_world.get_pc();
BodyDescription box_desc(phys_world);
box_desc.set_type(body_dynamic);
Body box(pc, box_desc);
//Setup box fixture description
PolygonShape box_shape(phys_world);
box_shape.set_as_box(20.0f,20.0f);
FixtureDescription fixture_desc2(phys_world);
fixture_desc2.set_shape(box_shape);
fixture_desc2.set_restitution(0.6f);
fixture_desc2.set_friction(0.001f);
fixture_desc2.set_density(50.0f);
Fixture box_fixture(pc, box,fixture_desc2);
return box;
}