示例#1
0
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));
}
示例#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 );
}
示例#5
0
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));
		}
	}
}
示例#6
0
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);
}
示例#7
0
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();

}
示例#8
0
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;
}
示例#9
0
void IMovable::BumpByGas(Dir dir, bool inside)
{
    //checkMove(dir);
    ApplyForce(DirToVDir[dir]);
}
示例#10
0
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
}
示例#11
0
void Body::applyG(double m, Vector2D dir, double dist)
{
	double g = G * m * mass.m / dist;
	Vector2D F = dir * g;
	ApplyForce(F);
}
示例#12
0
文件: Mover.cpp 项目: fjz13/Medusa
void Mover::ApplyGravity(const Point2F& gravity)
{
	ApplyForce(mMass*gravity);
}
void Ball::ApplyGravity(){
    ApplyForce(0,Gravitational_Acceleration * mass);
}
示例#14
0
void State::ApplyYForce(double y, double duration) { ApplyForce(0.0, y, duration); }
示例#15
0
void State::ApplyXForce(double x, double duration) { ApplyForce(x, 0.0, duration); }
示例#16
0
void ASprungWheel::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	ApplyForce();
}
示例#17
0
void Sarge::StrafeForward() {
    ApplyForce(50 * mDir);
}
示例#18
0
void Sarge::StrafeRight() {
    ApplyForce(50 * GetU());
}
示例#19
0
void Sarge::StrafeLeft() {
    ApplyForce(-50 * GetU());
}
示例#20
0
void Sarge::StrafeBackward() {
    ApplyForce(-30 * mDir);
}
示例#21
0
void IMovable::BumpByGas(Dir dir, bool inside)
{
    ApplyForce(DirToVDir[dir]);
}
示例#22
0
void State::ApplyForce(double x, double y, double duration) { ApplyForce(Vector2D(x, y), duration); }