예제 #1
0
void Momentum::newFrame()
{
	p.calculateMoment();
	*MomentVal=glm::length(p.Momentum);
	theLabel->setText(ConvertString(*MomentVal).c_str());
	p.mass= slider->value();
	graphic->pointSize=p.mass;

	if(theBox->isChecked())
	{
		p.Velocity=p.Momentum/p.mass;
	}

	float accelerationScaler = 1.00f;
	p.Acceleration=(accelerationScaler * getUserDirection());
	p.Velocity += p.Acceleration *dt();
	/*p.Velocity=p.Velocity*p.Damper;*/
	p.Position+=p.Velocity *dt();
	sync(graphic,p.Position);
	sync(velocityGraphic,p.Velocity,p.Position);
	sync(momentumGraphic,p.Momentum,p.Position);
}
void ParticleKeyboardForceGenerator::updateForce(Particle *particle, float duration)
{
	//check that particle does not have infinite mass

	particle->addForce(keyboardAccelerationMultiplier * getUserDirection() * particle->mass);
}