当前位置: 首页>>代码示例>>C++>>正文


C++ MyApplication::createPhysicalEntity方法代码示例

本文整理汇总了C++中MyApplication::createPhysicalEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ MyApplication::createPhysicalEntity方法的具体用法?C++ MyApplication::createPhysicalEntity怎么用?C++ MyApplication::createPhysicalEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyApplication的用法示例。


在下文中一共展示了MyApplication::createPhysicalEntity方法的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;
//.........这里部分代码省略.........
开发者ID:sub77,项目名称:hobbycode,代码行数:101,代码来源:main.cpp


注:本文中的MyApplication::createPhysicalEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。