void Dynamic::Move(double deltaTime) { m_Acceleration.y+= m_Gravity * deltaTime*60; m_OldVelocity= m_Velocity; m_Velocity+= m_Acceleration; //*m_PosPtr+= m_Velocity * deltaTime; m_Acceleration= DOUBLE2(); RayBounceWrapper(deltaTime); // Kan ook multi-tretherd! Zie GameEngine (concurrency problemen...) //RayBounce(deltaTime, &m_Pos, &m_Velocity); //DOUBLE2 pos= *m_PosPtr; if( GAME_ENGINE->IsKeyDown('X') ){ for( unsigned int myLink=0; myLink<m_LinkList.size(); ++myLink ){ if( rand()%140 < deltaTime*60 ) RemoveLink(myLink); } } if( m_Pos.x<0 ) ApplyForce(DOUBLE2(-m_Pos.x*4, 0)); double xTeVeel= m_MasterOfListsPtr->GetLevelMaxPos().x - m_Pos.x; if( xTeVeel<0 ) ApplyForce(DOUBLE2( xTeVeel*4, 0)); //xMarge= m_Pos.x - m_LevelMaxPos.x; //if( xMarge>0 ) ApplyForce(DOUBLE2(-xMarge*2, 0)); }
void IMovable::Bump(id_ptr_on<IMovable> item) { if (id_ptr_on<IMob> m = item) { ApplyForce(DirToVDir[m->dMove]); } }
void Grabber::Update(q3Vec3 & lookAt, q3Vec3 & from){ if (HasObject()){ ApplyForce(lookAt, from); } else{ TryGrab(lookAt, from); } }
void Terrain::Collide( Unit *un, const Matrix &t ) { Vector norm; if (un->isUnit() == BUILDINGPTR) return; float dist = GetHeight( un->Position().Cast(), norm, t, TotalSizeX, TotalSizeZ )-un->rSize(); if (dist < 0) ApplyForce( un, norm, -dist ); }
void CHostageImprov::Wiggle() { // for wiggling if (m_wiggleTimer.IsElapsed()) { m_wiggleDirection = static_cast<NavRelativeDirType>(RANDOM_LONG(FORWARD, LEFT)); m_wiggleTimer.Start(RANDOM_FLOAT(0.3f, 0.5f)); } const float force = 15.0f; Vector dir(BotCOS(m_moveAngle), BotSIN(m_moveAngle), 0.0f); Vector lat(-dir.y, dir.x, 0.0f); switch (m_wiggleDirection) { case FORWARD: ApplyForce(dir * force); break; case BACKWARD: ApplyForce(dir * -force); break; case LEFT: ApplyForce(lat * force); break; case RIGHT: ApplyForce(lat * -force); break; default: break; } const float minStuckJumpTime = 0.5f; if (m_follower.GetStuckDuration() > minStuckJumpTime && m_wiggleJumpTimer.IsElapsed()) { if (Jump()) { m_wiggleJumpTimer.Start(RANDOM_FLOAT(0.75f, 1.2f)); } } }
void Vehicle::Seek(Vector2 target) { Vector2 desired = target - position; float d = desired.length(); desired.normalize(); desired *= maxSpeed; if (d < 100) { float m = ofMap(d, 0, 100, 0, maxSpeed); desired *= m; } Vector2 steer = desired - velocity; steer.limit(maxForce); ApplyForce(steer); }
WizualizacjaWahadla::WizualizacjaWahadla( QWidget *wRodzic ): QWidget( wRodzic ){ param.q[0] = -90; param.q[1] = -90; param.q[2] = 0; param.q[3] = 0; param.l[0] = 6; param.l[1] = 3; param.m[0] = 5; param.m[1] = 4; S = new Wahadlo( this ); B = new QPushButton( this ); B->resize( 100, 30 ); B->move( 500, 300 ); B->setText("Apply Force"); connect(S, SIGNAL(UpdateAngles(PendulumParameters)), this, SLOT(fresh(PendulumParameters))); connect(B, SIGNAL(pressed()), S, SLOT(ApplyForce())); connect(B, SIGNAL(released()), S, SLOT(ReleaseForce())); setPalette( QPalette(Qt::white) ); setAutoFillBackground( true ); update(); }
void CN3Cloak::Tick(int nLOD) { //SetLOD(nLOD); // // static float fForceDelay = 0.0f; // static float fForceDelayLimit = 4.0f; // fForceDelay += s_fSecPerFrm; // if (fForceDelay > fForceDelayLimit) // { //float x = (rand()%30)*0.0001f; //float z = (rand()%60)*0.0001f; //SetForce(dif.x, dif.y, dif.z); // m_Force.x = dif.x; // m_Force.y = dif.y; // m_Force.z = dif.z; // fForceDelay = 0.0f; // fForceDelayLimit = 2.0f + rand()%10; // } m_fAnchorPreserveTime -= s_fSecPerFrm; if (m_eAnchorPattern != AMP_NONE) { if (m_fAnchorPreserveTime < 0.0f) { RestoreAnchorLine(); } } TickByPlayerMotion(); TickYaw(); UpdateLocalForce(); ApplyForce(); m_Force.x = m_Force.y = m_Force.z = 0.0f; }
void IMovable::BumpByGas(Dir dir, bool inside) { //checkMove(dir); ApplyForce(DirToVDir[dir]); }
void Dynamic::friction(double deler){ //ApplyForce( m_K*(-m_Velocity.Normalized()) ); // vrijving constant ApplyForce( -m_Velocity.Normalized()* pow(m_Velocity.Norm()/deler, 1.3) ); // vrijving ifv snelhijd }
void Body::applyG(double m, Vector2D dir, double dist) { double g = G * m * mass.m / dist; Vector2D F = dir * g; ApplyForce(F); }
void Mover::ApplyGravity(const Point2F& gravity) { ApplyForce(mMass*gravity); }
void Ball::ApplyGravity(){ ApplyForce(0,Gravitational_Acceleration * mass); }
void State::ApplyYForce(double y, double duration) { ApplyForce(0.0, y, duration); }
void State::ApplyXForce(double x, double duration) { ApplyForce(x, 0.0, duration); }
void ASprungWheel::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) { ApplyForce(); }
void Sarge::StrafeForward() { ApplyForce(50 * mDir); }
void Sarge::StrafeRight() { ApplyForce(50 * GetU()); }
void Sarge::StrafeLeft() { ApplyForce(-50 * GetU()); }
void Sarge::StrafeBackward() { ApplyForce(-30 * mDir); }
void IMovable::BumpByGas(Dir dir, bool inside) { ApplyForce(DirToVDir[dir]); }
void State::ApplyForce(double x, double y, double duration) { ApplyForce(Vector2D(x, y), duration); }