Exemplo n.º 1
0
//------------------------------------------------------------------------
IUIElement* CScriptBind_UIAction::GetElement( const char* sName, int instanceID, bool bSupressWarning )
{
	if (gEnv->IsDedicated())
		return NULL;

	CRY_ASSERT_MESSAGE( gEnv->pFlashUI, "FlashUI extension does not exist!" );
	if ( !gEnv->pFlashUI )
	{
		UIACTION_WARNING( "LUA: FlashUI extension does not exist!" );
		return NULL;
	}

	IUIElement* pElement = gEnv->pFlashUI->GetUIElement( sName );
	if ( pElement && instanceID > 0)
		pElement = pElement->GetInstance( instanceID );

	if (pElement && pElement->IsValid())
		return pElement;

	if (!bSupressWarning)
	{
		UIACTION_WARNING( "LUA: Try to access UIElement %s that is not valid!", sName );
	}
	return NULL;
}
Exemplo n.º 2
0
void CUIEntityDynTexTag::OnAddTaggedEntity(EntityId entityId, const char *uiElementName, const char *entityClass, const char *materialTemplate, const Vec3 &offset, const char *idx)
{
    OnRemoveTaggedEntity(entityId, idx);

    IEntityClass *pEntClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(entityClass);

    if(pEntClass)
    {
        SEntitySpawnParams params;
        params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
        params.pClass = pEntClass;

        IEntity *pTagEntity = gEnv->pEntitySystem->SpawnEntity(params);
        IUIElement *pElement = gEnv->pFlashUI->GetUIElement(uiElementName);

        if(pTagEntity && pElement)
        {
            IMaterial *pMatTemplate = gEnv->p3DEngine->GetMaterialManager()->LoadMaterial(materialTemplate, false);

            if(pMatTemplate && pMatTemplate->GetShaderItem().m_pShaderResources->GetTexture(0))
            {
                pMatTemplate->GetShaderItem().m_pShaderResources->GetTexture(0)->m_Name.Format("%s@%d.ui", uiElementName, entityId);
                IMaterial *pMat = gEnv->p3DEngine->GetMaterialManager()->CloneMaterial(pMatTemplate);
                pTagEntity->SetMaterial(pMat);
            }

            IEntityRenderProxy *pRenderProxy = (IEntityRenderProxy *) pTagEntity->GetProxy(ENTITY_PROXY_RENDER);

            if(pRenderProxy)
            {
                IRenderNode *pRenderNode = pRenderProxy->GetRenderNode();

                if(pRenderNode)
                {
                    pRenderNode->SetViewDistRatio(256);
                }
            }

            pElement->RemoveEventListener(this); // first remove to avoid assert if already registered!
            pElement->AddEventListener(this, "CUIEntityDynTexTag");
            gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_DONE, this);
            m_Tags.push_back(STagInfo(entityId, pTagEntity->GetId(), idx, offset, pElement->GetInstance((uint)entityId)));
        }
    }
}
void CFlowSetupModelPostRender::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
	switch (event)
	{
	case eFE_Initialize:
		break;
	case eFE_Activate:
		if (IsPortActive(pActInfo, IN_SHUTDOWN))
		{
			CMenuRender3DModelMgr::Release(true);

			ITexture *tex = NULL;
			//unbind tex from MC
			if(gEnv->pConsole->GetCVar("r_UsePersistentRTForModelHUD")->GetIVal() > 0)		
				tex  = gEnv->pRenderer->EF_LoadTexture("$ModelHUD");
			else
				tex  = gEnv->pRenderer->EF_LoadTexture("$BackBuffer");

			IUIElement* pElement = pFlashUI->GetUIElement(sUIElement.c_str());
			IUIElement* pUIElement = pElement ? pElement->GetInstance(0) : NULL;
			if(pUIElement)
				pUIElement->UnloadTexFromMc(sMovieClipName.c_str(), tex);

			return;
		}
		
		if (IsPortActive(pActInfo, IN_START))
		{
			INDENT_LOG_DURING_SCOPE();

			// Setup scene settings
			CMenuRender3DModelMgr::SSceneSettings sceneSettings;
			sceneSettings.fovScale = 0.85f;
			sceneSettings.fadeInSpeed = 0.01f;
			sceneSettings.flashEdgeFadeScale = 0.0f;
			sceneSettings.ambientLight = Vec4(GetPortVec3(pActInfo, IN_AMBIENTLIGHTCOLOR), GetPortFloat(pActInfo, IN_AMBIENTLIGHTSTRENGTH));
			sceneSettings.lights.resize(3);
			sceneSettings.lights[0].pos.Set(-25.f, -10.f, 30.f);
			sceneSettings.lights[0].color = GetPortVec3(pActInfo, IN_LIGHTCOLOR1);
			sceneSettings.lights[0].specular = 4.f;
			sceneSettings.lights[0].radius = 400.f;
			sceneSettings.lights[1].pos.Set(25.f, -4.f, 30.f);
			sceneSettings.lights[1].color = GetPortVec3(pActInfo, IN_LIGHTCOLOR2);
			sceneSettings.lights[1].specular = 10.f;
			sceneSettings.lights[1].radius = 400.f;
			sceneSettings.lights[2].pos.Set(60.f, 40.f, 10.f);
			sceneSettings.lights[2].color = GetPortVec3(pActInfo, IN_LIGHTCOLOR3);
			sceneSettings.lights[2].specular = 10.f;
			sceneSettings.lights[2].radius = 400.f;

			//Create scene
			CMenuRender3DModelMgr *renderModels = new CMenuRender3DModelMgr();
			renderModels->SetSceneSettings(sceneSettings);

			ITexture *tex = NULL;
			//Fetch texture and send to movieclip
			if(gEnv->pConsole->GetCVar("r_UsePersistentRTForModelHUD")->GetIVal() > 0)		
				tex  = gEnv->pRenderer->EF_LoadTexture("$ModelHUD");
			else
				tex  = gEnv->pRenderer->EF_LoadTexture("$BackBuffer");

			string sStr = GetPortString(pActInfo, IN_MC);
			string::size_type sPos = sStr.find( ':' );
			sUIElement = sStr.substr( 0, sPos );
			sMovieClipName = sStr.substr( sPos + 1 );

			IUIElement* pElement = pFlashUI->GetUIElement(sUIElement.c_str());
			IUIElement* pUIElement = pElement ? pElement->GetInstance(0) : NULL;
			if(pUIElement)
				pUIElement->LoadTexIntoMc(sMovieClipName.c_str(), tex);
			else
				CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "CFlowAdd3DModelToHUD: Movieclip not found");

			//check debug info
			float debugscale = GetPortFloat(pActInfo, IN_DEBUGSCALE);
			ICVar* cv_debugRender = gEnv->pConsole->GetCVar("g_post3DRendererDebug");
			if(debugscale > 0.0f)
			{
				if(cv_debugRender)
				{
					cv_debugRender->Set(2);
					CMenuRender3DModelMgr::GetInstance()->SetDebugScale(debugscale);
				}
			}
			else
			{
				cv_debugRender->Set(0);
			}
			
		}
		break;
	}
}