current.recalculate();
previous = current;
-
- //updateContainers();
}
Mf::Scalar mag = x.length();
Mf::Scalar d = 50.0;
+ // gravity:
current.force = Mf::Vector2(0.0, -2000.0);
+ // spring:
//current.force += -15.0 * x - 1.5 * current.velocity;
current.force += -20.0 * (mag - d) * (x / mag) - 2.0 * current.velocity;
+ // internal:
current.force += userForce;
current.recalculate();
//std::cout << "force: " << current.momentum << std::endl;
- Mf::integrate<State,Derivative>(current, t, dt);
+ Mf::euler<State,Derivative>(current, t, dt);
animation_.update(t, dt);
-
- //updateContainers();
}
-//void Character::updateContainers()
-//{
- //aabb_.init(Mf::Vector3(current.position[0]-16.0, current.position[1]-16.0, z),
- //Mf::Vector3(current.position[0]+16.0, current.position[1]+16.0, z));
- //sphere_.point = Mf::Vector3(current.position[0], current.position[1], z);
- //sphere_.radius = (aabb_.min - sphere_.point).length();
-//}
-
void Character::draw(Mf::Scalar alpha) const
{