コード例 #1
0
bool CDoorPanelBehavior::SetupFlashFromMaterial( IMaterial* pMaterial, CDoorPanel& doorPanel )
{
	bool bSetupFlash = false;

	pMaterial->ActivateDynamicTextureSources(true); // Ensure player is created

	IFlashPlayer* pFlashPlayer = CHUDUtils::GetFlashPlayerFromMaterialIncludingSubMaterials(pMaterial, true);
	if (pFlashPlayer)
	{
		IFlashVariableObject* pFlashObject = NULL;
		pFlashPlayer->GetVariable(DOOR_PANEL_FLASHOBJECT_ROOT, pFlashObject);
		if (pFlashObject)
		{
			m_pFlashObjectRoot = pFlashObject;
			bSetupFlash = true;
		}
		else
		{
			GameWarning("CDoorPanelBehavior::SetupFlashFromMaterial: Failed to get flash object: %s", DOOR_PANEL_FLASHOBJECT_ROOT);
		}

		pFlashPlayer->Release();
	}
	else
	{
		GameWarning("CDoorPanelBehavior::SetupFlashFromMaterial: Failed to get flash player from material");
	}
	
	return bSetupFlash;
}
コード例 #2
0
ファイル: Scan.cpp プロジェクト: Adi0927/alecmercer-origins
//------------------------------------------------------------------------
void CScan::StartFire()
{
	if (!m_pWeapon->IsBusy())
	{
		if(m_pWeapon->GetOwnerActor())
		{
			// add the flash animation part here
			IEntity *pEntity = m_pWeapon->GetEntity();
			if(pEntity)
			{
				IEntityRenderProxy* pRenderProxy((IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER));
				if (pRenderProxy)
				{
					IMaterial* pMtl(pRenderProxy->GetRenderMaterial(0));
					if (pMtl)
					{
						pMtl = pMtl->GetSafeSubMtl(2);
						if (pMtl)
						{
							const SShaderItem& shaderItem(pMtl->GetShaderItem());
							if (shaderItem.m_pShaderResources)
							{
								SEfResTexture* pTex = shaderItem.m_pShaderResources->GetTexture(0);
								if (pTex)
								{
									IDynTextureSource* pDynTexSrc = pTex->m_Sampler.m_pDynTexSource;
									if (pDynTexSrc)
									{
										IFlashPlayer* pFlashPlayer = (IFlashPlayer*) pDynTexSrc->GetSource(IDynTextureSource::DTS_I_FLASHPLAYER);
										if (pFlashPlayer)
											pFlashPlayer->Invoke0("startScan");
									}
								}
							}
						}
					}
				}
			}

			m_scanning=true;
			m_delayTimer=m_scanparams.delay;
			m_durationTimer=m_scanparams.duration;
			m_tagEntitiesDelay=m_scanparams.tagDelay;
			m_pWeapon->SetBusy(true);
		}

		m_pWeapon->PlayAction(m_scanactions.spin_up, 0, false, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending);
		m_pWeapon->RequestStartFire();
		m_pWeapon->RequireUpdate(eIUS_FireMode);
	}
}
コード例 #3
0
ファイル: FlashMenuScreen.cpp プロジェクト: RenEvo/dead6
void CFlashMenuScreen::UpdateRatio()
{
    if(IsLoaded())
    {
        IFlashPlayer* pFlashPlayer = GetFlashPlayer();
        IRenderer* pRenderer = gEnv->pRenderer;

        // Native width/height/ratio
        float fMovieWidth			= (float) pFlashPlayer->GetWidth();
        float fMovieHeight		= (float) pFlashPlayer->GetHeight();
        float fMovieRatio			=	fMovieWidth / fMovieHeight;

        // Current renderer width/height/ratio
        float fRendererWidth	=	(float) pRenderer->GetWidth();
        float fRendererHeight	=	(float) pRenderer->GetHeight();
        float fRendererRatio	=	fRendererWidth / fRendererHeight;

        // Compute viewport so that it fits
        float fViewportX			= 0.0f;
        float fViewportY			= 0.0f;
        float fViewportWidth	= 0.0f;
        float fViewportHeight	= 0.0f;

        /*
        	All the Flash files have been designed either in 4/3 or 16/9 aspect ratios in resolutions
        	such as 1024x768 or 1366x768. Problem is that minimum aspect ratio is NOT 4/3 but 5/4,
        	mainly because of LCD monitors. We need to rescale accordingly in screen resolutions like
        	1280x1024	so that we use the file in its 4/3 mode. Hence, there is wasted place in both
        	vertical and horizontal areas but this is the only way to fits right.
        */

        if(fRendererRatio >= 4.0f/3.0f)
        {
            fViewportHeight	= fRendererHeight;

            fViewportX = (fRendererWidth - (fRendererHeight * fMovieRatio)) * 0.5f;
            fViewportWidth = fRendererHeight * fMovieRatio;
        }
        else
        {
            fViewportX = (fRendererWidth - ((fRendererWidth * 3.0f / 4.0f) * fMovieRatio)) * 0.5f;
            fViewportY = (fRendererHeight - (fRendererWidth * 3.0f / 4.0f)) * 0.5f;

            fViewportWidth = (fRendererWidth * 3.0f / 4.0f) * fMovieRatio;
            fViewportHeight = fRendererWidth * 3.0f / 4.0f;
        }

        pFlashPlayer->SetViewport((int)fViewportX,(int)fViewportY,(int)fViewportWidth,(int)fViewportHeight);
    }
}
コード例 #4
0
ファイル: Scan.cpp プロジェクト: Adi0927/alecmercer-origins
//------------------------------------------------------------------------
void CScan::StopFire()
{
	if (!m_scanning)
		return;

	IEntity *pEntity = m_pWeapon->GetEntity();
	if(pEntity)
	{
		IEntityRenderProxy* pRenderProxy((IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER));
		if (pRenderProxy)
		{
			IMaterial* pMtl(pRenderProxy->GetRenderMaterial(0));
			if (pMtl)
			{
				pMtl = pMtl->GetSafeSubMtl(2);
				if (pMtl)
				{
					const SShaderItem& shaderItem(pMtl->GetShaderItem());
					if (shaderItem.m_pShaderResources)
					{
						SEfResTexture* pTex = shaderItem.m_pShaderResources->GetTexture(0);
						if (pTex)
						{
							IDynTextureSource* pDynTexSrc = pTex->m_Sampler.m_pDynTexSource;
							if (pDynTexSrc)
							{
								IFlashPlayer* pFlashPlayer = (IFlashPlayer*) pDynTexSrc->GetSource(IDynTextureSource::DTS_I_FLASHPLAYER);
								if (pFlashPlayer)
									pFlashPlayer->Invoke0("cancelScan");
							}
						}
					}
				}
			}
		}
	}

	m_pWeapon->PlayAction(m_scanactions.spin_down, 0, false, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending);

	m_scanning=false;
	m_pWeapon->SetBusy(false);
	m_pWeapon->RequestStopFire();

	if (m_scanLoopId != INVALID_SOUNDID)
	{
		m_pWeapon->StopSound(m_scanLoopId);
		m_scanLoopId = INVALID_SOUNDID;
	}
}
コード例 #5
0
ファイル: HUDCommon.cpp プロジェクト: mrwonko/CrysisVR
void CHUDCommon::RepositionFlashAnimation(CGameFlashAnimation *pAnimation) const
{
	if(!pAnimation)
		return;

	pAnimation->RepositionFlashAnimation();

	IFlashPlayer *player = pAnimation->GetFlashPlayer();
	if(player)
	{
		int iX0,iY0,iWidth,iHeight;
		float fAspectRatio;
		player->GetViewport(iX0,iY0,iWidth,iHeight,fAspectRatio);
		player->SetViewport((int)(iX0+m_displacementX-m_distortionX*0.5),(int)(m_displacementY-m_distortionY*0.5),iWidth+m_distortionX,iHeight+m_distortionY);
		player->SetVariable("_alpha",SFlashVarValue(m_alpha));
	}
}
コード例 #6
0
void CDoorPanel::AssignAsFSCommandHandler()
{
	IEntity* pEntity = GetEntity();
	if (pEntity)
	{
		IEntityRenderProxy* pRenderProxy = static_cast<IEntityRenderProxy*>(pEntity->GetProxy(ENTITY_PROXY_RENDER));
		if (pRenderProxy)
		{
			_smart_ptr<IMaterial> pMaterial = pRenderProxy->GetRenderMaterial(DOOR_PANEL_MODEL_NORMAL_SLOT);
			IFlashPlayer* pFlashPlayer = CHUDUtils::GetFlashPlayerFromMaterialIncludingSubMaterials(pMaterial, true);
			if (pFlashPlayer) // Valid to not have a flash player, since will update when flash setup
			{
				pFlashPlayer->SetFSCommandHandler(this);
				pFlashPlayer->Release();
			}
		}
	}
}
コード例 #7
0
void CDoorPanelBehavior::DeinitFlashResources( CDoorPanel& doorPanel )
{
	if (m_pFlashObjectRoot)
	{
		SAFE_RELEASE(m_pFlashObjectRoot);

		if (doorPanel.m_sharingMaterialEntity == 0)
		{
			IEntity* pEntity = doorPanel.GetEntity();

			IEntityRenderProxy* pRenderProxy = static_cast<IEntityRenderProxy*>(pEntity->GetProxy(ENTITY_PROXY_RENDER));
			if (pRenderProxy)
			{
				IMaterial* pMaterial = pRenderProxy->GetRenderMaterial(DOOR_PANEL_MODEL_NORMAL_SLOT);
				if (pMaterial)
				{
					IFlashPlayer* pFlashPlayer = CHUDUtils::GetFlashPlayerFromMaterialIncludingSubMaterials(pMaterial, true);
					if (pFlashPlayer)
					{
						pFlashPlayer->SetFSCommandHandler(NULL);

						pFlashPlayer->Release();
					}

					CDoorPanelBehavior::DecrementNumUniqueFlashInstances(pMaterial->GetName());
					doorPanel.NotifyScreenSharingEvent(eDoorPanelGameObjectEvent_StopShareScreen);
				}
			}

			if (m_pActualAnimatedMaterial)
			{
				m_pActualAnimatedMaterial->ActivateDynamicTextureSources(false);
			}
		}
	}
}