Пример #1
0
void Map::CalculateLights(bool firstTime) {
	if (!firstTime)
	{
		for (int i = minX; i < maxX; i++)
		{
			for (int j = minY; j < maxY; j++)
			{
				blocks[i][j].lightValue = 0;
			}
		}
	}

	for (int i = minX; i < maxX; i++)
	{
		for (int j = minY; j < maxY; j++)
		{
			if (blocks[i][j].lightSource > 0) {
				UpdateLight(i, j, blocks[i][j].lightSource);
			}
		}
	}
	Entity* entity;
	for (std::vector<Entity*>::iterator it = entities.begin(); it != entities.end(); ++it)
	{
		entity = (*it);
		if (entity->GetLight() > 0)
			UpdateLight((int) entity->shape->GetCenterX(), (int) entity->shape->GetCenterY(), entity->GetLight());
	}
}
Пример #2
0
//---------------------------------------------------------
//---------------------------------------------------------
void CBounceBomb::Wake( bool bAwake )
{
	CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();

	CReliableBroadcastRecipientFilter filter;
	
	if( !m_pWarnSound )
	{
		m_pWarnSound = controller.SoundCreate( filter, entindex(), "NPC_CombineMine.ActiveLoop" );
		controller.Play( m_pWarnSound, 1.0, PITCH_NORM  );
	}

	if( bAwake )
	{
		// Turning on
		if( m_bFoeNearest )
		{
			EmitSound( "NPC_CombineMine.TurnOn" );
			controller.SoundChangeVolume( m_pWarnSound, 1.0, 0.1 );
		}

		unsigned char r, g, b;
		r = g = b = 0;

		if( m_bFoeNearest )
		{
			r = 255;
		}
		else
		{
			g = 255;
		}

		UpdateLight( true, r, g, b, 190 );
	}
	else
	{
		// Turning off
		if( m_bFoeNearest )
		{
			EmitSound( "NPC_CombineMine.TurnOff" );
		}

		SetNearestNPC( NULL );
		controller.SoundChangeVolume( m_pWarnSound, 0.0, 0.1 );
		UpdateLight( false, 0, 0, 0, 0 );
	}

	m_bAwake = bAwake;
}
void C_EnvProjectedTexture::Simulate( void )
{
	//UpdateLight( false );
	UpdateLight(GetMoveParent() != NULL);

	BaseClass::Simulate();
}
Пример #4
0
dlgEffectLight::dlgEffectLight(wxWindow *parent, bool colour) {
    m_doUpdate = false;
    m_offset = 0;
    m_colour = colour;

    InitWidgetsFromXRC((wxWindow *)parent);

    m_choiceLightType->SetSelection(0);
    m_choiceLightOption->SetSelection(0);
    m_choiceColour->SetSelection(0);

    m_colourPick = new wxColourPickerCtrl(this, XRCID("m_colourPick"), *wxWHITE);
    m_colourPick->SetToolTip(_("Select light colour."));
    wxXmlResource::Get()->AttachUnknownControl(wxT("m_colourPick"), m_colourPick, this);

    Fit();
    Layout();
    GetSizer()->SetSizeHints(this);

    m_btOk->SetId(wxID_OK);
    m_btCancel->SetId(wxID_CANCEL);

    m_doUpdate = true;
    UpdateLight();

    if (m_colour) {
        m_choiceLightOption->Enable(false);
        m_textLightRadius->Enable(false);
        m_checkCM->Enable(false);
    }

}
Пример #5
0
bool C_EnvProjectedTexture::Simulate( void )
{
	UpdateLight();

	BaseClass::Simulate();
	return true;
}
Пример #6
0
void CC4Projectile::Arm(bool arm)
{
	if(arm != m_armed)
	{
		m_armed = arm;

		if(gEnv->bServer)
		{
			CHANGED_NETWORK_STATE(this, ASPECT_C4_STATUS);

			if(CWeapon* pWeapon = GetWeapon())
			{
				CHANGED_NETWORK_STATE(pWeapon, CC4::ASPECT_DETONATE);
			}
		}

		if(m_pStatObj)
		{
			m_pStatObj->SetMaterial(arm ? m_pArmedMaterial : m_pDisarmedMaterial);
		}

		if(m_pLightSource)
		{
			UpdateLight(0.f, true);
		}
	}
}
Пример #7
0
void MainScreen::SetupLights()
{
    // Setup scene lights
    Lights& lights = mEngine->GetRenderer().GetLights();

    // Add directional light
    DirLight dirLight;
    dirLight.direction = glm::vec3(-0.3f, -0.5f, -0.5f);
    dirLight.color = glm::vec3(0.9f);
    lights.dirLights.push_back(dirLight);

    // Add point lights
    for (int i = 0; i < 2; ++i)
    {
        PointLight pointLight;
        pointLight.color = glm::vec3(0.8f, 0.8f, 0.8f);
        pointLight.attProps.constant   = 1.0f;
        pointLight.attProps.linear     = 0.09f;
        pointLight.attProps.quadratic  = 0.032f;
        lights.pointLights.push_back(pointLight);
    }

    // Update lights once to take their initial position
    for (int i = 0; i < 2; i++)
        UpdateLight(mEngine->GetRenderer(), mScene.get(), i, glm::vec3(0));
}
Пример #8
0
/**
*@brief 削除ボタンを押したときのスロット
*/
void LightSetWidget::DestroySlot()
{

    if(up_flag)
    {
        std::string n = (const char*)NameEdit->currentText().toLocal8Bit();


        if(EC)
        {
            if(n == "")
            {
                return;
            }
            else
            {
                LightObj *ml = EC->getLightByName(n.c_str());
                if(ml)
                {
                    EC->DestroyQtLight(ml);
                    UpdateList();
                    emit UpdateLight();
                }
            }

        }
    }
}
Пример #9
0
//---------------------------------------------------------
//---------------------------------------------------------
void CBounceBomb::ExplodeThink()
{
	SetSolid( SOLID_NONE );

	// Don't catch self in own explosion!
	m_takedamage = DAMAGE_NO;

	if( m_hSprite )
	{
		UpdateLight( false, 0, 0, 0, 0 );
	}

	if( m_pWarnSound )
	{
		CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
		controller.SoundDestroy( m_pWarnSound );
	}


	CBaseEntity *pThrower = HasPhysicsAttacker( 0.5 );

	if (m_iModification == MINE_MODIFICATION_CAVERN)
	{
		ExplosionCreate( GetAbsOrigin(), GetAbsAngles(), (pThrower) ? pThrower : this, BOUNCEBOMB_EXPLODE_DAMAGE, BOUNCEBOMB_EXPLODE_RADIUS, true,
			NULL, CLASS_PLAYER_ALLY );
	}
	else
	{
		ExplosionCreate( GetAbsOrigin(), GetAbsAngles(), (pThrower) ? pThrower : this, BOUNCEBOMB_EXPLODE_DAMAGE, BOUNCEBOMB_EXPLODE_RADIUS, true);
	}
	UTIL_Remove( this );
}
Пример #10
0
void CWeapon::UpdateCL		()
{
	inherited::UpdateCL		();
	UpdateHUDAddonsVisibility();
	//подсветка от выстрела
	UpdateLight				();

	//нарисовать партиклы
	UpdateFlameParticles	();
	UpdateFlameParticles2	();

	if(!IsGameTypeSingle())
		make_Interpolation		();
	
	if( (GetNextState()==GetState()) && IsGameTypeSingle() && H_Parent()==Level().CurrentEntity())
	{
		CActor* pActor	= smart_cast<CActor*>(H_Parent());
		if(pActor && !pActor->AnyMove() && this==pActor->inventory().ActiveItem())
		{
			if (hud_adj_mode==0 && 
				GetState()==eIdle && 
				(Device.dwTimeGlobal-m_dw_curr_substate_time>20000) && 
				!IsZoomed()&&
				g_player_hud->attached_item(1)==NULL)
			{
				if(AllowBore())
					SwitchState		(eBore);

				ResetSubStateTime	();
			}
		}
	}

	if(m_zoom_params.m_pNight_vision && !need_renderable())
	{
		if(!m_zoom_params.m_pNight_vision->IsActive())
		{
			CActor *pA = smart_cast<CActor *>(H_Parent());
			R_ASSERT(pA);
			CTorch* pTorch = smart_cast<CTorch*>( pA->inventory().ItemFromSlot(TORCH_SLOT) );
			if ( pTorch && pTorch->GetNightVisionStatus() )
			{
				m_bRememberActorNVisnStatus = pTorch->GetNightVisionStatus();
				pTorch->SwitchNightVision(false, false);
			}
			m_zoom_params.m_pNight_vision->Start(m_zoom_params.m_sUseZoomPostprocess, pA, false);
		}

	}
	else if(m_bRememberActorNVisnStatus)
	{
		m_bRememberActorNVisnStatus = false;
		EnableActorNVisnAfterZoom();
	}

	if(m_zoom_params.m_pVision)
		m_zoom_params.m_pVision->Update();
}
Пример #11
0
void Vehicle::Update()
{
  UpdateHUD();
  UpdateWheels();
  UpdateEffects();
  UpdateSounds();
  UpdateCameraEntity();
  UpdateLight();
}
void ASFlashlight::HandleFiring()
{
	if (Role == ROLE_Authority)
	{
		/* Toggle light,cone and material when Fired */
		bIsActive = !bIsActive;

		UpdateLight(bIsActive);
	}
}
Пример #13
0
void Map::UpdateLight(int i, int j, float level, int previ, int prevj, bool recalculate)
{
	if (level <= 1 || !ValidateBlock(i, j))
		return;
	if (blocks[i][j].lightValue < level || (recalculate && blocks[i][j].lightValue == level))
		blocks[i][j].lightValue = level;
	else
		return;
	lightUpdated++;
	if (blocks[i][j].Id > 0)
		--level;
	if (previ != i - 1 || prevj != j)
		UpdateLight(i - 1, j, level - 1, i, j);
	if (previ != i + 1 || prevj != j)
		UpdateLight(i + 1, j, level - 1, i, j);
	if (previ != i || prevj != j - 1)
		UpdateLight(i, j - 1, level - 1, i, j);
	if (previ != i || prevj != j + 1)
		UpdateLight(i, j + 1, level - 1, i, j);
}
Пример #14
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : updateType - 
//-----------------------------------------------------------------------------
void C_EnvProjectedTexture::OnDataChanged( DataUpdateType_t updateType )
{
	if ( updateType == DATA_UPDATE_CREATED )
	{
		m_SpotlightTexture.Init( m_SpotlightTextureName, TEXTURE_GROUP_OTHER, true );
	}

	m_bForceUpdate = true;
	UpdateLight();
	BaseClass::OnDataChanged( updateType );
}
Пример #15
0
	void iLight3D::UpdateLogic(float afTimeStep)
	{
		UpdateLight(afTimeStep);
		if(mfFadeTime>0 || mbFlickering)
		{
			mbUpdateBoundingVolume = true;

			//This is so that the render container is updated.
			SetTransformUpdated();
		}
	}
