void SlowBeatLights() { AdjustBrightness(); //figure out a good brightness increase int beatBri = (int)(currentBri * 1.25f); if (beatBri > 255) beatBri = 255; //transition the color immediately UpdateLights(beatBri, 0, 2); //fade brightness UpdateLights(5, 0, 8); //fade }
void CycleLights() { //this is called once per second if no beats are detected CycleHue(3000); AdjustBrightness(); UpdateLights(currentBri, 0, 10); }
void cWorld3D::Update(float afTimeStep) { START_TIMING(Physics); if(mpPhysicsWorld) mpPhysicsWorld->Update(afTimeStep); STOP_TIMING(Physics); START_TIMING(Entities); UpdateEntities(afTimeStep); STOP_TIMING(Entities); START_TIMING(Bodies); UpdateBodies(afTimeStep); STOP_TIMING(Bodies); START_TIMING(Particles); UpdateParticles(afTimeStep); STOP_TIMING(Particles); START_TIMING(Lights); UpdateLights(afTimeStep); STOP_TIMING(Lights); START_TIMING(SoundEntities); UpdateSoundEntities(afTimeStep); STOP_TIMING(SoundEntities); }
void CArtefact::UpdateWorkload (u32 dt) { VERIFY(!physics_world()->Processing()); // particles - velocity Fvector vel = {0, 0, 0}; if (H_Parent()) { CPhysicsShellHolder* pPhysicsShellHolder = smart_cast<CPhysicsShellHolder*>(H_Parent()); if(pPhysicsShellHolder) pPhysicsShellHolder->PHGetLinearVell(vel); } CParticlesPlayer::SetParentVel (vel); // UpdateLights (); if(m_activationObj && m_activationObj->IsInProgress()) { CPHUpdateObject::Activate (); m_activationObj->UpdateActivation (); return; } // custom-logic if(!CAttachableItem::enabled()) UpdateCLChild (); }
void idGLDrawableView::draw(int x, int y, int w, int h) { int i; renderView_t refdef; const idMaterial *mat = material; if (mat) { qglViewport(x, y, w, h); qglScissor(x, y, w, h); qglMatrixMode(GL_PROJECTION); qglClearColor( 0.1f, 0.1f, 0.1f, 0.0f ); qglClear(GL_COLOR_BUFFER_BIT); UpdateLights(); // render it renderSystem->BeginFrame(w, h); memset( &refdef, 0, sizeof( refdef ) ); UpdateCamera( &refdef ); // Copy global shaderparms to view for( i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++ ) { refdef.shaderParms[ i ] = globalParms[ i ]; } refdef.width = SCREEN_WIDTH; refdef.height = SCREEN_HEIGHT; refdef.fov_x = 90; refdef.fov_y = 2 * atan((float)h / w) * idMath::M_RAD2DEG; refdef.time = eventLoop->Milliseconds(); world->RenderScene( &refdef ); if ( showLights ) { drawLights( &refdef ); } renderSystem->EndFrame( NULL, NULL ); world->DebugClearLines( refdef.time ); qglMatrixMode( GL_MODELVIEW ); qglLoadIdentity(); } }
void CActorViewer::CreateScene() { auto screenSize = Palleon::CGraphicDevice::GetInstance().GetScreenSize(); { auto camera = Palleon::CCamera::Create(); camera->SetPerspectiveProjection(MAIN_CAMERA_FOV, screenSize.x / screenSize.y, MAIN_CAMERA_NEAR_Z, MAIN_CAMERA_FAR_Z, Palleon::HANDEDNESS_RIGHTHANDED); m_mainCamera = camera; } { auto viewport = Palleon::CViewport::Create(); viewport->SetCamera(m_mainCamera); m_mainViewport = viewport; } UpdateLights(); }
void CScene::Render(ID3D11DeviceContext*pd3dDeviceContext, CCamera *pCamera) { if (m_pLights && m_pd3dcbLights) { /*두 번째 조명은 플레이어가 가지고 있는 손전등이다. 그러므로 카메라의 위치가 바뀌면 조명의 위치와 방향을 카메라의 위치와 방향으로 변경한다.*/ D3DXVECTOR3 d3dxvCameraPosition = pCamera->GetPosition(); m_pLights->m_d3dxvCameraPosition = D3DXVECTOR4(d3dxvCameraPosition, 1.0f); m_pLights->m_pLights[1].m_d3dxvPosition = d3dxvCameraPosition; m_pLights->m_pLights[1].m_d3dxvDirection = pCamera->GetLookVector(); UpdateLights(pd3dDeviceContext); } for (int i = 0; i < m_nShaders; i++) { m_ppShaders[i]->Render(pd3dDeviceContext, pCamera); } }
extern "C" void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName) { //set Hue registration command const char json[] = "{\"devicetype\":\"Kodi\",\"username\":\"KodiVisWave\"}"; //struct curl_slist *headers = NULL; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1); curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); //curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json); // Set the URL that is about to receive our POST. curl_easy_setopt(curl, CURLOPT_URL, strURLRegistration.c_str()); // Perform the request, res will get the return code res = curl_easy_perform(curl); // always cleanup (at the end) } //turn the lights on TurnLightsOn(); UpdateLights(currentBri, 255, 30); //initialize the beat detection InitTime(); g_fftobj.Init(576, NUM_FREQUENCIES); //initialize the moving average of mids for (int i = 0; i<15; i++) { g_movingAvgMid[i] = 0; } }
// Updating void VoxGame::Update() { // FPS #ifdef _WIN32 QueryPerformanceCounter(&m_fpsCurrentTicks); m_deltaTime = ((float)(m_fpsCurrentTicks.QuadPart - m_fpsPreviousTicks.QuadPart) / (float)m_fpsTicksPerSecond.QuadPart); #else struct timeval tm; gettimeofday(&tm, NULL); m_fpsCurrentTicks = (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0; m_deltaTime = (m_fpsCurrentTicks - m_fpsPreviousTicks); #endif //_WIN32 m_fps = 1.0f / m_deltaTime; m_fpsPreviousTicks = m_fpsCurrentTicks; // Update interpolator singleton Interpolator::GetInstance()->Update(m_deltaTime); // Pause the interpolator we are are paused. Interpolator::GetInstance()->SetPaused(m_bPaused); // Update the time manager (countdowntimers); TimeManager::GetInstance()->Update(m_deltaTime); // Update the initial wait timer and variables, so we dont do gameplay updates straight away if (m_initialStartWait == true) { if (m_initialWaitTimer > m_initialWaitTime) { m_initialStartWait = false; } else { m_initialWaitTimer += m_deltaTime; m_initialStartWait = true; } } // Animation update if (m_bPaused == false && m_initialStartWait == false) { // Update the lighting manager m_pLightingManager->Update(m_deltaTime); // Block particle manager m_pBlockParticleManager->Update(m_deltaTime); // Instance manager m_pInstanceManager->Update(m_deltaTime); // Scenery manager m_pSceneryManager->Update(m_deltaTime); // Inventory manager m_pInventoryManager->Update(m_deltaTime); // Item manager m_pItemManager->Update(m_deltaTime); m_pItemManager->UpdateItemLights(m_deltaTime); m_pItemManager->UpdateItemParticleEffects(m_deltaTime); m_interactItemMutex.lock(); m_pInteractItem = m_pItemManager->CheckItemPlayerInteraction(); m_interactItemMutex.unlock(); // Projectile manager m_pProjectileManager->Update(m_deltaTime); m_pProjectileManager->UpdateProjectileLights(m_deltaTime); m_pProjectileManager->UpdateProjectileParticleEffects(m_deltaTime); // Text effects manager m_pTextEffectsManager->Update(m_deltaTime); // Player if (m_animationUpdate) { m_pPlayer->Update(m_deltaTime); } // Camera faked position if (m_cameraMode == CameraMode_MouseRotate || m_cameraMode == CameraMode_AutoCamera || m_cameraMode == CameraMode_NPCDialog) { vec3 playerMovementChanged = m_pPlayer->GetPositionMovementAmount(); m_pGameCamera->SetFakePosition(m_pGameCamera->GetFakePosition() + playerMovementChanged); } } // Update the chunk manager m_pChunkManager->Update(m_deltaTime); // Update controls UpdateControls(m_deltaTime); // Update the camera based on movements if (m_gameMode == GameMode_Game) { UpdateCamera(m_deltaTime); m_pPlayer->SetCameraPosition(m_pGameCamera->GetPosition()); m_pPlayer->SetCameraForward(normalize(m_pGameCamera->GetFacing())); } // Update the dynamic camera zoom UpdateCameraZoom(m_deltaTime); // Update the camera clipping m_targetCameraPositionBeforeClipping = m_pGameCamera->GetFakePosition(); UpdateCameraClipping(m_deltaTime); // Update the player's alpha and transparency based on camera distance to player if (m_gameMode == GameMode_Game && m_cameraMode != CameraMode_Debug) { UpdatePlayerAlpha(m_deltaTime); } // Update the frontend m_pFrontendManager->Update(m_deltaTime); // Update the GUI int x = m_pVoxWindow->GetCursorX(); int y = m_pVoxWindow->GetCursorY(); m_pGUI->Update(m_deltaTime); if (m_pVoxWindow->IsCursorOn()) { m_pGUI->ImportMouseMotion(x, m_windowHeight - y); } UpdateGUI(m_deltaTime); if (m_bPaused == false && m_initialStartWait == false) { // Update game GUI UpdateGameGUI(m_deltaTime); // Update lights UpdateLights(m_deltaTime); } // Update the application and window m_pVoxApplication->Update(m_deltaTime); m_pVoxWindow->Update(m_deltaTime); }
void Scene::UpdateScene(double fTime, float fElapsedTime) { { static bool bOneTime = true; if(bMovingLights || bOneTime) { UpdateLights(fTime); bOneTime = false; } } if(bMovingMeshes) { // copy current to previous (for use in per instance logic) memcpy((void*)m_MeshPreviousWorlds, (void*)m_MeshWorlds, m_iNumActiveInstances * sizeof(D3DXMATRIX)); if(m_iNumUpdateThreads == 0) // non threaded updates { for(int i = 0; i < m_iNumActiveInstances; i++) { UpdateInstance(i, (float)fTime, fElapsedTime); } } else { for(int iThread = 0; iThread < m_iNumUpdateThreads; iThread++) { int iStart = iThread * m_iNumActiveInstances / m_iNumUpdateThreads; int iEnd = iStart + (m_iNumActiveInstances / m_iNumUpdateThreads) - 1; if(iThread == m_iNumUpdateThreads - 1) iEnd = m_iNumActiveInstances - 1; // last thread catches the slop m_threadShared[iThread].iStartMeshIndex = iStart; m_threadShared[iThread].iEndMeshIndex = iEnd; m_threadShared[iThread].fTime = (float)fTime; m_threadShared[iThread].fElapsedTime = (float)fElapsedTime; // set event to begin on all scene thread SetEvent(m_hBeginInstanceUpdateEvent[iThread]); m_threadActive[iThread] = true; } // $$ For now just block, but in the future, render can use m_threadActive + start/end to know if a mesh is ready to be rendered; // wait for completion WaitForMultipleObjects(m_iNumUpdateThreads, m_hEndInstanceUpdateEvent, TRUE, INFINITE); for(int iThread = 0; iThread < m_iNumUpdateThreads; iThread++) { m_threadActive[iThread] = false; } } } }
// Updating void VoxGame::Update() { // FPS #ifdef _WIN32 QueryPerformanceCounter(&m_fpsCurrentTicks); m_deltaTime = ((float)(m_fpsCurrentTicks.QuadPart - m_fpsPreviousTicks.QuadPart) / (float)m_fpsTicksPerSecond.QuadPart); #else struct timeval tm; gettimeofday(&tm, NULL); m_fpsCurrentTicks = (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0; m_deltaTime = (m_fpsCurrentTicks - m_fpsPreviousTicks); #endif //_WIN32 m_fps = 1.0f / m_deltaTime; m_fpsPreviousTicks = m_fpsCurrentTicks; float maxDeltaTime = 0.25f; if (m_deltaTime > maxDeltaTime) { cout << "Warning: DeltaTime exceeded sensible value, switching dt from " << m_deltaTime << " to " << maxDeltaTime << ".\n"; m_deltaTime = maxDeltaTime; } // Update interpolator singleton Interpolator::GetInstance()->Update(m_deltaTime); // Pause the interpolator we are are paused. Interpolator::GetInstance()->SetPaused(m_bPaused); // Update the time manager (countdowntimers); TimeManager::GetInstance()->Update(m_deltaTime); // Update the audio manager AudioManager::GetInstance()->Update(m_pGameCamera->GetPosition(), m_pGameCamera->GetFacing(), m_pGameCamera->GetUp()); // Update the initial wait timer and variables, so we dont do gameplay updates straight away if (m_initialStartWait == true) { if (m_initialWaitTimer > m_initialWaitTime) { m_initialStartWait = false; } else { m_initialWaitTimer += m_deltaTime; m_initialStartWait = true; } } // Update the current biome Biome currentBiome = m_pBiomeManager->GetBiome(m_pPlayer->GetCenter()); if (currentBiome != m_currentBiome) { m_pSkybox->SetCurrentBiome(currentBiome); m_currentBiome = currentBiome; } // Update game music if (m_gameMode == GameMode_Game) { UpdateGameMusic(m_deltaTime); } UpdateMusicVolume(0.0f); // Main components update if (m_bPaused == false && m_initialStartWait == false) { // Update the lighting manager m_pLightingManager->Update(m_deltaTime); // Block particle manager m_pBlockParticleManager->Update(m_deltaTime); // Instance manager m_pInstanceManager->Update(m_deltaTime); // Scenery manager m_pSceneryManager->Update(m_deltaTime); // Inventory manager m_pInventoryManager->Update(m_deltaTime); // Item manager m_pItemManager->Update(m_deltaTime); m_pItemManager->UpdateItemLights(m_deltaTime); m_pItemManager->UpdateItemParticleEffects(m_deltaTime); m_interactItemMutex.lock(); m_pInteractItem = m_pItemManager->CheckItemPlayerInteraction(); m_interactItemMutex.unlock(); // Projectile manager m_pProjectileManager->Update(m_deltaTime); m_pProjectileManager->UpdateProjectileLights(m_deltaTime); m_pProjectileManager->UpdateProjectileParticleEffects(m_deltaTime); // Text effects manager m_pTextEffectsManager->Update(m_deltaTime); // Update the NPC manager m_pNPCManager->Update(m_deltaTime); // Update the enemy manager m_pEnemyManager->Update(m_deltaTime); // Update the biome manager m_pBiomeManager->Update(m_deltaTime); // Player if (m_animationUpdate) { m_pPlayer->Update(m_deltaTime); } // Camera faked position if (m_cameraMode == CameraMode_MouseRotate || m_cameraMode == CameraMode_AutoCamera || m_cameraMode == CameraMode_NPCDialog) { vec3 playerMovementChanged = m_pPlayer->GetPositionMovementAmount(); m_pGameCamera->SetFakePosition(m_pGameCamera->GetFakePosition() + playerMovementChanged); } // Water m_elapsedWaterTime += m_deltaTime; } // Update the chunk manager m_pChunkManager->Update(m_deltaTime); // Update name picking if (m_pGUI->IsMouseInteractingWithGUIComponent(false) == false) { UpdateNamePicking(); } // Update the NPC hover selection based on the mouse name picking if (m_gameMode == GameMode_FrontEnd) { if (m_bNamePickingSelected) { m_pNPCManager->UpdateHoverNamePickingSelection(m_pickedObject); } else { m_pNPCManager->UpdateHoverNamePickingSelection(-1); } } // Update controls UpdateControls(m_deltaTime); // Update the camera based on movements if (m_gameMode == GameMode_Game) { UpdateCamera(m_deltaTime); m_pPlayer->SetCameraPosition(m_pGameCamera->GetPosition()); m_pPlayer->SetCameraForward(normalize(m_pGameCamera->GetFacing())); m_pPlayer->SetCameraUp(normalize(m_pGameCamera->GetUp())); m_pPlayer->SetCameraRight(normalize(m_pGameCamera->GetRight())); } // Update the dynamic camera zoom UpdateCameraZoom(m_deltaTime); // Update the camera clipping m_targetCameraPositionBeforeClipping = m_pGameCamera->GetFakePosition(); UpdateCameraClipping(m_deltaTime); // Update the player's alpha and transparency based on camera distance to player if (m_gameMode == GameMode_Game && m_cameraMode != CameraMode_Debug) { UpdatePlayerAlpha(m_deltaTime); } // Update the frontend m_pFrontendManager->Update(m_deltaTime); // Update the GUI int x = m_pVoxWindow->GetCursorX(); int y = m_pVoxWindow->GetCursorY(); m_pGUI->Update(m_deltaTime); if (IsCursorOn()) { m_pGUI->ImportMouseMotion(x, m_windowHeight - y); } UpdateGUI(m_deltaTime); if (m_bPaused == false && m_initialStartWait == false) { // Update game GUI UpdateGameGUI(m_deltaTime); // Update lights UpdateLights(m_deltaTime); } // Update the application and window m_pVoxWindow->Update(m_deltaTime); }
// initalise the OpenGL context void C3dView::InitGL ( long iX,long iY) { m_iViewportX = iX; m_iViewportY = iY; m_fAspect = 1.33f; if (m_iViewportY != 0) m_fAspect = (float) m_iViewportX / (float) m_iViewportY; // set the projection matrix and viewport info SetDepthRange(m_xNearZ,m_xFarZ); // set the BG color glClearColor ((float)m_BackGroundColor.r, (float)m_BackGroundColor.g, (float)m_BackGroundColor.b, 1.0); glClearDepth(1.0f); // Depth Buffer Setup // make everything look it's best not fastest. glHint(GL_PERSPECTIVE_CORRECTION_HINT ,GL_NICEST); // we want a z buffer glEnable (GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do // we want back face culling glEnable (GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CCW); // we want smooth filled polies glShadeModel (GL_SMOOTH); glPolygonMode (GL_FRONT, GL_FILL); glEnable (GL_LIGHTING); EnabletLight(0,true); float f[4] = {1.0f}; f[0] = f[1] = f[2] = 0.25f; SetLightInfo(0,eLightAmb,f); f[0] = f[1] = f[2] = 0.60f; SetLightInfo(0,eLightDif,f); f[0] = f[1] = f[2] = 0.60f; SetLightInfo(0,eLightSpec,f); f[0] = 0;f[1] = 0;f[2] = 10.0f; SetLightInfo(0,eLightPos,f); UpdateLights(); // but only enable one ?!? // glEnable (GL_LIGHT0); // we want alpha based transperancy glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_COLOR_MATERIAL); // clear out the model view matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity (); }
bool Lighting::EvaluateLighting(LPDIRECT3DDEVICE9 Device, RenderMesh *RMesh, ShaderMat *Mat) { D3DLIGHT9 DLight; D3DXVECTOR3 Pos,Dir; RenderLight Light; int i; if(!Device || !RMesh || !m_Ready) { return(false); } m_Device = Device; // // Setup // // The force update is used when the scene is in an unknwon state - usual after a an undo of a light if(m_forceUpdate) GetLightsFromScene(); UpdateLights(); SetRenderStates(); // m_Lights.clear(); if(m_Lights.size()) { for(i=0; i < m_Lights.size(); i++) { SetShader(m_Lights[i].m_Type,Mat); SetMaterialConst(Mat); SetShaderConst(i,&m_Lights[i],Mat); RMesh->Render(m_Device); } } else { m_Device->GetLight(0,&DLight); Light.m_Dir = Point3(-DLight.Direction.x, -DLight.Direction.y, -DLight.Direction.z); Light.m_Color.x = DLight.Diffuse.r; Light.m_Color.y = DLight.Diffuse.g; Light.m_Color.z = DLight.Diffuse.b; Light.m_Pos.x = DLight.Position.x; Light.m_Pos.y = DLight.Position.y; Light.m_Pos.z = DLight.Position.z; Light.m_InnerRange = 1.0f; Light.m_OuterRange = 1.0f / (DLight.Range * 2.0f); SetShader(LIGHT_DIR,Mat); SetMaterialConst(Mat); SetShaderConst(0,&Light,Mat); RMesh->Render(m_Device); } return(true); }
// Updating void VoxGame::Update() { // FPS #ifdef _WIN32 QueryPerformanceCounter(&m_fpsCurrentTicks); m_deltaTime = ((float)(m_fpsCurrentTicks.QuadPart - m_fpsPreviousTicks.QuadPart) / (float)m_fpsTicksPerSecond.QuadPart); #else struct timeval tm; gettimeofday(&tm, NULL); m_fpsCurrentTicks = (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0; m_deltaTime = (m_fpsCurrentTicks - m_fpsPreviousTicks); #endif //_WIN32 m_fps = 1.0f / m_deltaTime; m_fpsPreviousTicks = m_fpsCurrentTicks; // Update interpolator singleton Interpolator::GetInstance()->Update(m_deltaTime); // Pause the interpolator if animations are paused. Interpolator::GetInstance()->SetPaused(m_animationUpdate == false); // Update the time manager (countdowntimers); TimeManager::GetInstance()->Update(m_deltaTime); // Animation update if (m_animationUpdate) { // Update the lighting manager m_pLightingManager->Update(m_deltaTime); // Block particle manager m_pBlockParticleManager->Update(m_deltaTime); // Player m_pPlayer->Update(m_deltaTime); if (m_cameraMode == CameraMode_MouseRotate || m_cameraMode == CameraMode_AutoCamera) { vec3 playerMovementChanged = m_pPlayer->GetPositionMovementAmount(); m_pGameCamera->SetFakePosition(m_pGameCamera->GetFakePosition() + playerMovementChanged); } } // Update the chunk manager m_pChunkManager->Update(m_deltaTime); // Update controls UpdateControls(m_deltaTime); // Update the camera based on movements if (m_gameMode == GameMode_Game) { UpdateCamera(m_deltaTime); } // Update the dynamic camera zoom UpdateCameraZoom(m_deltaTime); // Update the camera clipping m_targetCameraPositionBeforeClipping = m_pGameCamera->GetFakePosition(); UpdateCameraClipping(m_deltaTime); // Update the player's alpha and transparency based on camera distance to player if (m_gameMode == GameMode_Game && m_cameraMode != CameraMode_Debug) { UpdatePlayerAlpha(m_deltaTime); } // Update the GUI int x = m_pVoxWindow->GetCursorX(); int y = m_pVoxWindow->GetCursorY(); m_pGUI->Update(m_deltaTime); if (m_pVoxWindow->IsCursorOn()) { m_pGUI->ImportMouseMotion(x, m_windowHeight - y); } UpdateGUI(m_deltaTime); // Update lights UpdateLights(m_deltaTime); // Update the application and window m_pVoxApplication->Update(m_deltaTime); m_pVoxWindow->Update(m_deltaTime); }
//------------------------------------------------------------------ // Storm3D_Scene_LightHandler::UpdateLights //------------------------------------------------------------------ Storm3D_Scene_LightHandler::Storm3D_Scene_LightHandler(Storm3D *s2,Storm3D_Scene *scene) : Storm3D2(s2) { UpdateLights(scene); }