int main(int argc, char **argv) { //Initialize GLUT glutInit(&argc, argv); //Lets use doublebuffering, RGB(A)-mode and a depth buffer glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800,600); //Create a window with rendering context and everything else we need glutCreateWindow("Particle Engine and Billboarding"); //Init some state variables: glDisable(GL_DEPTH_TEST); glClearColor(0.1,0.1,0.1,1.0); glEnable(GL_POINT_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //also try GL_LINE g_Camera.Move(F3dVector(0.0f,0.3f,3.0f)); //INITIALIZE THE PARTICLE SYSTEM: InitParticles(); //Assign the event-handling routines glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutKeyboardFunc(KeyDown); glutIdleFunc(Display); //If there is no msg, we have to repaint g_iLastRenderTime = timeGetTime(); //Let GLUT get the msgs and tell us the ones we need glutMainLoop(); return 0; }
void CParticleJetEffectPainter::CreateNewParticles (CSpaceObject *pObj, int iCount, const CVector &vInitialPos, const CVector &vInitialVel) // CreateNewParticles // // Create the new particles for a tick { // Make sure we're initialized InitParticles(vInitialPos); // If we haven't yet figured out which direction to emit, then we wait. // (This doesn't happen until paint time). if (m_iCurDirection == -1) return; // If we using object motion (e.g., for missile exhaust, then have a // completely different algorithm. if (m_bUseObjectMotion) CreateFixedParticles(pObj, iCount, vInitialPos, vInitialVel); // If our emit direction has changed then we need to interpolate between the two else if (m_iCurDirection != m_iLastDirection) CreateInterpolatedParticles(pObj, iCount, vInitialPos, vInitialVel); // Otherwise, just linear creation else CreateLinearParticles(pObj, iCount, vInitialPos, vInitialVel); }
void CParticleDamage::OnUpdate (SUpdateCtx &Ctx, Metric rSecondsPerTick) // OnUpdate // // Update { m_iTick++; // Update the single particle painter if (m_pPainter) m_pPainter->OnUpdate(); // Set up context block for particle array update SEffectUpdateCtx EffectCtx; EffectCtx.pSystem = GetSystem(); EffectCtx.pObj = this; EffectCtx.pDamageDesc = m_pDesc; EffectCtx.iTotalParticleCount = m_iParticleCount; EffectCtx.pEnhancements = m_pEnhancements; EffectCtx.iCause = m_iCause; EffectCtx.bAutomatedWeapon = IsAutomatedWeapon(); EffectCtx.Attacker = m_Source; // Update (includes doing damage) m_Particles.Update(EffectCtx); // If we're tracking, change velocity to follow target if (m_pTarget && m_pDesc->IsTrackingTime(m_iTick)) m_Particles.UpdateTrackTarget(m_pTarget, m_pDesc->GetManeuverRate(), m_pDesc->GetRatedSpeed()); // Expired? if (--m_iLifeLeft <= 0) { Destroy(removedFromSystem, CDamageSource()); return; } // Emit new particles if (m_iTick < m_iEmitTime && !m_Source.IsEmpty()) { InitParticles(m_pDesc->GetParticleCount(), m_vEmitSourcePos - GetPos(), GetVel(), m_iEmitDirection); } }
void Explosion::Init(cResourceHandle* explosion_sprite, cResourceHandle* explosion_sprite1, cResourceHandle* flash, cResourceHandle* particleTexture) { mExplosion_sprite = explosion_sprite; mExplosion_sprite1 = explosion_sprite1; mExplosion_flash = flash; miExplosionSeq = 0; miExplosionStep = 0; mTranslate.LoadIdentity(); mAlive = false; InitParticles(particleTexture); }
byte InitLevel(byte map) { JamulSoundPurge(); // each level, that should be good if (curWorld.numMaps <= map) return 0; // can't go to illegal map // make a copy of the map to be played curMap = new Map(curWorld.map[map]); curMapFlags = curMap->flags; switch (PlayerGetMusicSettings()) { case MUSIC_OFF: CDStop(); // in case it's playing for some reason break; case MUSIC_ON: CDPlay(curMap->song); break; case MUSIC_RAND: break; // do nothing- if there is a song currently playing, let it finish, else a new // one will automatically start at the next call to CDPlayerUpdate } gameStartTime = timeGetTime(); tickerTime = timeGetTime(); updFrameCount = 0; visFrameCount = 0; numRunsToMakeUp = 0; frmRate = 30.0f; visFrms = 0; if (msgFromOtherModules != MSG_NEWFEATURE) msgFromOtherModules = 0; InitGuys(256); InitBullets(); InitPlayer(INIT_LEVEL, 0, map); InitMessage(); NewBigMessage(curMap->name, 100); InitParticles(512); lastKey = 0; curMap->Init(&curWorld); windingDown = 0; windingUp = 30; ResetInterface(); InitCheater(); SetGiveUpText((byte) (map != 0)); return 1; }
Smoke::Smoke(ID3D11Device* device,D3DXVECTOR3 pos,ID3D11DeviceContext* deviceContext): ParticleSystem(device,deviceContext) { mPosition = pos; srand(time(0)); SystemProperties(); InitParticles(); InitBuffers(device); InitTexture(device); }
// Full Ctor Localization::Localization(Position2dProxy &position2dProxy, LaserProxy* laserProxy, Map& map) { // Init the variables. pos_proxy = &position2dProxy; laser_proxy = laserProxy; grid_map = map; particles_vector = vector<Particle>(); // Set the robot location, privious location and the particles. Location robot_location_in_meters(pos_proxy->GetXPos(),pos_proxy->GetYPos()); double loc_x = pos_proxy->GetXPos() * 100; double loc_y = pos_proxy->GetYPos() * 100; //double loc_x = ((pos_proxy->GetXPos() + 6.875) * 100);//simulator //double loc_y = (((pos_proxy->GetYPos() * -1) + 4.75) * 100);//simulator privious_location.SetLocation(loc_x, loc_y); privious_location.setYaw(pos_proxy->GetYaw()); InitParticles(); }
LocalizationManager::LocalizationManager(double x, double y, Map* map) { srand(time(NULL)); InitParticles(x, y, map); }
void H5input::ReadParticles(int rank, int nproc, const int *dimns, double *L, MPI_Comm CART_COMM){ int ndim = 3; // By default 2D is considered as a 'flat' 3D LoadParticles(ndim, rank, nproc, dimns, L, CART_COMM); InitParticles(ndim, rank, CART_COMM); }
//-------------------------------------------------------------------------------------- // Name: Initialize() // Desc: //-------------------------------------------------------------------------------------- BOOL CSample::Initialize() { m_Colors[0] = FRMCOLOR( 1.0f, 0.5f, 0.5f ); m_Colors[1] = FRMCOLOR( 1.0f, 1.0f, 0.5f ); m_Colors[2] = FRMCOLOR( 0.5f, 1.0f, 0.5f ); m_Colors[3] = FRMCOLOR( 0.5f, 1.0f, 1.0f ); m_Colors[4] = FRMCOLOR( 0.5f, 0.5f, 1.0f ); m_Colors[5] = FRMCOLOR( 1.0f, 0.5f, 1.0f ); m_fXFactor = 0.15f; m_fYFactor = 0.10f; m_fParticleSpeed = 0.35f; m_fTimePerColor = 1.0f; m_bUseSrcAlpha = TRUE; m_bUseTransformFeedback = TRUE; InitParticles( m_Particles, &m_hParticleBuffers[0], &m_hParticleVAOs[0], &m_hQuery ); // Initialize buffer indices m_srcBuffer = 0; m_dstBuffer = 1; for( UINT32 i = 0; i < NUM_EMITTERS; ++i ) m_ParticleEmitters[i].Init(); // Create the font if( FALSE == m_Font.Create( "Samples/Fonts/Tuffy12.pak" ) ) return FALSE; // Load the packed resources CFrmPackedResourceGLES resource; if( FALSE == resource.LoadFromFile( "Samples/Textures/ParticleSystem.pak" ) ) return FALSE; // Create the logo texture m_pLogoTexture = resource.GetTexture( "Logo" ); // Create the particle texture m_pParticleTexture = resource.GetTexture( "Particle" ); // Setup the user interface if( FALSE == m_UserInterface.Initialize( &m_Font, m_strName ) ) return FALSE; m_UserInterface.AddOverlay( m_pLogoTexture->m_hTextureHandle, -5, -5, m_pLogoTexture->m_nWidth, m_pLogoTexture->m_nHeight ); m_UserInterface.AddTextString( "Press " FRM_FONT_KEY_0 " for Help", 1.0f, -1.0f ); m_UserInterface.AddFloatVariable( &m_fXFactor , "X Factor", "%4.2f" ); m_UserInterface.AddFloatVariable( &m_fYFactor , "Y Factor", "%4.2f" ); m_UserInterface.AddFloatVariable( &m_fParticleSpeed , "Speed", "%4.2f" ); m_UserInterface.AddBoolVariable( &m_bUseSrcAlpha , "Use Source Alpha", "Yes", "No" ); m_UserInterface.AddBoolVariable( &m_bUseTransformFeedback , "Use Transform Feedback", "Yes", "No" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_STAR, "Toggle Orientation" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_0, "Toggle Info Pane" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_1, "Decrease X Factor" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_2, "Increase X Factor" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_3, "Decrease Y Factor" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_4, "Increase Y Factor" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_5, "Decrease Speed" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_6, "Increase Speed" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_7, "Toggle Blend Mode" ); m_UserInterface.AddHelpKey( FRM_FONT_KEY_8, "Toggle Transform Feedback vs CPU Particles" ); // Create the shaders if( FALSE == InitShaders() ) return FALSE; return TRUE; }
ParticleFilter::ParticleFilter(int size) { InitParticles(size); }