本文整理汇总了C++中MyApplication::getSimulator方法的典型用法代码示例。如果您正苦于以下问题:C++ MyApplication::getSimulator方法的具体用法?C++ MyApplication::getSimulator怎么用?C++ MyApplication::getSimulator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyApplication
的用法示例。
在下文中一共展示了MyApplication::getSimulator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupEnvironment
void setupEnvironment()
{
// Main static arena.
opal::Blueprint arenaBlueprint;
opal::loadFile(arenaBlueprint, "../data/blueprints/arena1.xml");
opal::BlueprintInstance arenaBPInstance;
gEngine.getSimulator()->instantiateBlueprint(arenaBPInstance,
arenaBlueprint, opal::Matrix44r(), 1);
gEngine.createPhysicalEntity("staticEnvironment", "Plastic/Gray",
arenaBPInstance.getSolid("staticEnvironment"));
gEngine.createPhysicalEntity("toy1", "Plastic/Green",
arenaBPInstance.getSolid("toy1"));
gEngine.createPhysicalEntity("toy2", "Plastic/Green",
arenaBPInstance.getSolid("toy2"));
gEngine.createPhysicalEntity("toy3", "Plastic/Green",
arenaBPInstance.getSolid("toy3"));
// Seesaw.
opal::Blueprint seesawBP;
opal::loadFile(seesawBP, "../data/blueprints/seesaw.xml");
opal::BlueprintInstance seesawBPInstance;
opal::Matrix44r seesawTransform;
seesawTransform.translate(8, 0, 0);
gEngine.getSimulator()->instantiateBlueprint(seesawBPInstance,
seesawBP, seesawTransform, 1);
gEngine.createPhysicalEntity("seesawSupport", "Plastic/Black",
seesawBPInstance.getSolid("seesawSupport"));
gEngine.createPhysicalEntity("seesawPanel", "Plastic/Orange",
seesawBPInstance.getSolid("seesawPanel"));
// Add an initial torque to bring one end of the seesaw to the
// ground.
seesawBPInstance.getJoint("seesawHinge")->addTorque(0, 100, 0, true);
// Merry-go-round.
gEngine.createPhysicalEntity("merryGoRound", "Plastic/Yellow",
arenaBPInstance.getSolid("merryGoRound"));
// Curtains.
opal::Blueprint curtainsBP;
opal::loadFile(curtainsBP, "../data/blueprints/blockCurtain.xml");
opal::BlueprintInstance curtainsBPInstance;
opal::Matrix44r curtainsTransform;
curtainsTransform.rotate(45, 0, 1, 0);
curtainsTransform.translate(-10, 0, 0);
gEngine.getSimulator()->instantiateBlueprint(curtainsBPInstance,
curtainsBP, curtainsTransform, 1);
gEngine.createPhysicalEntity("curtainBase", "Plastic/Red",
curtainsBPInstance.getSolid("curtainBase"));
gEngine.createPhysicalEntity("curtainPiece0", "Plastic/Black",
curtainsBPInstance.getSolid("curtainPiece0"));
gEngine.createPhysicalEntity("curtainPiece1", "Plastic/Black",
curtainsBPInstance.getSolid("curtainPiece1"));
gEngine.createPhysicalEntity("curtainPiece2", "Plastic/Black",
curtainsBPInstance.getSolid("curtainPiece2"));
gEngine.createPhysicalEntity("curtainPiece3", "Plastic/Black",
curtainsBPInstance.getSolid("curtainPiece3"));
gEngine.createPhysicalEntity("curtainPiece4", "Plastic/Black",
curtainsBPInstance.getSolid("curtainPiece4"));
gEngine.createPhysicalEntity("curtainPiece5", "Plastic/Black",
curtainsBPInstance.getSolid("curtainPiece5"));
//// Ragdoll.
//opal::Blueprint ragdollBP;
//opal::loadFile(ragdollBP, "../data/blueprints/ragdoll.xml");
//opal::BlueprintInstance ragdollBPInstance;
//opal::Matrix44r ragdollTransform;
//ragdollTransform.translate(10, 5, 0);
//gEngine.getSimulator()->instantiateBlueprint(ragdollBPInstance,
// ragdollBP, ragdollTransform, 2);
//for (unsigned int i = 0; i < ragdollBPInstance.getNumSolids(); ++i)
//{
// opal::Solid* s = ragdollBPInstance.getSolid(i);
// gEngine.createPhysicalEntity(s->getName(), "Plastic/Red", s);
//}
//// TESTING: Simple goal box.
//opal::Solid* boxSolid = gEngine.getSimulator()->createSolid();
//boxSolid->setStatic(false);
//boxSolid->setSleepiness(0);
//boxSolid->setPosition(15.5, 10, -7);
//opal::BoxShapeData data;
//data.dimensions.set(1.5, 1.5, 1.5);
//data.material.friction = 0.1;
//data.material.density = 0.5;
//boxSolid->addShape(data);
//gEngine.createPhysicalEntity("goal box", "Plastic/Green", boxSolid);
//// TESTING: Make a volume sensor to detect the goal.
//opal::VolumeSensorData goalSensorData;
//goalSensorData.solid = gRobot->getChassis();
//goalSensorData.transform.makeTranslation(0, 0, -2);
//gGoalSensor = gEngine.getSimulator()->createVolumeSensor();
//gGoalSensor->init(goalSensorData);
//gGoalSensorVolume = gEngine.getSimulator()->createSolid();
//gGoalSensorVolume->setStatic(true);
////opal::Matrix44r m = gRobot->getChassis()->getTransform();
////m.translate(0, 0, -2);
//opal::Matrix44r m;
//.........这里部分代码省略.........