本文整理汇总了C++中PhysicalObject::setCustomHull方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicalObject::setCustomHull方法的具体用法?C++ PhysicalObject::setCustomHull怎么用?C++ PhysicalObject::setCustomHull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicalObject
的用法示例。
在下文中一共展示了PhysicalObject::setCustomHull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hull
EnkiPlayground(World *world, QWidget *parent = 0) :
ViewerWidget(world, parent),
subjectiveView(false)
{
#define PROBLEM_GENERIC_TOY
#define PROBLEM_BALL_LINE
//#define PROBLEM_LONE_EPUCK
#ifdef PROBLEM_GENERIC_TOY
{
const double amount = 9;
const double radius = 5;
const double height = 20;
Polygone p;
for (double a = 0; a < 2*M_PI; a += 2*M_PI/amount)
p.push_back(Point(radius * cos(a), radius * sin(a)));
PhysicalObject* o = new PhysicalObject;
PhysicalObject::Hull hull(Enki::PhysicalObject::Part(p, height));
o->setCustomHull(hull, -1);
o->setColor(Color(0.4,0.6,0.8));
o->pos = Point(100, 100);
world->addObject(o);
}
for (int i = 0; i < 20; i++)
{
PhysicalObject* o = new PhysicalObject;
o->pos = Point(UniformRand(20, 100)(), UniformRand(20, 100)());
o->setCylindric(1, 1, 10);
o->setColor(Color(0.9, 0.2, 0.2));
o->dryFrictionCoefficient = 0.01;
world->addObject(o);
}
Polygone p2;
p2.push_back(Point(5,1));
p2.push_back(Point(-5,1));
p2.push_back(Point(-5,-1));
p2.push_back(Point(5,-1));
for (int i = 0; i < 5; i++)
{
PhysicalObject* o = new PhysicalObject;
PhysicalObject::Hull hull(Enki::PhysicalObject::Part(p2, 3));
o->setCustomHull(hull, 30);
o->setColor(Color(0.2, 0.1, 0.6));
o->collisionElasticity = 0.2;
o->pos = Point(UniformRand(20, 100)(), UniformRand(20, 100)());
world->addObject(o);
}
// cross shape
{
PhysicalObject* o = new PhysicalObject;
PhysicalObject::Hull hull;
hull.push_back(Enki::PhysicalObject::Part(Polygone() << Point(5,1) << Point(-5,1) << Point(-5,-1) << Point(5,-1), 2));
hull.push_back(Enki::PhysicalObject::Part(Polygone() << Point(1,5) << Point(-1,5) << Point(-1,-5) << Point(1,-5), 4));
o->setCustomHull(hull, 60);
o->setColor(Color(0.2, 0.4, 0.6));
o->collisionElasticity = 0.2;
o->pos = Point(UniformRand(20, 100)(), UniformRand(20, 100)());
world->addObject(o);
}
#endif // PROBLEM_GENERIC_TOY
#ifdef PROBLEM_BALL_LINE
for (double d = 40; d < 60; d += 8)
{
PhysicalObject* o = new PhysicalObject;
o->pos = Point(d, 20);
o->setCylindric(4, 2, 10);
o->setColor(Color(0.2, 0.2, 0.6));
o->dryFrictionCoefficient = 0.;
world->addObject(o);
}
#endif // PROBLEM_BALL_LINE
#ifdef PROBLEM_LONE_EPUCK
addDefaultsRobots(world);
#endif // PROBLEM_LONE_EPUCK
Marxbot *marxbot = new Marxbot;
marxbot->pos = Point(60, 50);
marxbot->leftSpeed = 8;
marxbot->rightSpeed = 2;
world->addObject(marxbot);
#ifdef USE_SDL
if((SDL_Init(SDL_INIT_JOYSTICK)==-1))
{
cerr << "Error : Could not initialize SDL: " << SDL_GetError() << endl;
addDefaultsRobots(world);
return;
}
int joystickCount = SDL_NumJoysticks();
for (int i = 0; i < joystickCount; ++i)
{
SDL_Joystick* joystick = SDL_JoystickOpen(i);
if (!joystick)
//.........这里部分代码省略.........