Beispiel #1
0
void GrandPrixWin::setKarts(const std::string idents_arg[3])
{
    TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager();

    // reorder in "podium order" (i.e. second player to the left, first player
    // in the middle, last at the right)
    std::string idents[3];
    idents[0] = idents_arg[1];
    idents[1] = idents_arg[0];
    idents[2] = idents_arg[2];

    for (int i = 0; i < 3; i++)
    {
        const KartProperties* kp = kart_properties_manager->getKart(idents[i]);
        if (kp == NULL) continue;

        KartModel* kart_model = kp->getKartModelCopy(KRT_DEFAULT);
        m_all_kart_models.push_back(kart_model);
        scene::ISceneNode* kart_main_node = kart_model->attachModel(false, false);

        m_kart_x[i] = KARTS_X + i*KARTS_DELTA_X;
        m_kart_y[i] = INITIAL_Y + KARTS_DELTA_Y;
        m_kart_z[i] = KARTS_INITIAL_Z;
        m_kart_rotation[i] = 0.0f;

        core::vector3df kart_pos(m_kart_x[i], m_kart_y[i], m_kart_z[i]);
        core::vector3df kart_rot(0, 0, 0);
        core::vector3df kart_scale(1.0f, 1.0f, 1.0f);

        //FIXME: it's not ideal that both the track object and the presentation
        // know the initial coordinates of the object
        TrackObjectPresentationSceneNode* presentation = 
            new TrackObjectPresentationSceneNode(kart_pos, kart_rot, kart_scale,
                                                 kart_main_node);
        TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale,
            "ghost", presentation, false /* isDynamic */, NULL /* physics settings */);
        tobjman->insertObject(tobj);

        m_kart_node[i] = tobj;
    }

    TrackObject* currObj;
    PtrVector<TrackObject>& objects = tobjman->getObjects();
    for_in(currObj, objects)
    {
        TrackObjectPresentationMesh* meshPresentation = currObj->getPresentation<TrackObjectPresentationMesh>();
        if (meshPresentation != NULL)
        {
            if (meshPresentation->getModelFile() == "gpwin_podium1.b3d")
                m_podium_steps[0] = currObj;
            else if (meshPresentation->getModelFile() == "gpwin_podium2.b3d")
                m_podium_steps[1] = currObj;
            else if (meshPresentation->getModelFile() == "gpwin_podium3.b3d")
                m_podium_steps[2] = currObj;
        }
    }
void GrandPrixWin::setKarts(const std::string idents_arg[3])
{
    TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager();

    // reorder in "podium order" (i.e. second player to the left, first player
    // in the middle, last at the right)
    std::string idents[3];
    idents[0] = idents_arg[1];
    idents[1] = idents_arg[0];
    idents[2] = idents_arg[2];

    for (int i = 0; i < 3; i++)
    {
        const KartProperties* kp = kart_properties_manager->getKart(idents[i]);
        if (kp == NULL) continue;

        KartModel* kart_model = kp->getKartModelCopy();
        m_all_kart_models.push_back(kart_model);
        scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false);
        LODNode* lnode = dynamic_cast<LODNode*>(kart_main_node);
        if (lnode)
        {
            // Lod node has to be animated
            auto* a_node = static_cast<scene::IAnimatedMeshSceneNode*>
                (lnode->getAllNodes()[0]);
            const unsigned start_frame =
                kart_model->getFrame(KartModel::AF_WIN_LOOP_START) > -1 ?
                kart_model->getFrame(KartModel::AF_WIN_LOOP_START) :
                kart_model->getFrame(KartModel::AF_WIN_START) > -1 ?
                kart_model->getFrame(KartModel::AF_WIN_START) :
                kart_model->getFrame(KartModel::AF_STRAIGHT);
            const unsigned end_frame =
                kart_model->getFrame(KartModel::AF_WIN_END) > -1 ?
                kart_model->getFrame(KartModel::AF_WIN_END) :
                kart_model->getFrame(KartModel::AF_STRAIGHT);
            a_node->setLoopMode(true);
            a_node->setFrameLoop(start_frame, end_frame);
        }

        m_kart_x[i] = KARTS_INITIAL_X[i];
        m_kart_y[i] = KARTS_INITIAL_Y[i];
        m_kart_z[i] = KARTS_INITIAL_Z[i];
        m_kart_rotation[i] = KARTS_AND_PODIUMS_INITIAL_ROTATION[i];

        core::vector3df kart_pos(m_kart_x[i], m_kart_y[i], m_kart_z[i]);
        core::vector3df kart_rot(0, 0, 0);
        core::vector3df kart_scale(1.0f, 1.0f, 1.0f);

        //FIXME: it's not ideal that both the track object and the presentation
        // know the initial coordinates of the object
        TrackObjectPresentationSceneNode* presentation = 
            new TrackObjectPresentationSceneNode(kart_pos, kart_rot, kart_scale,
                                                 kart_main_node);
        TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale,
            "ghost", presentation, false /* isDynamic */, NULL /* physics settings */);
        tobjman->insertObject(tobj);

        m_kart_node[i] = tobj;
    }

    TrackObject* currObj;
    PtrVector<TrackObject>& objects = tobjman->getObjects();
    for_in(currObj, objects)
    {
        TrackObjectPresentationMesh* meshPresentation = currObj->getPresentation<TrackObjectPresentationMesh>();
        if (meshPresentation != NULL)
        {
            if (meshPresentation->getModelFile() == "gpwin_podium1.spm")
                m_podium_steps[0] = currObj;
            else if (meshPresentation->getModelFile() == "gpwin_podium2.spm")
                m_podium_steps[1] = currObj;
            else if (meshPresentation->getModelFile() == "gpwin_podium3.spm")
                m_podium_steps[2] = currObj;
        }
    }