Exemple #1
0
//-----------------------------------------------------------------------------
// The scene manager class destructor.
//-----------------------------------------------------------------------------
SceneManager::~SceneManager()
{
	DestroyScene();

	// Destroy the dynamic objects list as it was created in the constructor.
	SAFE_DELETE( m_dynamicObjects );
}
void WorldSceneManager::PktNode_CreateNodeSceneRst(class PacketCreateNodeSceneRst* pPkt)
{
	if(!pPkt)
		return;

	int32 nSceneID = pPkt->nSceneID;
	CreatingSceneMap& map = m_mapCreatingScenes;

	WorldScene* pScene = map.GetItem(nSceneID);
	if(!pScene)
		return;

	map.RemoveItem(nSceneID);

	WorldSceneInfo* pSI = (WorldSceneInfo*)pScene->GetSceneInfo();
	if( pPkt->nCreateFlag == eScene_Create_Succeed)
	{
		pScene->SetSceneState( Scene::eSceneState_Running );
		pScene->SetArenaID( pPkt->nArenaID );
		pScene->OnCreateSucceed();
		pSI->OnSceneCreateSucceed(pScene);
		m_ScenesTickList.Add( pScene->GetTickNode());
	}
	else
	{
		pSI->OnSceneCreateFailed( pScene, eCreateSceneError_CreateNodeScene);
		DestroyScene(nSceneID);

		MyLog::message("Node Create Scene Failed SceneSID[%d], SceneID[%d]", SceneInfo::GetSceneSID(nSceneID), nSceneID);
	}
}
Exemple #3
0
void CALLBACK OnD3D11DestroyDevice(void* userContext)
{
    DestroyApp();
    DestroyScene();
    
    gDialogResourceManager.OnD3D11DestroyDevice();
    gD3DSettingsDlg.OnD3D11DestroyDevice();
    DXUTGetGlobalResourceCache().OnDestroyDevice();
    SAFE_DELETE(gTextHelper);
}
void FPxScene::TerminateLevel()
{
	pxguard(FPxScene::TerminateLevel);
	PX_LOG( PX_NAME, TEXT("%s >> %s ::"), PX_LOGP );
		
	DestroyScene();

	PX_LOG( PX_NAME, TEXT("%s << %s ::"), PX_LOGP );
	unguard;
}
dPluginInterface::~dPluginInterface(void)
{
	while (m_allPlugins.GetFirst()) {
		FreeLibrary(m_allPlugins.GetFirst()->GetInfo());
		m_allPlugins.Remove(m_allPlugins.GetFirst());
	}

	DestroyScene ();

	m_render->Release();
}
void CDirect3D11::OnDestroy()
{
	DestroyScene();

	CTextureManager::GetInstance()->OnDestroy();

	if( m_pd3dDeviceContext )
	{
		m_pd3dDeviceContext->ClearState();
	}

	if( m_pd3dDepthStencilView )
	{
		m_pd3dDepthStencilView->Release();
		m_pd3dDepthStencilView = NULL;
	}

	if ( m_pd3dDSResouceView )
	{
		m_pd3dDSResouceView->Release();
		m_pd3dDSResouceView = NULL;
	}

	if( m_d3dDepthStencilBuffer )
	{
		m_d3dDepthStencilBuffer->Release();
		m_d3dDepthStencilBuffer = NULL;
	}

	if( m_pd3dRenderTargetView )
	{
		m_pd3dRenderTargetView->Release();
		m_pd3dRenderTargetView = NULL;
	}

	if( m_pdxgiSwapChain )
	{
		m_pdxgiSwapChain->Release();
		m_pdxgiSwapChain = NULL;
	}

	if( m_pd3dDeviceContext )
	{
		m_pd3dDeviceContext->Release();
		m_pd3dDeviceContext = NULL;
	}

	if( m_pd3dDevice )
	{
		m_pd3dDevice->Release();
		m_pd3dDevice = NULL;
	}
}
Exemple #7
0
void CWBQuadScene::Release(uint32 uSlot, CTrMirrorBuffer* pMgr)
{
	CMirrorBuffer* pBuffer = pMgr->GetWriteBuffer();

	pBuffer->RestoreIdleSlot(uSlot);

	CMirrorPatch* pPatch = pMgr->GetCurWBPatch();
	pPatch->AddCmd(new (pPatch)CWBQuadSceneReleasedCmd(uSlot));

	pMgr->AddDiscardedCmd(uSlot);

	DestroyScene();
}
void WorldSceneManager::OnCreatingSceneTimeout(WorldScene* pScene)
{
	int32 nSceneID = pScene->GetSceneID();

	MyLog::error("Delete Pending Scene id = %d", nSceneID);

	// close process
	WorldSceneInfo* pInfo = (WorldSceneInfo*)pScene->GetSceneInfo();
	if(!pInfo)
		return;

	pInfo->OnSceneCreateFailed( pScene, eCreateSceneError_Timeout);

	PacketDestroyScene pkt;
	pkt.nSceneID = pScene->GetSceneID();
	Send2Node( &pkt, pScene->GetNodeID() );
	DestroyScene( nSceneID );
}
void GLFluidsCanvas::Restart (void)
{
  Disable();
  m_run = false;
  m_init = false;
  DestroyScene();

  m_width = m_currentConfig->width; m_height = m_currentConfig->height;
  glViewport (0, 0, m_width, m_height);
  m_camera = new Camera (m_width, m_height, m_currentConfig->clipping);

  InitUISettings();
  InitSolvers();
  m_swatch->Start();
  m_init = true;
  m_run = true;
  cerr << "Réinitialisation terminée" << endl;
  Enable();
}
Exemple #10
0
void CALLBACK OnGUIEvent(UINT eventID, INT controlID, CDXUTControl* control, void* userContext)
{
    switch (controlID) {
        case UI_TOGGLEFULLSCREEN:
            DXUTToggleFullScreen(); break;
        case UI_TOGGLEWARP:
            DXUTToggleWARP(); break;
        case UI_CHANGEDEVICE:
            gD3DSettingsDlg.SetActive(!gD3DSettingsDlg.IsActive()); break;
        case UI_LIGHTINGONLY:
            gUIConstants.lightingOnly = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;
        case UI_FACENORMALS:
            gUIConstants.faceNormals = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;        
        case UI_VISUALIZELIGHTCOUNT:
            gUIConstants.visualizeLightCount = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;            
        case UI_VISUALIZEPERSAMPLESHADING:
            gUIConstants.visualizePerSampleShading = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break;            
        case UI_SELECTEDSCENE:
            DestroyScene(); break;
        case UI_LIGHTS:
            gApp->SetActiveLights(DXUTGetD3D11Device(), 1 << gLightsSlider->GetValue()); break;
        case UI_CULLTECHNIQUE:
            gUIConstants.lightCullTechnique = static_cast<unsigned int>(PtrToUlong(gCullTechniqueCombo->GetSelectedData())); break;

        // These controls all imply changing parameters to the App constructor
        // (i.e. recreating resources and such), so we'll just clean up the app here and let it be
        // lazily recreated next render.
        case UI_MSAA:
            DestroyApp(); break;

        default:
            break;
    }

    UpdateUIState();
}
Exemple #11
0
void InitScene(ID3D11Device* d3dDevice)
{
    DestroyScene();
    D3DXVECTOR3 cameraEye(0.0f, 0.0f, 0.0f);
    D3DXVECTOR3 cameraAt(0.0f, 0.0f, 0.0f);
    float sceneScaling = 1.0f;
    D3DXVECTOR3 sceneTranslation(0.0f, 0.0f, 0.0f);
    bool zAxisUp = false;

#pragma region Pick Scene
    SCENE_SELECTION scene = static_cast<SCENE_SELECTION>(PtrToUlong(gSceneSelectCombo->GetSelectedData()));
	scene = CUBES;
    switch (scene) {
		case CUBE_WORLD: {
#pragma region CUBE_WORLD
            sceneScaling = 1.0f;

			D3DXMatrixScaling(&gWorldMatrix, sceneScaling, sceneScaling, sceneScaling);
			if (zAxisUp) {
				D3DXMATRIXA16 m;
				D3DXMatrixRotationX(&m, -D3DX_PI / 2.0f);
				gWorldMatrix *= m;
			}
			{
				D3DXMATRIXA16 t;
				D3DXMatrixTranslation(&t, sceneTranslation.x, sceneTranslation.y, sceneTranslation.z);
				gWorldMatrix *= t;
			}

			sceneGraph.StartScene(gWorldMatrix,sceneScaling);

			sceneGraph.Add(d3dDevice, L"..\\media\\cube\\cube.sdkmesh",0,0,0,1,500,500);
            //gMeshOpaque.Create(d3dDevice, L"..\\media\\cube\\cube.sdkmesh");			
            LoadSkybox(d3dDevice, L"..\\media\\Skybox\\EmptySpace.dds");

            cameraEye = sceneScaling * D3DXVECTOR3(100.0f, 5.0f, 5.0f);
            cameraAt = sceneScaling * D3DXVECTOR3(0.0f, 0.0f, 0.0f);
        } break;
#pragma endregion
        case POWER_PLANT_SCENE: {
#pragma region POWER_PLANT_SCENE
            sceneScaling = 1.0f;

			D3DXMatrixScaling(&gWorldMatrix, sceneScaling, sceneScaling, sceneScaling);
			if (zAxisUp) {
				D3DXMATRIXA16 m;
				D3DXMatrixRotationX(&m, -D3DX_PI / 2.0f);
				gWorldMatrix *= m;
			}
			{
				D3DXMATRIXA16 t;
				D3DXMatrixTranslation(&t, sceneTranslation.x, sceneTranslation.y, sceneTranslation.z);
				gWorldMatrix *= t;
			}
			
			sceneGraph.StartScene(gWorldMatrix,sceneScaling);

			sceneGraph.Add(d3dDevice, L"..\\media\\powerplant\\powerplant.sdkmesh");
			//gMeshOpaque.Create(d3dDevice, L"..\\media\\powerplant\\powerplant.sdkmesh");
            LoadSkybox(d3dDevice, L"..\\media\\Skybox\\EmptySpace.dds");

            cameraEye = sceneScaling * D3DXVECTOR3(100.0f, 5.0f, 5.0f);
            cameraAt = sceneScaling * D3DXVECTOR3(0.0f, 0.0f, 0.0f);
        } break;
#pragma endregion
        case SPONZA_SCENE: {
#pragma region SPONZA_SCENE
            sceneScaling = 0.05f;

			D3DXMatrixScaling(&gWorldMatrix, sceneScaling, sceneScaling, sceneScaling);
			if (zAxisUp) {
				D3DXMATRIXA16 m;
				D3DXMatrixRotationX(&m, -D3DX_PI / 2.0f);
				gWorldMatrix *= m;
			}
			{
				D3DXMATRIXA16 t;
				D3DXMatrixTranslation(&t, sceneTranslation.x, sceneTranslation.y, sceneTranslation.z);
				gWorldMatrix *= t;
			}
			
			sceneGraph.StartScene(gWorldMatrix,sceneScaling);
			

			sceneGraph.Add(d3dDevice, L"..\\media\\Sponza\\sponza_dds.sdkmesh");
			//gMeshOpaque.Create(d3dDevice, L"..\\media\\Sponza\\sponza_dds.sdkmesh");
            LoadSkybox(d3dDevice, L"..\\media\\Skybox\\EmptySpace.dds");

            cameraEye = sceneScaling * D3DXVECTOR3(1200.0f, 200.0f, 100.0f);
            cameraAt = sceneScaling * D3DXVECTOR3(0.0f, 0.0f, 0.0f);
        } break;
#pragma endregion
		case MULTI_SCENE:{
#pragma region MULTI_SCENE
            sceneScaling = .05f;
			
			D3DXMatrixScaling(&gWorldMatrix, sceneScaling, sceneScaling, sceneScaling);
			if (zAxisUp) {
				D3DXMATRIXA16 m;
				D3DXMatrixRotationX(&m, -D3DX_PI / 2.0f);
				gWorldMatrix *= m;
			}
			{
				D3DXMATRIXA16 t;
				D3DXMatrixTranslation(&t, sceneTranslation.x, sceneTranslation.y, sceneTranslation.z);
				gWorldMatrix *= t;
			}
			
			sceneGraph.StartScene(gWorldMatrix,sceneScaling);

			sceneGraph.Add(d3dDevice, L"..\\media\\Sponza\\sponza_dds.sdkmesh");
			D3DXMATRIXA16 translate;
			D3DXMatrixTranslation(&translate,0,10,0);
			sceneGraph.Add(d3dDevice,L"..\\media\\powerplant\\powerplant.sdkmesh",translate);
			//gMeshOpaque.Create(d3dDevice, L"..\\media\\Sponza\\sponza_dds.sdkmesh");
			//gMeshOpaque2.Create(d3dDevice,L"..\\media\\powerplant\\powerplant.sdkmesh");
            LoadSkybox(d3dDevice, L"..\\media\\Skybox\\EmptySpace.dds");

            cameraEye = sceneScaling * D3DXVECTOR3(100.0f, 5.0f, 5.0f);
            cameraAt = sceneScaling * D3DXVECTOR3(0.0f, 0.0f, 0.0f);
		}break;
#pragma endregion
		case CUBES:
		{
#pragma region CUBES
			sceneScaling = 1.0f;

			D3DXMatrixScaling(&gWorldMatrix, sceneScaling, sceneScaling, sceneScaling);
			if (zAxisUp) {
				D3DXMATRIXA16 m;
				D3DXMatrixRotationX(&m, -D3DX_PI / 2.0f);
				gWorldMatrix *= m;
			}
			{
				D3DXMATRIXA16 t;
				D3DXMatrixTranslation(&t, sceneTranslation.x, sceneTranslation.y, sceneTranslation.z);
				gWorldMatrix *= t;
			}

			sceneGraph.StartScene(gWorldMatrix,sceneScaling);
			D3DXMATRIXA16 translate;
			D3DXMatrixTranslation(&translate,0,0,0);
			
			D3DXMATRIXA16 s;
			D3DXMatrixScaling(&s,100,0.01,100);
			s=s*translate;
			//sceneGraph.Add(d3dDevice, L"..\\media\\cube\\cube.sdkmesh",s);
			//sceneGraph.Add(d3dDevice, L"..\\media\\cube\\cube.sdkmesh",s);


			//Initializing PhysX
			if(!PXEngine)
				PXEngine = new PhysXEngine();
			sceneGraph.AddMeshInstance(d3dDevice, L"..\\media\\cube\\cube.sdkmesh");
			//sceneGraph.Add(d3dDevice,L"..\\media\\powerplant\\powerplant.sdkmesh",translate);
			if(PXEngine)
				PXEngine->InitializePhysX(cubeList, PhysXUnProject, PhysXProject);

			sceneGraph.Add(d3dDevice, L"..\\media\\cube\\cube.sdkmesh",0,0,0,1000,1000,1000);

			//Creating all of the cubes
			for(int i = 0; i < cubeList->size(); i++)
			{
				if(i%10==0)
				{
					sceneGraph.Add(d3dDevice, L"..\\media\\cube\\cube.sdkmesh",0,0,0,1,1,1);
				}
				else
					(*cubeList)[i]->id = sceneGraph.AddInstance(1,(*cubeList)[i]->x, (*cubeList)[i]->y, (*cubeList)[i]->z, (*cubeList)[i]->sx, (*cubeList)[i]->sy, (*cubeList)[i]->sz);
			}
/*
			for(float x =0; x<15;x+=5)
			{
				for(float y=0; y<15; y+=5)
				{
					for(float z=0; z<15; z+=5)
					{
						D3DXMatrixTranslation(&translate,x,y,z);
						sceneGraph.Add(d3dDevice, L"..\\media\\cube\\cube.sdkmesh",x,y,z,1,1,1);
					}
				}
			}
*/
			LoadSkybox(d3dDevice, L"..\\media\\Skybox\\Clouds.dds");
			cameraEye = sceneScaling * D3DXVECTOR3(100.0f, 5.0f, 5.0f);
            cameraAt = sceneScaling * D3DXVECTOR3(0.0f, 0.0f, 0.0f);

		}break;
#pragma endregion
    };
#pragma endregion
	
	cameraEye.x += 200;
    gViewerCamera.SetViewParams(&cameraEye, &cameraAt);
    gViewerCamera.SetScalers(0.01f, 100.0f);
    gViewerCamera.FrameMove(0.0f);
    
    // Zero out the elapsed time for the next frame
    gZeroNextFrameTime = true;
}
GLFluidsCanvas::~GLFluidsCanvas()
{
  DestroyScene();
  delete [] m_pixels;
}
Exemple #13
0
int CsGame::Run()
{
	Init();

	
	SetupScene("spawntest");
	
	//mRoot->renderOneFrame();
	// create threads
	
	mLogicThread  = new boost::thread(&CsGame::Logic, this);
	//mInputThread = new boost::thread(&CsGame::InputControl, this);
	mControlThread  = new boost::thread(&CsGame::ThreadControl, this);

	mBulletManager->GetDynamicsWorld()->stepSimulation(0.0);

	mGameLevel->Update();
	mGameLevel->Synchronize();
	mGameLevel->UpdateSceneNodes();


	//terminate the control thread 
	boost::thread::id notAny;
	while (1)  {
		Ogre::WindowEventUtilities::messagePump();

		// if logic thread quits then wait for the reaper
		if ( mLogicThread->get_id() == notAny)  {
				//mControlThread->interrupt();
				mControlThread->join();
				break;
		}

		mInputManager->CaptureInput();
		Render();
		
		// dispatch accumulated messages to the Logic part
		{
			boost::mutex::scoped_lock lock(mLogicQueue.mMutex);
			while (!mLogicTempQueue.empty()) {
				mLogicQueue.push(mLogicTempQueue.front());
				mLogicTempQueue.pop();
			}
		}

	}


	// TODO: termination of threads, exception handling etc
	// TODO: disableInterruption objects in thread functions
	// destroy threads

	delete mControlThread;
	delete mLogicThread;
	//delete mInputThread;

	DestroyScene();

	// ----------------------------------------------------------------------------------------------

	
	//------------------------------------------------------------------------------------------------

	Cleanup();
    return 17;
}
Exemple #14
0
void CHudGui::Destroy()
{
	DestroyScene();
}