void ASFlashlight::OnUnEquip()
{
	Super::OnUnEquip();

	if (Role == ROLE_Authority)
	{
		bIsActive = false;

		/* Turn off light while carried on belt  */
		UpdateLight(bIsActive);
	}
}
void ASFlashlight::OnEnterInventory(ASCharacter* NewOwner)
{
	if (Role == ROLE_Authority)
	{
		bIsActive = false;

		/* Turn off light while carried on belt  */
		UpdateLight(bIsActive);
	}

	Super::OnEnterInventory(NewOwner);
}
Пример #18
0
void CC4Projectile::CreateLight()
{
	if(m_pAmmoParams->pC4ExplosiveParams)
	{
		m_pLightSource = gEnv->p3DEngine->CreateLightSource();
		if(m_pLightSource)
		{
			UpdateLight(0.f, false);
			SetLightParams();
			gEnv->p3DEngine->RegisterEntity(m_pLightSource);
		}
	}
}
Пример #19
0
//---------------------------------------------------------
//---------------------------------------------------------
void CBounceBomb::OnRestore()
{
	BaseClass::OnRestore();
	if ( gpGlobals->eLoadType == MapLoad_Transition && !m_hSprite && m_LastSpriteColor.GetRawColor() != 0 )
	{
		UpdateLight( true, m_LastSpriteColor.r(), m_LastSpriteColor.g(), m_LastSpriteColor.b(), m_LastSpriteColor.a() );
	}

	if( VPhysicsGetObject() )
	{
		VPhysicsGetObject()->Wake();
	}
}
Пример #20
0
//------------------------------------------------------------------------
void CVehiclePartLight::ToggleLight(bool enable)
{
	if (enable && !IsEnabled())
  {
    // 0: no lights at all (only intended for debugging etc.)
    // 1: lights only enabled for the local player
    // 2: all lights enabled
    if (VehicleCVars().v_lights == 0
			|| (VehicleCVars().v_lights == 1 && !m_pVehicle->IsPlayerPassenger()))
      return;

		if (m_pHelper && m_damageRatio < 1.0f)
		{ 
      m_slot = GetEntity()->LoadLight(m_slot, &m_light);

      if (m_slot != -1)
			{
				if(m_pMaterial)
				{
					GetEntity()->SetSlotMaterial(m_slot, m_pMaterial);
				}

				if(m_lightViewDistanceRatio > 0)
				{
					SEntitySlotInfo slotInfo;
					if(GetEntity()->GetSlotInfo(m_slot, slotInfo) && (slotInfo.pLight != NULL))
					{
						slotInfo.pLight->SetViewDistRatio(m_lightViewDistanceRatio);
					}
				}
			}
			
		  UpdateLight(0.f);			
		}

		m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_Visible);
    m_enabled = true;
	}
	else if (!enable)
	{ 
    if (m_slot != -1)
    {
      GetEntity()->FreeSlot(m_slot);
      m_slot = -1;
    }  

		m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_NoUpdate);
    m_enabled = false;
	}

}
Пример #21
0
	static void SetUniforms()
	{
		if (sg_loaded)
		{
			glUseProgram(sg_shaderID);
			glUniformMatrix4fv(sg_projectionViewLocation, 1, false, glm::value_ptr(Engine::GetProjectionViewMatrix()));
			glUniform3fv(sg_cameraPositionLocation, 1, &sg_cameraPosition[0]);
			glUniform3fv(sg_ambientLightLocation, 1, &sg_lightAmbient[0]);
			for (unsigned int i = 0; i < sg_lightCount; ++i)
				UpdateLight(i);
			glUniform1ui(sg_lightCountLocation, sg_lightCount);
			glUniform1i(sg_textureLocation, 0);
		}
	}
