]> Dogcows Code - chaz/yoink/commitdiff
spring experiments
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sun, 20 Sep 2009 16:36:42 +0000 (10:36 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sun, 20 Sep 2009 16:36:42 +0000 (10:36 -0600)
src/Character.cc
src/Character.hh
src/Moof/RK4.hh

index c7de260d6cb61190e5ceaf60b2be6701b455f309..4ce11052274d0a0d9a23e378e3f5d7302ebd729a 100644 (file)
@@ -40,7 +40,7 @@ Character::Character(const std::string& name) :
        current.inverseMass = 1.0 / current.mass;
 
        // gravity
        current.inverseMass = 1.0 / current.mass;
 
        // gravity
-       current.force = Mf::Vector2(0.0, -120.0);
+       //current.force = Mf::Vector2(0.0, -120.0);
 
        // starting position
        current.position = Mf::Vector2(64.0, 64.0);
 
        // starting position
        current.position = Mf::Vector2(64.0, 64.0);
@@ -56,6 +56,23 @@ Character::Character(const std::string& name) :
 void Character::update(Mf::Scalar t, Mf::Scalar dt)
 {
        previous = current;
 void Character::update(Mf::Scalar t, Mf::Scalar dt)
 {
        previous = current;
+
+       Mf::Scalar epsilon = 100.0;
+
+       //current.momentum = Mf::Vector2(0.0, -120.0);
+       current.momentum = -5 * (current.position - Mf::Vector2(500.0, 200.0))
+               - 2.0 * current.velocity;
+       current.recalculate();
+       std::cout << "force: " << current.momentum << std::endl;
+
+       //if (std::abs(current.force[0]) < epsilon && std::abs(current.force[1]) < epsilon &&
+               //std::abs(current.velocity[0]) < epsilon && std::abs(current.velocity[1]) < epsilon)
+       //{
+               //current.force = Mf::Vector2(0.0, 0.0);
+               //current.velocity = Mf::Vector2(0.0, 0.0);
+               //current.momentum = Mf::Vector2(0.0, 0.0);
+       //}
+
        Mf::integrate<State,Derivative>(current, t, dt);
 
        animation_.update(t, dt);
        Mf::integrate<State,Derivative>(current, t, dt);
 
        animation_.update(t, dt);
index 96ac499001110bf1882d5f93e3c2634f4aa265b2..00e5a4b2b6912dc8ceae0b27643d5f67496102ea 100644 (file)
@@ -123,7 +123,7 @@ struct Character : public Mf::Entity
                        return state;
                }
 
                        return state;
                }
 
-               State operator+(State state) const
+               State operator+(const State& state) const
                {
                        State newState = *this;
                        newState.position +=  state.position;
                {
                        State newState = *this;
                        newState.position +=  state.position;
index a2e0f1cbe713c62e0eb9b6267c2b2febaecd065a..00c0b649c9406414dd7a56593322b59bb1f8b780 100644 (file)
@@ -75,6 +75,15 @@ inline void integrate(S& state, Scalar t, Scalar dt)
 }
 
 
 }
 
 
+//template<typename T>
+//inline T spring(Scalar k, Scalar b)
+//{
+       //current.force = -15 * (current.position - Mf::Vector2(200.0, 200.0))
+               //- 15.0 * current.velocity;
+       //return 
+//}
+
+
 } // namespace Mf
 
 #endif // _MOOF_RK4_HH_
 } // namespace Mf
 
 #endif // _MOOF_RK4_HH_
This page took 0.022356 seconds and 4 git commands to generate.