// draws all particles belonging to this system bool CParticleSystem::DrawSystem( void ) { if (TestSystem() == false) { return false; } UpdateSystem(); m_flLastDraw = gEngfuncs.GetClientTime(); return true; }
bool CParticleSystem::RenderSystem( void ) { // heres where we loop through the system and render it if( TestSystem( ) ) { // if test works update it UpdateSystem( ); //now we loop thorugh the parts in the system and render them Particle_s *pPart = m_pHeadPart; int iCount = 0; PreRender( ); while( pPart ) { // first we need to test if the particle should still be living Particle_s *pTmp = pPart->pNext; if( TestPart( pPart ) ) { UpdatePart( pPart ); if( TestVisability( pPart ) ) { // then we should update the particle // now draw it RenderPart( pPart ); iCount ++; } } else { // test show no need for particle remove it ReturnToPool( pPart ); } //move to the next part pPart = pTmp; } // turn it off PostRender( ); // if( iCount >= 5000 ) /*{ gEngfuncs.Con_Printf( "Parts: %i\n", iCount ); }*/ } else { //we can break out system doesnt need to be around any more return false; } //every thing was successfull return true; }
bool Application::VInitializeInstance() { /*m_pGame = VCreateGameAndView(); if (!m_pGame) return false;*/ // // Initialize the ResCache - Chapter 5, page 141 // // Note - this is a little different from the book. Here we have a speccial resource ZIP file class, DevelopmentResourceZipFile, // that actually reads directly from the source asset files, rather than the ZIP file. This is MUCH better during development, since // you don't want to have to rebuild the ZIP file every time you make a minor change to an asset. // //IResourceFile *zipFile = (m_bIsEditorRunning || m_Options.m_useDevelopmentDirectories) ? //WE_NEW DevelopmentResourceZipFile(L"Assets.zip", DevelopmentResourceZipFile::Editor) : IResourceFile *ZipFile = WE_NEW ResourceZipFile(L"Assets.zip"); m_ResCache = WE_NEW ResCache(50, ZipFile); if (!m_ResCache->Init()) { printf("Failed to initialize resource cache! Are your paths set up correctly?"); return false; } //extern shared_ptr<IResourceLoader> CreateWAVResourceLoader(); //extern shared_ptr<IResourceLoader> CreateOGGResourceLoader(); //extern shared_ptr<IResourceLoader> CreateDDSResourceLoader(); //extern shared_ptr<IResourceLoader> CreateJPGResourceLoader(); extern shared_ptr<IResourceLoader> CreateXMLResourceLoader(); //extern shared_ptr<IResourceLoader> CreateSdkMeshResourceLoader(); //extern shared_ptr<IResourceLoader> CreateScriptResourceLoader(); // Note - register these in order from least specific to most specific! They get pushed onto a list. // RegisterLoader is discussed in Chapter 5, page 142 //m_ResCache->RegisterLoader(CreateWAVResourceLoader()); //m_ResCache->RegisterLoader(CreateOGGResourceLoader()); //m_ResCache->RegisterLoader(CreateDDSResourceLoader()); //m_ResCache->RegisterLoader(CreateJPGResourceLoader()); m_ResCache->RegisterLoader(CreateXMLResourceLoader()); //m_ResCache->RegisterLoader(CreateSdkMeshResourceLoader()); //m_ResCache->RegisterLoader(CreateScriptResourceLoader()); m_ProcessManager = new ProcessManager; m_pEventManager = WE_NEW EventManager("Warp Engine Generic Event Manager", true); EventListenerDelegate DelegateFunction = fastdelegate::MakeDelegate(this, &Application::EngineLoadedDelegate); IEventManager::Get()->VAddListener(DelegateFunction, EventData_Engine_Loaded::sk_EventType); TS = WE_NEW TestSystem(); TS->Initialize(); // Create a window //IWindow* Wind = new GLFWWindow(); //Wind->VInitializeInstance(640, 400, "Main Window"); // Splash Screen Creation m_pSplash = new GLFWSplashScreen(); m_pSplash->VInitializeInstance(1024, 512, "Splash"); // Renderer setup m_Renderer = shared_ptr<IRenderer>(WE_NEW OpenGLRenderer()); //m_Renderer->SetBackgroundColor() // Temporary! m_pGame = WE_NEW BaseGameLogic; if (!m_pGame) return false; Human = WE_NEW HumanView(m_Renderer); m_pGame->VAddView(shared_ptr<IGameView>(Human)); Human->SetWindow(m_pSplash); m_pSplash->VOnUpdate(1.0f); m_pSplash->VOnRender(); //Human->SetWindow(Wind); StrongProcessPtr EngineLoad(new ProcessEngineLoad(3)); m_ProcessManager->AttachProcess(EngineLoad); //m_Renderer->VAddRenderTarget(Wind); /* Mat4x4 Mat = Mat4x4(); Mat.BuildRotationX(0.5f); Mat.BuildTranslation(2.0f, 3.0f, 10.0f); Mat.BuildTranslation(1.0f, 0.0f, 0.0f); Mat.BuildTranslation(1.0f, 0.0f, 0.0f); Mat.BuildTranslation(1.0f, 0.0f, 0.0f); Mat.BuildTranslation(1.0f, 0.0f, 0.0f); Mat.BuildTranslation(2.0f, 0.0f, 0.0f); StrongProcessPtr Render(new ProcessRender()); StrongProcessPtr Delay(new ProcessDelay(10)); StrongProcessPtr Delay2(new ProcessDelay(2)); m_ProcessManager->AttachProcess(Delay); Delay->AttachChild(Delay2); Delay->AttachChild(Render); */ return true; }