示例#1
0
void particleSystem::init(){
    printf("Initiating Particles... ");
    spacing = 1.f;
    simW = 100.f;
    bottom = 0.0;
    lifetime = 1000.0;
    kill = false;
    particleType = basic;
    setup = cube;
    particleSize = spacing;
    globalForce = Vec2(0.0,0.0);
    setupParticles(setup,1);
    printf("done\n");
}
KDvoid Sample_ParticleFX::setupContent ( KDvoid )
{
    // setup some basic lighting for our scene
    m_pSceneMgr->setAmbientLight ( ColourValue ( 0.3, 0.3, 0.3 ) );
    m_pSceneMgr->createLight ( )->setPosition ( 20, 80, 50 );
    
    // set our camera to orbit around the origin and show cursor
    m_pCameraMan->setStyle ( CS_ORBIT );
    m_pCameraMan->setYawPitchDist ( Degree ( 0 ), Degree ( 15 ), 250 );
    m_pTrayMgr->showCursor ( );
    
    // create an ogre head entity and place it at the origin
    Entity*  pEntity = m_pSceneMgr->createEntity ( "Head", "ogrehead.mesh" );
    m_pSceneMgr->getRootSceneNode ( )->attachObject ( pEntity );
    
    setupParticles ( );   // setup particles
    setupTogglers  ( );   // setup particle togglers
}
示例#3
0
//--------------------------------------------------------------
void testApp::update(){
    
    ofVec3f diff ;          //Difference between particle and mouse
    float dist ;            //distance from particle to mouse ( as the crow flies ) 
    float ratio ;           //Ratio of how strong the effect is = 1 + (-dist/maxDistance) ;
    const ofVec3f mousePosition = ofVec3f( mouseX , mouseY , 0 ) ; //Allocate and retrieve mouse values once.
    const ofVec3f origin = ofVec3f(0,0,0);
    //Create an iterator to cycle through the vector
    std::vector<Particle>::iterator p ; 
    for ( p = particles.begin() ; p != particles.end() ; p++ ) 
    {
        ratio = 1.0f ; 
        p->velocity *= friction ; 
        //reset acceleration every frame
        p->acceleration = ofVec3f() ; 
        diff = mousePosition - p->position ;  
        dist = mousePosition.distance( p->position ) ; 
        //If within the zone of interaction
        if ( dist * .5 < forceRadius )  
        {
            ratio = -1 + dist / forceRadius ; 
            //Repulsion
            if ( cursorMode == 0 ) 
                p->acceleration -= ( diff * ratio) ;
            //Attraction
            else
                p->acceleration += ( diff * ratio ) ; 
        }
        if ( springEnabled ) 
        {
            //Move back to the original position
            p->acceleration += springFactor * (p->spawnPoint - p->position );
        }
        
        p->velocity += p->acceleration * ratio ; 
        p->position += p->velocity ; 
    }
    
    if ( ofGetFrameNum() % 300 == 0 ) 
    {
        curImageIndex++ ;
        setupParticles() ;
    }
}
//--------------------------------------------------------------
void ofApp::setup(){
	
	bGuiVisible = false;
	
	particlesW = 1280;
	particlesH = 800;
	
	setupGui();
	
	width = 1280;
	height = 800;
	
	videoIn.setDeviceID(0);
	videoIn.setDesiredFrameRate(60);
	videoIn.initGrabber(VIDEO_WIDTH, VIDEO_HEIGHT, true);
	
	setupParticles();
	
	iPreset = 1;
	load( iPreset );
	
	bDebug = false;

}
示例#5
0
void electromagnetica::resetParticles(){
    particles.clear();
    setupParticles();
}
示例#6
0
void electromagnetica::setupShader(){
	shader.load("", "shaders/whitenoise.frag");
    setupParticles();
    
}