Example #1
0
void NxVehicle::control(NxReal steering, bool analogSteering, NxReal acceleration, bool analogAcceleration, bool handBrake)
{
	if (steering != 0 || acceleration != 0 || handBrake)
		_bodyActor->wakeUp(0.05);

	_controlSteering(steering, analogSteering);
	_computeLocalVelocity();
	if (!_braking || _releaseBraking)
	{
		_braking = _localVelocity.x * acceleration < (-0.1f /* NxMath::sign(-acceleration)*/);
		_releaseBraking = false;
	}
	//printf("Braking: %s, Handbrake: %s\n", _braking?"true":"false", handBrake?"true":"false");
	if(_handBrake != handBrake)
	{
		_handBrake = handBrake;
		_brakePedalChanged;
	}
	_controlAcceleration(acceleration, analogAcceleration);


}
Example #2
0
void pVehicle::control(float steering, bool analogSteering, float acceleration, bool analogAcceleration, bool handBrake)
{
	
	if (steering != 0 || acceleration != 0 || handBrake)
		getActor()->wakeUp(0.05);

	return;

	_controlSteering(steering, analogSteering);
	_computeLocalVelocity();

	NxVec3 locVel = _localVelocity;
	float lcx = locVel.x;
	float lcz = locVel.z;
	
	
	float test = _localVelocity.z * acceleration < ( NxMath::sign(-acceleration) );
	float test2 = _localVelocity.z * acceleration < ( -0.1f );
	float test3 = XAbs(_localVelocity.z) * acceleration < ( -0.1f );


	if (!_braking || _releaseBraking)
	{
		//_braking = _localVelocity.x * acceleration < (-0.1f /** NxMath::sign(-acceleration) */);
		_braking = _localVelocity.z * acceleration < ( -0.1 /*NxMath::sign(acceleration) */ );

		//_braking = _localVelocity.z * acceleration < ( NxMath::sign(acceleration));
		_releaseBraking = false;
	}

	if(_handBrake != handBrake)
	{
		_handBrake = handBrake;
		_brakePedalChanged;
	}
	//printf("Braking: %s, Handbrake: %s\n", _braking?"true":"false", handBrake?"true":"false");
	_controlAcceleration(acceleration, analogAcceleration);
}