Ejemplo n.º 1
0
void Game::fireSphere(const std::string&) {
    Entity* camera;
    if (m_sceneManager.findEntity("camera", camera)) {
        static size_t n = 0;
        stringstream ss;
        ss << "missile-sphere-" << ++n;

        Entity* sphere = m_sceneManager.getRoot().addChild(ss.str());
        Vector3 orientationUnit = VECTOR3_UNIT_Z_NEG.rotate(camera->getOrientationAbs());
        sphere->setPositionAbs(camera->getPositionAbs() + orientationUnit);
        sphere->setOrientationAbs(camera->getOrientationAbs());

        RenderableMesh* cubeMesh = new RenderableMesh(sphere);
        cubeMesh->loadFromFile("assets/meshes/icosphere3.dae");

        RigidBody* cubeBody = new RigidBody(sphere);
        cubeBody->init(1.0, 0.8);
        cubeBody->addSphere(1.0);
//         cubeBody->addConvexHull("assets/meshes/icosphere1.dae");
        cubeBody->setLinearVelocity(orientationUnit * FIRE_SPEED);
    }
}