Пример #22
0
void CC4Projectile::OnChangedTeam( EntityId entityId, int oldTeamId, int newTeamId )
{
	const EntityId clientId = g_pGame->GetClientActorId();
	if(entityId == clientId)
	{
		m_OnSameTeam = m_teamId ? m_teamId == newTeamId : GetOwnerId() == clientId;
		if(m_pLightSource)
		{
			UpdateLight(0.f, true); //Force colour update
		}
		if(gEnv->bMultiplayer)
		{
			SetupUIIcon();
		}
	}
}
Пример #23
0
void CC4Projectile::Update(SEntityUpdateContext &ctx, int updateSlot)
{
	if(gEnv->bMultiplayer)
	{
		IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerId);
		if(!pActor || pActor->IsDead())
		{
			if(gEnv->bServer)
			{
				Destroy();
			}
			else
			{
				GetEntity()->Hide(true);
			}

			RemoveLight();
			if(m_isShowingUIIcon)
			{
				SHUDEvent hudEvent(eHUDEvent_RemoveC4Icon);
				hudEvent.AddData((int)GetEntityId());
				CHUDEventDispatcher::CallEvent(hudEvent);
				m_isShowingUIIcon = false;
			}
		}
	}

	if(m_pLightSource)
	{
		UpdateLight(ctx.fFrameTime, false);
	}

	if(m_disarmTimer > 0.f)
	{
		m_disarmTimer -= ctx.fFrameTime;
		if(m_disarmTimer <= 0.f)
		{
			m_disarmTimer = 0.f;
			Arm(true);
		}
	}

	BaseClass::Update(ctx, updateSlot);
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : updateType - 
//-----------------------------------------------------------------------------
void C_EnvProjectedTexture::OnDataChanged(DataUpdateType_t updateType)
{

	if (updateType == DATA_UPDATE_CREATED)
	{
		if (m_bEnableShadows && r_flashlightdepthtexture.GetBool() && m_bClientWantsShadows)
		{
			m_SpotlightTexture.Init(m_SpotlightTextureName, TEXTURE_GROUP_OTHER, true);
		}
		else
		{
			m_SpotlightTexture.Init(m_SpotlightDX8TextureName, TEXTURE_GROUP_OTHER, true);
		}
	}

	m_bForceUpdate = true;
	UpdateLight();
	BaseClass::OnDataChanged(updateType);
}
Пример #25
0
/*
================
idExplodingBarrel::Think
================
*/
void idExplodingBarrel::Think()
{
	idBarrel::BarrelThink();
	
	UpdateLight();
	
	if( !common->IsClient() && state != BURNING && state != EXPLODING )
	{
		BecomeInactive( TH_THINK );
		return;
	}
	
	if( particleModelDefHandle >= 0 )
	{
		particleRenderEntity.origin = physicsObj.GetAbsBounds().GetCenter();
		particleRenderEntity.axis = mat3_identity;
		gameRenderWorld->UpdateEntityDef( particleModelDefHandle, &particleRenderEntity );
	}
}
Пример #26
0
void PeerSocket::Update()
{
    if(light_data_list.isEmpty()==false)
    {   
        emit UpdateLight(light_data_list);
        light_data_list.clear();
    }
    if(temperature_data_list.isEmpty()==false&&humidity_data_list.isEmpty()==false)
    {
        emit UpdataTemperatureAndHumidity(temperature_data_list,humidity_data_list);
        temperature_data_list.clear();
        humidity_data_list.clear();
    }
    if(!old_temperature_data_list.isEmpty())
    {
        emit UpdateTemperature_Old(old_temperature_data_list);
        old_temperature_data_list.clear();
    }

}
Пример #27
0
/**
*@brief 作成ボタンを押したときのスロット
*/
void LightSetWidget::SetSlot()
{
    std::string n = (const char*)NameEdit->currentText().toLocal8Bit();
    float px = PosXspinBox->value();
    float py = PosYspinBox->value();
    float pz = PosZspinBox->value();

    float red = RedspinBox->value();
    float green = GreenspinBox->value();
    float blue = BluespinBox->value();


    if(EC)
    {
        if(n == "")
        {
            return;
        }
        else if(EC->getLightByName(n.c_str()))
        {
            return;
        }
        else
        {

            LightObj *ml = EC->CreateQtLight(n.c_str());
            ml->SetPosition(px, py, pz);
            ml->setColor(red, green, blue);




            UpdateList();
            emit UpdateLight();
            NameEdit->setCurrentIndex(NameEdit->count()-1);

        }
    }
}
Пример #28
0
void AppGUI::Tick(RenderEngine& engine)
{
    UpdateShader(engine);
    switch (m_cache->PageSelected.Get())
    {
    case PAGE_SCENE:
        UpdateScene(engine);
        break;
    case PAGE_AREA:
        UpdateTerrain(engine);
        UpdateTexture(engine);
        break;
    case PAGE_MESH:
        UpdateMesh();
        UpdateWater();
        UpdateEmitter();
        break;
    case PAGE_POST:
        UpdateLight();
        UpdatePost(engine);
        break;
    }
}
Пример #29
0
//---------------------------------------------------------
//---------------------------------------------------------
void CBounceBomb::ExplodeThink()
{
	SetSolid( SOLID_NONE );

	// Don't catch self in own explosion!
	m_takedamage = DAMAGE_NO;

	if( m_hSprite )
	{
		UpdateLight( false, 0, 0, 0, 0 );
	}

	if( m_pWarnSound )
	{
		CSoundEnvelopeController &controller = CSoundEnvelopeController::GetController();
		controller.SoundDestroy( m_pWarnSound );
	}


	CBaseEntity *pThrower = HasPhysicsAttacker( 0.5 );

	ExplosionCreate( GetAbsOrigin(), GetAbsAngles(), (pThrower) ? pThrower : this, static_cast<int>(BOUNCEBOMB_EXPLODE_DAMAGE), static_cast<int>(BOUNCEBOMB_EXPLODE_RADIUS), true );
	UTIL_Remove( this );
}
Пример #30
0
//-----------------------------------------------------------------------------
// Name: 描画処理。
//-----------------------------------------------------------------------------
VOID Render()
{
	// 画面をクリア。
	g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
	
	static int renderCount = 0;
	
	if (SUCCEEDED(g_pd3dDevice->BeginScene()))
	{
		renderCount++;
		D3DXMATRIXA16 matWorld;
    	D3DXMatrixRotationY( &g_worldMatrix, renderCount / 500.0f ); 
    	g_rotationMatrix = g_worldMatrix;
		//ライトを更新
		UpdateLight();
		// Turn on the zbuffer
		g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
		
		//シェーダー適用開始。
		g_pEffect->SetTechnique("SkinModel");
		g_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE);
		g_pEffect->BeginPass(0);

		//定数レジスタに設定するカラー。
		D3DXVECTOR4 color( 1.0f, 0.0f, 0.0f, 1.0f);
		//ワールド行列の転送。
		g_pEffect->SetMatrix("g_worldMatrix", &g_worldMatrix);
		//ビュー行列の転送。
		g_pEffect->SetMatrix("g_viewMatrix", &camera.GetViewMatrix());				//@カメラクラスを作るためのヒント。 カメラクラスのゲッターを使用するようにする。
		//プロジェクション行列の転送。
		g_pEffect->SetMatrix("g_projectionMatrix", &camera.GetProjectionMatrix());	//@カメラクラスを作るためのヒント。 カメラクラスのゲッターを使用するようにする。
		//回転行列を転送。
		g_pEffect->SetMatrix( "g_rotationMatrix", &g_rotationMatrix );
		//ライトの向きを転送。
		g_pEffect->SetVectorArray("g_diffuseLightDirection", g_diffuseLightDirection, LIGHT_NUM );
		//ライトのカラーを転送。
		g_pEffect->SetVectorArray("g_diffuseLightColor", g_diffuseLightColor, LIGHT_NUM );
		//環境光を設定。
		g_pEffect->SetVector("g_ambientLight", &g_ambientLight);

		g_pEffect->CommitChanges();						//この関数を呼び出すことで、データの転送が確定する。描画を行う前に一回だけ呼び出す。
		
		// Meshes are divided into subsets, one for each material. Render them in
        // a loop
        for( DWORD i = 0; i < g_dwNumMaterials; i++ )
        {
			g_pEffect->SetTexture("g_diffuseTexture", g_pMeshTextures[i]);
            // Draw the mesh subset
            g_pMesh->DrawSubset( i );
        }
        
		g_pEffect->EndPass();
		g_pEffect->End();

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the backbuffer contents to the display
	g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}