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


C++ CCamera::GetCam方法代码示例

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


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

示例1: DoNewCamera

static void DoNewCamera( idCameraPosition::positionType type ){
	CCamera *cam = AllocCam();

	if ( cam ) {
		char buf[128];
		sprintf( buf, "camera%i", cam->GetCamNum() );

		cam->GetCam()->startNewCamera( type );
		cam->GetCam()->setName( buf );
		cam->GetCam()->buildCamera();

		sprintf( buf, "Unsaved Camera %i", cam->GetCamNum() );
		cam->SetFileName( buf, false );

		SetCurrentCam( cam );
		RefreshCamListCombo();

		// Go to editmode Add
		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_pEditModeAddRadioButton ), TRUE );

		// Show the camera inspector
		DoCameraInspector();

		// Start edit mode (if not initiated by DoCameraInspector)
		if ( !g_bEditOn ) {
			DoStartEdit( GetCurrentCam() );
		}
	}
	else {
		g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "No free cameras available.", "Create Camera Error", MB_OK, NULL );
	}
}
开发者ID:TTimo,项目名称:GtkRadiant,代码行数:32,代码来源:funchandlers.cpp

示例2: DoLoadCamera

void DoLoadCamera(){
	char basepath[PATH_MAX];

	if ( firstCam && firstCam->HasBeenSaved() ) {
		CAMERA_ExtractFilePath( firstCam->GetFileName(), basepath );
	}
	else{
		strcpy( basepath, g_FuncTable.m_pfnGetGamePath() );
	}

	const gchar *filename = g_FuncTable.m_pfnFileDialog( (GtkWidget *)g_pRadiantWnd, TRUE, "Open Camera File", basepath, "camera", NULL );

	if ( filename ) {
		CCamera *cam = AllocCam();
		char fullpathtofile[PATH_MAX];

		if ( cam ) {
			Q_realpath( filename, fullpathtofile, PATH_MAX );

			// see if this camera file was already loaded
			CCamera *checkCam = firstCam->GetNext(); // not the first one as we just allocated it
			while ( checkCam ) {
				if ( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) {
					char error[PATH_MAX + 64];
					FreeCam( cam );
					sprintf( error, "Camera file \'%s\' is already loaded", fullpathtofile );
					g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL );
					//g_free( filename );
					return;
				}
				checkCam = checkCam->GetNext();
			}

			if ( loadCamera( cam->GetCamNum(), fullpathtofile ) ) {
				cam->GetCam()->buildCamera();
				cam->SetFileName( filename, true );
				SetCurrentCam( cam );
				RefreshCamListCombo();
				g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
			}
			else {
				char error[PATH_MAX + 64];
				FreeCam( cam );
				sprintf( error, "An error occured during the loading of \'%s\'", fullpathtofile );
				g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL );
			}

			//g_free( filename );
		}
		else {
			g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "No free camera slots available", "Load error", MB_OK, NULL );
		}
	}
}
开发者ID:TTimo,项目名称:GtkRadiant,代码行数:54,代码来源:funchandlers.cpp

示例3: DrawFromAim

void CNametags::DrawFromAim()
{
    unsigned long ulCurrentTime = CClientTime::GetTime();

    // Got any players that are not local?
    if (m_pPlayerManager->Count() > 1)
    {
        // Grab the local player
        CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer();
        if (pLocalPlayer)
        {
            // Grab the current time and the camera
            unsigned long ulCurrentTime = CClientTime::GetTime();
            CCamera*      pCamera = g_pGame->GetCamera();

            // Grab our controller state
            CControllerState State;
            g_pGame->GetPad()->GetCurrentControllerState(&State);

            // Grab our current weapon slot. Use screen center if melee or none
            CVector     vecStart;
            CVector     vecTarget;
            eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot();
            if (eSlot == WEAPONSLOT_TYPE_UNARMED || eSlot == WEAPONSLOT_TYPE_MELEE || eSlot == WEAPONSLOT_TYPE_RIFLE || eSlot == WEAPONSLOT_TYPE_THROWN ||
                eSlot == WEAPONSLOT_TYPE_SPECIAL || eSlot == WEAPONSLOT_TYPE_GIFT || eSlot == WEAPONSLOT_TYPE_PARACHUTE || eSlot == WEAPONSLOT_TYPE_DETONATOR)
            {
                // Grab the active cam
                CCamera* pCamera = g_pGame->GetCamera();
                CCam*    pActive = pCamera->GetCam(pCamera->GetActiveCam());

                // Grab the camera matrix
                CMatrix matCamera;
                pCamera->GetMatrix(&matCamera);
                vecStart = matCamera.vPos;

                // Range
                float        fRange;
                eWeaponType  eWeapon = pLocalPlayer->GetCurrentWeaponType();
                float        fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon));
                CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill);
                if (pWeaponStat)
                {
                    fRange = pWeaponStat->GetTargetRange();
                }
                else
                {
                    fRange = MELEE_VISIBLE_RANGE;
                }

                // Find the target position
                CVector vecFront = *pActive->GetFront();
                vecFront.Normalize();
                vecTarget = *pActive->GetSource() + vecFront * fRange;
            }
            else
            {
                // Grab the weapon and keysync state. If it exists and he holds Target down
                CWeapon* pPlayerWeapon = pLocalPlayer->GetWeapon();
                if (pPlayerWeapon && State.RightShoulder1)
                {
                    // Grab the gun muzzle position
                    eWeaponType  eWeapon = pLocalPlayer->GetCurrentWeaponType();
                    float        fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon));
                    CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill);

                    CVector vecGunMuzzle = *pWeaponStat->GetFireOffset();
                    pLocalPlayer->GetTransformedBonePosition(BONE_RIGHTWRIST, vecGunMuzzle);

                    // Grab the target point
                    pCamera->Find3rdPersonCamTargetVector(AIM_VISIBLE_RANGE, &vecGunMuzzle, &vecStart, &vecTarget);
                }
                else
                {
                    // Grab the active cam
                    CCam* pActive = pCamera->GetCam(pCamera->GetActiveCam());

                    // Grab the camera matrix
                    CMatrix matCamera;
                    pCamera->GetMatrix(&matCamera);
                    vecStart = matCamera.vPos;

                    // Find the target position
                    CVector vecFront = *pActive->GetFront();
                    vecFront.Normalize();
                    vecTarget = *pActive->GetSource() + vecFront * MELEE_VISIBLE_RANGE;
                }
            }

            // Ignore the local player for this
            pLocalPlayer->WorldIgnore(true);

            // Do the raycast
            CColPoint*        pColPoint = NULL;
            CEntity*          pEntity = NULL;
            SLineOfSightFlags flags;
            flags.bCheckBuildings = true;
            flags.bCheckVehicles = true;
            flags.bCheckPeds = true;
            flags.bCheckObjects = true;
            flags.bCheckDummies = true;
//.........这里部分代码省略.........
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:101,代码来源:CNametags.cpp


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