//----------------------------------------------------------------------------- // Name: // Desc: //----------------------------------------------------------------------------- void C3DBody::Simulate( float fDeltaT ) { float fCurrentT = 0.0f; #define FIXED_TIMESTEP 1 #if FIXED_TIMESTEP fDeltaT = 0.01f; #endif float fEndT = fDeltaT; while( fCurrentT < fDeltaT ) { SumForces(); Integrate( fEndT - fCurrentT ); /* CalculateVertices(TargetConfigurationIndex); CheckForCollisions(TargetConfigurationIndex); if( CollisionState == Penetrating ) { // we simulated too far, so subdivide time and try again fEndT = ( fCurrentT + fEndT ) * 0.5f; // blow up if we aren't moving forward each step, which is // probably caused by interpenetration at the frame start assert(fabs(TargetTime - CurrentTime) > Epsilon); } else { // either colliding or clear if( CollisionState == Colliding ) { // @todo handle multiple simultaneous collisions int Counter = 0; do { ResolveCollisions(TargetConfigurationIndex); Counter++; } while((CheckForCollisions(TargetConfigurationIndex) == Colliding) && (Counter < 100)); assert(Counter < 100); } */ // we made a successful step, so swap configurations for the next step fCurrentT = fEndT; fEndT = fDeltaT; SwapStates(); // } } }
int main(){ traj = fopen("myTraj_0721_18p_modified6p.xyz","w"); stateFile = fopen("state_0721.txt","w"); InitialSet(); t=0; while(t<time){ t = t + 1; newcal(); note(); for(a=0;a<N-1;a++){ for(b=a+1;b<N;b++){ CalDist(); CalEdepth(); CalForce(); } } SumForces(); State(); Renew(); } return 0; }