コード例 #1
0
ファイル: cirr3dengine.hpp プロジェクト: xiaofeme/tt
	void setRotation(core::quaternion & q)
	{
		core::vector3df euler;
		q.toEuler(euler);

		euler.X = core::radToDeg(euler.X);
		euler.Y = core::radToDeg(euler.Y);
		euler.Z = core::radToDeg(euler.Z);

		m_lightNode->setRotation(euler);
	}
コード例 #2
0
ファイル: cirr3dengine.hpp プロジェクト: xiaofeme/tt
    void getRotation(core::quaternion &q)
    {
        core::vector3df euler;
		euler = m_lightNode->getRotation();

		euler.X = core::degToRad(euler.X);
		euler.Y = core::degToRad(euler.Y);
		euler.Z = core::degToRad(euler.Z);

        q.set(euler);
    }
コード例 #3
0
/** Update, called once per timestep.
 *  \param dt Time step size.
 */
void SlipStream::update(float dt)
{
    MovingTexture::update(dt);

    // Update this karts slipstream quad (even for low level AI which don't
    // use slipstream, since even then player karts can get slipstream, 
    // and so have to compare with the modified slipstream quad.
    m_slipstream_original_quad->transform(m_kart->getTrans(), 
                                          m_slipstream_quad);

    if(m_slipstream_mode==SS_USE)
    {
        m_slipstream_time -= dt;
        if(m_slipstream_time<0) m_slipstream_mode=SS_NONE;
    }

    updateSlipstreamPower();

    // If this kart is too slow for slipstreaming taking effect, do nothing
    // --------------------------------------------------------------------
    // Define this to get slipstream effect shown even when the karts are
    // not moving. This is useful for debugging the graphics of SS-ing.
#undef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING
#ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING
    if(m_kart->getSpeed()<m_kart->getKartProperties()->getSlipstreamMinSpeed())
    {
        setIntensity(0, NULL);
        m_slipstream_mode = SS_NONE;
        if(UserConfigParams::m_slipstream_debug)
            setDebugColor(video::SColor(255, 0, 0, 0));
        return;
    }
#endif

    // Then test if this kart is in the slipstream range of another kart:
    // ------------------------------------------------------------------
    World *world           = World::getWorld();
    unsigned int num_karts = world->getNumKarts();
    bool is_sstreaming     = false;
    m_target_kart          = NULL;

    // Note that this loop can not be simply replaced with a shorter loop
    // using only the karts with a better position - since a kart might
    // be a lap behind
    for(unsigned int i=0; i<num_karts; i++)
    {
        m_target_kart= world->getKart(i);
        // Don't test for slipstream with itself, a kart that is being
        // rescued or exploding, or an eliminated kart
        if(m_target_kart==m_kart               || 
            m_target_kart->getKartAnimation()  ||
            m_target_kart->isEliminated()        ) continue;

        float diff = fabsf(m_target_kart->getXYZ().getY() 
                           - m_kart->getXYZ().getY()      );
        // If the kart is 'on top' of this kart (e.g. up on a bridge),
        // don't consider it for slipstreaming.

        if(diff>6.0f) continue;
        // If the kart we are testing against is too slow, no need to test
        // slipstreaming. Note: We compare the speed of the other kart 
        // against the minimum slipstream speed kart of this kart - not 
        // entirely sure if this makes sense, but it makes it easier to 
        // give karts different slipstream properties.
#ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING
        if(m_target_kart->getSpeed() <
            m_kart->getKartProperties()->getSlipstreamMinSpeed()) 
        {
            if(UserConfigParams::m_slipstream_debug &&
                m_kart->getController()->isPlayerController())
                m_target_kart->getSlipstream()
                              ->setDebugColor(video::SColor(255, 0, 0, 0));

            continue;
        }
#endif
        // Quick test: the kart must be not more than
        // slipstream length+0.5*kart_length()+0.5*target_kart_length
        // away from the other kart
        Vec3 delta = m_kart->getXYZ() - m_target_kart->getXYZ();
        float l    = m_target_kart->getKartProperties()->getSlipstreamLength() 
                   + 0.5f*( m_target_kart->getKartLength()
                           +m_kart->getKartLength()        );
        if(delta.length2_2d() > l*l) 
        {
            if(UserConfigParams::m_slipstream_debug &&
                m_kart->getController()->isPlayerController())
                m_target_kart->getSlipstream()
                             ->setDebugColor(video::SColor(255, 0, 0, 128));
            continue;
        }
        // Real test: if in slipstream quad of other kart
        if(m_target_kart->getSlipstream()->m_slipstream_quad
                                         ->pointInQuad(m_kart->getXYZ()))
        {
            is_sstreaming     = true;
            break;
        }
        if(UserConfigParams::m_slipstream_debug &&
            m_kart->getController()->isPlayerController())
            m_target_kart->getSlipstream()
                         ->setDebugColor(video::SColor(255, 0, 0, 255));
    }   // for i < num_karts

    if(!is_sstreaming)
    {
        if(UserConfigParams::m_slipstream_debug &&
            m_kart->getController()->isPlayerController())
            m_target_kart->getSlipstream()
                         ->setDebugColor(video::SColor(255, 255, 0, 0));

        if(isSlipstreamReady()) 
        {
            // The first time slipstream is ready after collecting
            // and you are leaving the slipstream area, you get a
            // zipper bonus. 
            if(m_slipstream_mode==SS_COLLECT)
            {
                m_slipstream_mode = SS_USE;
                m_kart->handleZipper();
                m_slipstream_time = 
                    m_kart->getKartProperties()->getSlipstreamCollectTime();
                return;
            }
        }
        m_slipstream_time -=dt;
        if(m_slipstream_time<0) m_slipstream_mode = SS_NONE;
        setIntensity(0, NULL);
        return;
    }   // if !is_sstreaming

    if(UserConfigParams::m_slipstream_debug &&
        m_kart->getController()->isPlayerController())
        m_target_kart->getSlipstream()->setDebugColor(video::SColor(255, 0, 255, 0));
    // Accumulate slipstream credits now
    m_slipstream_time = m_slipstream_mode==SS_NONE ? dt 
                                                   : m_slipstream_time+dt;
    if(isSlipstreamReady())
        m_kart->setSlipstreamEffect(9.0f);
    setIntensity(m_slipstream_time, m_target_kart);

    m_slipstream_mode = SS_COLLECT;
    if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime())
    {
        setIntensity(1.0f, m_target_kart);
    }
    

return;
    core::vector3df pos = m_kart->getNode()->getPosition();
    pos.Y = m_kart->getHoT()+0.2f;
    m_node->setPosition(pos);
    core::vector3df f = core::vector3df(0, 0, 10) - f;
    core::vector3df r = f.getHorizontalAngle();
    m_node->setRotation(r);
    return;

    const core::quaternion new_rot(m_kart->getNode()->getRotation());
    const core::quaternion old_rot(m_node->getRotation()            );

    core::quaternion interpo;
    core::vector3df interp;
    new_rot.toEuler(interp);
    m_node->setRotation(interp);
}   // update