Ejemplo n.º 1
0
bool TRotationEffect::EditKeyFramesDialog(BLooper* target, TKeyFrameIterator 
		kf, bool doingDefaults)
{
	// See if the dialog is already open.  If so, bring it to front
	if (m_keyFramesDialog) {
		m_keyFramesDialog->Activate(true);	
		return false;
	}

	// Hang on to the stuff we keep around while the dialog is up
	m_dialogTarget = target;
	m_keyFrameTarget = kf;
	m_editingDefaults = doingDefaults;
	const TRotationState* rs = RotationState(kf);
	m_keyFramesDialog = new TRotateDialog(this, rs->m_rotation);

	// Center it
	BScreen theScreen(B_MAIN_SCREEN_ID);
	BRect screenBounds = theScreen.Frame();
	BRect windBounds = m_keyFramesDialog->Frame();
	m_keyFramesDialog->MoveTo((screenBounds.Width() - windBounds.Width())/2, 
			(screenBounds.Height() - windBounds.Height())/2);

	// Show it
	m_keyFramesDialog->Show();
	return true;
	
	// The dialog will now call DialogValueChanged(), DialogIsClosing()
}
Ejemplo n.º 2
0
void ParticleSystem::update()
{
    // create a box that defines the screen (we'll use it to test if a particle
    // is still on the screen ...
    ofRectangle theScreen(-100,-100,ofGetWidth()+200,ofGetHeight()+200);



    ofVec2f mouse(ofGetMouseX(),ofGetMouseY());

    for(int i = 0; i < _particles.size(); ++i)
    {
        float distance = _particles[i]->position.distance(mouse);
        float activeDistance = 40;
        if(distance < activeDistance)
        {
            ofVec2f oppositeDirectionvelocity = (_particles[i]->position - mouse).normalized() * ofMap(distance, 0, activeDistance, .1,.3);
            _particles[i]->velocity += oppositeDirectionvelocity;

        }
    }

    // iterate through the particles backward so we can delete items as we go.
    // this is best done with an std::vector<>::iterator, but we will do that
    // later.
    for(int i = _particles.size() - 1; i >= 0; --i)
    {
        _particles[i]->update();

        if(_particles[i]->isDead || // is the particle too old?
           !theScreen.inside(_particles[i]->position)) // or is the particle not on the screen?
        {
            _particles[i]->kill(); // call the kill function

            // if yes to either, then erase the particle
            _particles.erase(_particles.begin() + i);
        }
    }

    // these are our render groups
    // we have render groups so that we can treat particles as groups when drawing
    for(int i = _groups.size() - 1; i >= 0; --i)
    {
        _groups[i]->update(); // update the group

        if(_groups[i]->members.empty())
        {
            _groups.erase(_groups.begin() + i);
        }
    }

}