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


C++ CVehicle::GetModelIndex方法代码示例

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


在下文中一共展示了CVehicle::GetModelIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessMouseMove

////////////////////////////////////////////////////
//
//  CMouseControl::ProcessMouseMove
//
//  Process a windows mouse movement message and turn it into control
//
////////////////////////////////////////////////////
bool CMouseControl::ProcessMouseMove ( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    if ( uMsg != WM_MOUSEMOVE )
        return false;

    if ( g_pCore->GetGame ()->GetSystemState () != 9 )
        return false;

    // HACK:  Grab our local player, and check his vehicle
    CPed* pPed = g_pCore->GetGame ()->GetPools ()->GetPedFromRef ( (DWORD)1 );
    if ( !pPed )
        return false;

    CVehicle* pVehicle = pPed->GetVehicle ();
    if ( !pVehicle )
        return false;

    CModelInfo* pModelInfo = g_pCore->GetGame ()->GetModelInfo( pVehicle->GetModelIndex() );

    bool bVar;
    CVARS_GET ( "fly_with_mouse", bVar );
    if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() && !bVar ) // Are we in a plane, but not have mouse flight enabled?
        return false;

    CVARS_GET ( "steer_with_mouse", bVar );
    if ( !bVar )  // Are we in another type of vehicle, but not have mouse steering enabled?
        return false;


    // Let's calculate our mouse movement directions
    CVector2D resolution = g_pCore->GetGUI()->GetResolution();
    int iX = LOWORD ( lParam ), iY = HIWORD ( lParam );
    float fX = (iX - resolution.fX*0.5f)/resolution.fX;

    fX *= MOUSE_CONTROL_MULTIPLIER;

    float fMouseSensitivity = g_pCore->GetGame ( )->GetSettings()->GetMouseSensitivity ();
    fX *= fMouseSensitivity;

    m_usLeftStickX += fX*128;
    m_usLeftStickX  = Clamp < const short > ( -128, m_usLeftStickX, 128 );

    // Only process Y input if we're in a vehicle that requires it
    if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() || pModelInfo->IsBike() || pModelInfo->IsBmx() || pModelInfo->IsQuadBike() )
    {
        float fY = (resolution.fY*0.5f - iY)/resolution.fY;
        fY *= MOUSE_CONTROL_MULTIPLIER;
        fY *= fMouseSensitivity;

        CVARS_GET ( "invert_mouse", bVar );
        fY = bVar ? -fY : fY;

        m_usLeftStickY += fY*128;
        m_usLeftStickY  = Clamp < const short > ( -128, m_usLeftStickY, 128 );
    }

    return true;
}
开发者ID:ntauthority,项目名称:openvice,代码行数:65,代码来源:CMouseControl.cpp


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