Esempio n. 1
0
 void Player::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
 {
     if (adjust) {
         setYaw(getYaw() + rot.z);
         setPitch(getPitch() + rot.x);
     } else {
         setYaw(rot.z);
         setPitch(rot.x);
     }
     Ogre::Quaternion xr(
         Ogre::Radian(getPitch() + Ogre::Math::HALF_PI),
         Ogre::Vector3::UNIT_X
     );
     Ogre::Quaternion zr(
         Ogre::Radian(getYaw()),
         Ogre::Vector3::NEGATIVE_UNIT_Z
     );
     if (!mVanity.enabled && !mPreviewMode) {
         mPlayerNode->setOrientation(zr);
         mCameraNode->setOrientation(xr);
     } else {
         mCameraNode->setOrientation(zr * xr);
     }
 }
Esempio n. 2
0
SoundSource& SoundSource::operator =(const SoundSource& right)
{
    // Leave m_source untouched -- it's not necessary to destroy and
    // recreate the OpenAL sound source, hence no copy-and-swap idiom

    // Assign the sound attributes
    setPitch(right.getPitch());
    setVolume(right.getVolume());
    setPosition(right.getPosition());
    setRelativeToListener(right.isRelativeToListener());
    setMinDistance(right.getMinDistance());
    setAttenuation(right.getAttenuation());

    return *this;
}
Esempio n. 3
0
/** Sets the pitch and the roll of this vector to follow the normal given. The
 *  heading is taken from this vector.
 *  \param normal The normal vector to which pitch and roll should be aligned.
 */
void Vec3::setPitchRoll(const Vec3 &normal)
{
    const float X = sin(getHeading());
    const float Z = cos(getHeading());
    // Compute the angle between the normal of the plane and the line to
    // (x,0,z).  (x,0,z) is normalised, so are the coordinates of the plane,
    // which simplifies the computation of the scalar product.
    float pitch = ( normal.getX()*X + normal.getZ()*Z );  // use ( x,0,z)
    float roll  = (-normal.getX()*Z + normal.getZ()*X );  // use (-z,0,x)

    // The actual angle computed above is between the normal and the (x,y,0)
    // line, so to compute the actual angles 90 degrees must be subtracted.
    setPitch(-acosf(pitch) + NINETY_DEGREE_RAD);
    setRoll (-acosf(roll)  + NINETY_DEGREE_RAD);
}   // setPitchRoll
Esempio n. 4
0
SoundSource& SoundSource::operator =(const SoundSource& right)
{
	// Assign the sound attributes
	setPitch(right.getPitch());
	setVolume(right.getVolume());
	setPosition(right.getPosition());
	setRelativeToListener(right.isRelativeToListener());
	setMinDistance(right.getMinDistance());
	setAttenuation(right.getAttenuation());

	m_channel = right.m_channel;
	m_ndspWaveBuf = right.m_ndspWaveBuf;

	return *this;
}
Esempio n. 5
0
void GameAudioImpl::playSE(const StringRef& filePath, float volume, float pitch)
{
    auto sound = createSound(filePath);

    // ボリューム・ピッチ設定
    sound->setVolume(volume);
    sound->setPitch(pitch);

    // 再生途中で解放されようとしても再生終了までは解放されない & SE として再生する
    sound->setGameAudioFlags(GameAudioFlags_SE);
    pushReleaseAtPlayEndList(sound);

    // 再生
    sound->setLoopEnabled(false);
    sound->play();
}
Esempio n. 6
0
void Player::deSerialize(std::istream &is)
{
    Settings args;

    for(;;)
    {
        if(is.eof())
            throw SerializationError
            ("Player::deSerialize(): PlayerArgsEnd not found");
        std::string line;
        std::getline(is, line);
        std::string trimmedline = trim(line);
        if(trimmedline == "PlayerArgsEnd")
            break;
        args.parseConfigLine(line);
    }

    //args.getS32("version"); // Version field value not used
    std::string name = args.get("name");
    updateName(name.c_str());
    setPitch(args.getFloat("pitch"));
    setYaw(args.getFloat("yaw"));
    setPosition(args.getV3F("position"));
    try {
        hp = args.getS32("hp");
    } catch(SettingNotFoundException &e) {
        hp = 20;
    }

    inventory.deSerialize(is);

    if(inventory.getList("craftpreview") == NULL)
    {
        // Convert players without craftpreview
        inventory.addList("craftpreview", 1);

        bool craftresult_is_preview = true;
        if(args.exists("craftresult_is_preview"))
            craftresult_is_preview = args.getBool("craftresult_is_preview");
        if(craftresult_is_preview)
        {
            // Clear craftresult
            inventory.getList("craftresult")->changeItem(0, ItemStack());
        }
    }
}
Esempio n. 7
0
int SampleChannel::loadByPatch(const char *f, int i)
{
	int res = load(f);

		volume      = G_Patch.getVol(i);
		key         = G_Patch.getKey(i);
		index       = G_Patch.getIndex(i);
		mode        = G_Patch.getMode(i);
		mute        = G_Patch.getMute(i);
		mute_s      = G_Patch.getMute_s(i);
		solo        = G_Patch.getSolo(i);
		boost       = G_Patch.getBoost(i);
		panLeft     = G_Patch.getPanLeft(i);
		panRight    = G_Patch.getPanRight(i);
		readActions = G_Patch.getRecActive(i);
		recStatus   = readActions ? REC_READING : REC_STOPPED;

		readPatchMidiIn(i);
		midiInReadActions = G_Patch.getMidiValue(i, "InReadActions");
		midiInPitch       = G_Patch.getMidiValue(i, "InPitch");
		readPatchMidiOut(i);

	if (res == SAMPLE_LOADED_OK) {
		setBegin(G_Patch.getBegin(i));
		setEnd  (G_Patch.getEnd(i, wave->size));
		setPitch(G_Patch.getPitch(i));
	}
	else {
		// volume = DEFAULT_VOL;
		// mode   = DEFAULT_CHANMODE;
		// status = STATUS_WRONG;
		// key    = 0;

		if (res == SAMPLE_LEFT_EMPTY)
			status = STATUS_EMPTY;
		else
		if (res == SAMPLE_READ_ERROR)
			status = STATUS_MISSING;
		sendMidiLplay();
	}

	return res;
}
Esempio n. 8
0
void Player::deSerialize(std::istream &is, std::string playername)
{
	Settings args;

	if (!args.parseConfigLines(is, "PlayerArgsEnd")) {
		throw SerializationError("PlayerArgsEnd of player " +
				playername + " not found!");
	}

	m_dirty = true;
	//args.getS32("version"); // Version field value not used
	std::string name = args.get("name");
	strlcpy(m_name, name.c_str(), PLAYERNAME_SIZE);
	setPitch(args.getFloat("pitch"));
	setYaw(args.getFloat("yaw"));
	setPosition(args.getV3F("position"));
	try{
		hp = args.getS32("hp");
	}catch(SettingNotFoundException &e) {
		hp = PLAYER_MAX_HP;
	}
	try{
		m_breath = args.getS32("breath");
	}catch(SettingNotFoundException &e) {
		m_breath = PLAYER_MAX_BREATH;
	}

	inventory.deSerialize(is);

	if(inventory.getList("craftpreview") == NULL) {
		// Convert players without craftpreview
		inventory.addList("craftpreview", 1);

		bool craftresult_is_preview = true;
		if(args.exists("craftresult_is_preview"))
			craftresult_is_preview = args.getBool("craftresult_is_preview");
		if(craftresult_is_preview)
		{
			// Clear craftresult
			inventory.getList("craftresult")->changeItem(0, ItemStack());
		}
	}
}
void Oscillator::setSemi(float semi)
{
  if(semi >= 0.5f)
  {
    semi -= 0.5f;
    semi *= 2.0f;
    semi *= g_osc_semi_range;
    //tempsemi should now have the amount of semitones away from center pitch
    m_semi = cpowf(1.05946309436f, common::croundf(semi));
  }
  else if(semi < 0.5f)
  {
    semi = 0.5f-semi;
    semi *= 2.0f;
    semi *= g_osc_semi_range;
    //tempsemi should now have the amount of semitones away from center pitch
    m_semi = cpowf(0.94387431268f, common::croundf(semi));
  }
  setPitch(m_pitch);
}
Esempio n. 10
0
void GameAudioImpl::playSE3D(const StringRef& filePath, const Vector3& position, float distance, float volume, float pitch)
{
    // サウンド作成
    auto sound = createSound(filePath);
    sound->set3DEnabled(true);

    // 位置・ピッチ設定
    sound->setEmitterPosition(position);
    sound->setEmitterMaxDistance(distance);
    sound->setVolume(volume);
    sound->setPitch(pitch);

    // 再生途中で解放されようとしても再生終了までは解放されない & SE として再生する
    sound->setGameAudioFlags(GameAudioFlags_SE);
    pushReleaseAtPlayEndList(sound);

    // 再生
    sound->setLoopEnabled(false);
    sound->play();
}
Esempio n. 11
0
GlWindow::GlWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
: mxGlWindow (parent, x, y, w, h, label, style)
{
	d_rotX = d_rotY = 0;
	d_transX = d_transY = 0;
	d_transZ = 50;
	d_models[0] = 0;
	d_models[1] = 0;
	d_textureNames[0] = 0;
	d_textureNames[1] = 0;
	d_textureNames[2] = 0;
	d_textureNames[3] = 0;

	setFrameInfo (0, 0);
	setRenderMode (0);
	setFlag (F_WATER, false);
	setFlag (F_LIGHT, true);
	setFlag (F_SHININESS, true);
	setFlag (F_INTERPOLATE, true);
	setFlag (F_GLCOMMANDS, true);
	setFlag (F_PAUSE, false);
	setFlag (F_BACKGROUND, false);
	
	setPitch (125.0f);
	setBGColor (0.0f, 0.0f, 0.0f);
	setFGColor (1.0f, 1.0f, 1.0f);
	setWFColor (1.0f, 1.0f, 1.0f);
	setLightColor (1.0f, 1.0f, 1.0f);
	setBrightness (5);
	setTextureLimit (256);

	loadTexture ("water.pcx", TEXTURE_WATER);

	glCullFace (GL_FRONT);

	mx::setIdleWindow (this);
	
#ifdef FULLSCREEN
	setVisible (true);
#endif
}
void Oscillator::setDetune(float detune)
{
  //horrible implementation, there's gotta be a smart and accurate way to do this. works for now.
  //TODO: make pretty
  if(detune >= 0.5f)
  {
    detune *= 2.0f;
    detune -= 1.0f;
    detune *= 0.05946309436f;
    detune += 1.0f;
    m_detune=detune;
  }
  else if(detune < 0.5f)
  {
    detune *= 2.0f;
    detune *= 0.05946309436f;
    detune += 0.94387431268f;
    m_detune=detune;
  }
  setPitch(m_pitch);
}
Esempio n. 13
0
void Piano::viewMouseMoveEvent(QMouseEvent* event)
{
    int pitch = y2pitch(event->y());
    emit pitchChanged(pitch);
    setPitch(pitch);

    if (button != Qt::NoButton) {
        int nk = y2pitch(event->y());
        if (nk < 0 || nk > 127)
            nk = -1;
        if (nk != keyDown) {
            if (keyDown != -1) {
                emit keyReleased(keyDown, shift);
            }
            keyDown = nk;
            if (keyDown != -1) {
                int velocity = event->x()*127/40;
                emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift);
            }
        }
    }
}
Esempio n. 14
0
void ts::scene::Engine_sound_controller::register_car(const world::Car* car)
{
    const auto& car_definition = car->car_definition();
    auto audio_buffer = engine_sound_store_.load_from_file(car_definition.engine_sample);

    engine_sounds_.push_back({ car, nullptr });
    if (audio_buffer)
    {
        Vector2<float> position = car->position();

        auto& entry = engine_sounds_.back();
        auto sound_ptr = std::make_unique<sf::Sound>();
        sound_ptr->setLoop(true);
        sound_ptr->setPitch(base_pitch);
        sound_ptr->setBuffer(*audio_buffer);
        sound_ptr->setMinDistance(200.0f);
        sound_ptr->setRelativeToListener(false);
        entry.second = std::move(sound_ptr);

        sorting_required_ = true;
    }
}
QT_USE_NAMESPACE

QSoundSourcePrivate::QSoundSourcePrivate(QObject *parent)
    : QSoundSource(parent)
    , m_alSource(0)
    , m_bindBuffer(0)
    , m_isReady(false)
    , m_state(QSoundSource::StoppedState)
    , m_gain(0)
    , m_pitch(0)
    , m_coneInnerAngle(0)
    , m_coneOuterAngle(0)
    , m_coneOuterGain(1)
{
#ifdef DEBUG_AUDIOENGINE
    qDebug() << "creating new QSoundSourcePrivate";
#endif
    alGenSources(1, &m_alSource);
    QAudioEnginePrivate::checkNoError("create source");
    setGain(1);
    setPitch(1);
    setCone(360, 360, 0);
}
Esempio n. 16
0
void Player::deSerialize(std::istream &is)
{
	Settings args;
	
	for(;;)
	{
		if(is.eof())
			throw SerializationError
					("Player::deSerialize(): PlayerArgsEnd not found");
		std::string line;
		std::getline(is, line);
		std::string trimmedline = trim(line);
		if(trimmedline == "PlayerArgsEnd")
			break;
		args.parseConfigLine(line);
	}

	//args.getS32("version"); // Version field value not used
	std::string name = args.get("name");
	updateName(name.c_str());
	setPitch(args.getFloat("pitch"));
	setYaw(args.getFloat("yaw"));
	setPosition(args.getV3F("position"));
	try{
		craftresult_is_preview = args.getBool("craftresult_is_preview");
	}catch(SettingNotFoundException &e){
		craftresult_is_preview = true;
	}
	try{
		hp = args.getS32("hp");
	}catch(SettingNotFoundException &e){
		hp = 20;
	}

	inventory.deSerialize(is, m_gamedef);
}
Esempio n. 17
0
//------------------------------------
// Constructor
//------------------------------------
LLFollowCamParams::LLFollowCamParams()
{
	mMaxCameraDistantFromSubject		= DEFAULT_MAX_DISTANCE_FROM_SUBJECT;
	mPositionLocked						= false;
	mFocusLocked						= false;
	mUsePosition						= false;
	mUseFocus							= false;

	//------------------------------------------------------
	// setting the attributes to their defaults
	//------------------------------------------------------
	setPositionLag		( FOLLOW_CAM_DEFAULT_POSITION_LAG			);
	setFocusLag			( FOLLOW_CAM_DEFAULT_FOCUS_LAG				);
	setPositionThreshold( FOLLOW_CAM_DEFAULT_POSITION_THRESHOLD		);
	setFocusThreshold	( FOLLOW_CAM_DEFAULT_FOCUS_THRESHOLD		);
	setBehindnessLag	( FOLLOW_CAM_DEFAULT_BEHINDNESS_LAG		);
	setDistance			( FOLLOW_CAM_DEFAULT_DISTANCE				);
	setPitch			( FOLLOW_CAM_DEFAULT_PITCH					);
	setFocusOffset		( FOLLOW_CAM_DEFAULT_FOCUS_OFFSET	);
	setBehindnessAngle	( FOLLOW_CAM_DEFAULT_BEHINDNESS_ANGLE		);
	setPositionThreshold( FOLLOW_CAM_DEFAULT_POSITION_THRESHOLD		);
	setFocusThreshold	( FOLLOW_CAM_DEFAULT_FOCUS_THRESHOLD		);

}
Esempio n. 18
0
void tPropSurface::clear(void)
{
  setElementLocked

  setPitch(NULL);
  setChord(NULL);
  setSkew(NULL);
  setMaxThick(NULL);
  setRake(NULL);
  setThickness(NULL);
  setCamber(NULL);

  fDiameter = 1.;
  fhubDiameter = 0.2;
  fScale = 1.;
  fZ = 1;
  fRoundedTip = true;
  fautoRoundTE = true;
  frotationDirection = true;

  radialVar->setFullString("r=1*(r0^3-2*r0^2+r0)+0.05*(r0^3-r0^2)-2*r0^3+3*r0^2");
  peripherVar->setFullString("t=0.2*(t0^3-2*t0^2+t0)+0.05*(t0^3-t0^2)-2*t0^3+3*t0^2");

}
Esempio n. 19
0
void LLFollowCam::copyParams(LLFollowCamParams& params)
{
	setPositionLag(params.getPositionLag());
	setFocusLag(params.getFocusLag());
	setFocusThreshold( params.getFocusThreshold());
	setPositionThreshold(params.getPositionThreshold());
	setPitch(params.getPitch());
	setFocusOffset(params.getFocusOffset());
	setBehindnessAngle(params.getBehindnessAngle());
	setBehindnessLag(params.getBehindnessLag());

	setPositionLocked(params.getPositionLocked());
	setFocusLocked(params.getFocusLocked());

	setDistance(params.getDistance());	
	if (params.getUsePosition())
	{
		setPosition(params.getPosition());
	}
	if (params.getUseFocus())
	{
		setFocus(params.getFocus());
	}
}
Esempio n. 20
0
void LocalPlayer::applyControl(float dtime)
{
	// Clear stuff
	swimming_vertical = false;

	setPitch(control.pitch);
	setYaw(control.yaw);

	// Nullify speed and don't run positioning code if the player is attached
	if(isAttached)
	{
		setSpeed(v3f(0,0,0));
		return;
	}

	v3f move_direction = v3f(0,0,1);
	move_direction.rotateXZBy(getYaw());

	v3f speedH = v3f(0,0,0); // Horizontal (X, Z)
	v3f speedV = v3f(0,0,0); // Vertical (Y)

	bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
	bool fast_allowed = m_gamedef->checkLocalPrivilege("fast");

	bool free_move = fly_allowed && g_settings->getBool("free_move");
	bool fast_move = fast_allowed && g_settings->getBool("fast_move");
	// When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
	bool fast_climb = fast_move && control.aux1 && !g_settings->getBool("aux1_descends");
	bool continuous_forward = g_settings->getBool("continuous_forward");
	bool always_fly_fast = g_settings->getBool("always_fly_fast");

	// Whether superspeed mode is used or not
	bool superspeed = false;

	if (always_fly_fast && free_move && fast_move)
		superspeed = true;

	// Old descend control
	if(g_settings->getBool("aux1_descends"))
	{
		// If free movement and fast movement, always move fast
		if(free_move && fast_move)
			superspeed = true;

		// Auxiliary button 1 (E)
		if(control.aux1)
		{
			if(free_move)
			{
				// In free movement mode, aux1 descends
				if(fast_move)
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_walk;
			}
			else if(in_liquid || in_liquid_stable)
			{
				speedV.Y = -movement_speed_walk;
				swimming_vertical = true;
			}
			else if(is_climbing)
			{
				speedV.Y = -movement_speed_climb;
			}
			else
			{
				// If not free movement but fast is allowed, aux1 is
				// "Turbo button"
				if(fast_move)
					superspeed = true;
			}
		}
	}
	// New minecraft-like descend control
	else
	{
		// Auxiliary button 1 (E)
		if(control.aux1)
		{
			if(!is_climbing)
			{
				// aux1 is "Turbo button"
				if(fast_move)
					superspeed = true;
			}
		}

		if(control.sneak)
		{
			if(free_move)
			{
				// In free movement mode, sneak descends
				if (fast_move && (control.aux1 || always_fly_fast))
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_walk;
			}
			else if(in_liquid || in_liquid_stable)
			{
				if(fast_climb)
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_walk;
				swimming_vertical = true;
			}
			else if(is_climbing)
			{
				if(fast_climb)
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_climb;
			}
		}
	}

	if (continuous_forward)
		speedH += move_direction;

	if (control.up) {
		if (continuous_forward) {
			if (fast_move)
				superspeed = true;
		} else {
			speedH += move_direction;
		}
	}
	if(control.down)
	{
		speedH -= move_direction;
	}
	if(control.left)
	{
		speedH += move_direction.crossProduct(v3f(0,1,0));
	}
	if(control.right)
	{
		speedH += move_direction.crossProduct(v3f(0,-1,0));
	}
	if(control.jump)
	{
		if (free_move) {
			if (g_settings->getBool("aux1_descends") || always_fly_fast) {
				if (fast_move)
					speedV.Y = movement_speed_fast;
				else
					speedV.Y = movement_speed_walk;
			} else {
				if(fast_move && control.aux1)
					speedV.Y = movement_speed_fast;
				else
					speedV.Y = movement_speed_walk;
			}
		}
		else if(m_can_jump)
		{
			/*
				NOTE: The d value in move() affects jump height by
				raising the height at which the jump speed is kept
				at its starting value
			*/
			v3f speedJ = getSpeed();
			if(speedJ.Y >= -0.5 * BS)
			{
				speedJ.Y = movement_speed_jump * physics_override_jump;
				setSpeed(speedJ);

				MtEvent *e = new SimpleTriggerEvent("PlayerJump");
				m_gamedef->event()->put(e);
			}
		}
		else if(in_liquid)
		{
			if(fast_climb)
				speedV.Y = movement_speed_fast;
			else
				speedV.Y = movement_speed_walk;
			swimming_vertical = true;
		}
		else if(is_climbing)
		{
			if(fast_climb)
				speedV.Y = movement_speed_fast;
			else
				speedV.Y = movement_speed_climb;
		}
	}

	// The speed of the player (Y is ignored)
	if(superspeed || (is_climbing && fast_climb) || ((in_liquid || in_liquid_stable) && fast_climb))
		speedH = speedH.normalize() * movement_speed_fast;
	else if(control.sneak && !free_move && !in_liquid && !in_liquid_stable)
		speedH = speedH.normalize() * movement_speed_crouch;
	else
		speedH = speedH.normalize() * movement_speed_walk;

	// Acceleration increase
	f32 incH = 0; // Horizontal (X, Z)
	f32 incV = 0; // Vertical (Y)
	if((!touching_ground && !free_move && !is_climbing && !in_liquid) || (!free_move && m_can_jump && control.jump))
	{
		// Jumping and falling
		if(superspeed || (fast_move && control.aux1))
			incH = movement_acceleration_fast * BS * dtime;
		else
			incH = movement_acceleration_air * BS * dtime;
		incV = 0; // No vertical acceleration in air
	}
	else if (superspeed || (is_climbing && fast_climb) || ((in_liquid || in_liquid_stable) && fast_climb))
		incH = incV = movement_acceleration_fast * BS * dtime;
	else
		incH = incV = movement_acceleration_default * BS * dtime;

	// Accelerate to target speed with maximum increment
	accelerateHorizontal(speedH * physics_override_speed, incH * physics_override_speed);
	accelerateVertical(speedV * physics_override_speed, incV * physics_override_speed);
}
Esempio n. 21
0
void LocalPlayer::applyControl(float dtime)
{
	// Clear stuff
	swimming_up = false;

	// Random constants
	f32 walk_acceleration = 4.0 * BS;
	f32 walkspeed_max = 4.0 * BS;
	
	setPitch(control.pitch);
	setYaw(control.yaw);
	
	v3f move_direction = v3f(0,0,1);
	move_direction.rotateXZBy(getYaw());
	
	v3f speed = v3f(0,0,0);

	bool free_move = g_settings->getBool("free_move");
	bool fast_move = g_settings->getBool("fast_move");
	bool continuous_forward = g_settings->getBool("continuous_forward");

	if(free_move || is_climbing)
	{
		v3f speed = getSpeed();
		speed.Y = 0;
		setSpeed(speed);
	}

	// Whether superspeed mode is used or not
	bool superspeed = false;
	
	// If free movement and fast movement, always move fast
	if(free_move && fast_move)
		superspeed = true;
	
	// Auxiliary button 1 (E)
	if(control.aux1)
	{
		if(free_move)
		{
			// In free movement mode, aux1 descends
			v3f speed = getSpeed();
			if(fast_move)
				speed.Y = -20*BS;
			else
				speed.Y = -walkspeed_max;
			setSpeed(speed);
		}
		else if(is_climbing)
		{
		        v3f speed = getSpeed();
			speed.Y = -3*BS;
			setSpeed(speed);
		}
		else
		{
			// If not free movement but fast is allowed, aux1 is
			// "Turbo button"
			if(fast_move)
				superspeed = true;
		}
	}

	if(continuous_forward)
		speed += move_direction;

	if(control.up)
	{
		if(continuous_forward)
			superspeed = true;
		else
			speed += move_direction;
	}
	if(control.down)
	{
		speed -= move_direction;
	}
	if(control.left)
	{
		speed += move_direction.crossProduct(v3f(0,1,0));
	}
	if(control.right)
	{
		speed += move_direction.crossProduct(v3f(0,-1,0));
	}
	if(control.jump)
	{
		if(free_move)
		{
			v3f speed = getSpeed();
			if(fast_move)
				speed.Y = 20*BS;
			else
				speed.Y = walkspeed_max;
			setSpeed(speed);
		}
		else if(touching_ground)
		{
			v3f speed = getSpeed();
			/*
				NOTE: The d value in move() affects jump height by
				raising the height at which the jump speed is kept
				at its starting value
			*/
			speed.Y = 6.5*BS;
			setSpeed(speed);
		}
		// Use the oscillating value for getting out of water
		// (so that the player doesn't fly on the surface)
		else if(in_water)
		{
			v3f speed = getSpeed();
			speed.Y = 1.5*BS;
			setSpeed(speed);
			swimming_up = true;
		}
		else if(is_climbing)
		{
	                v3f speed = getSpeed();
			speed.Y = 3*BS;
			setSpeed(speed);
		}
	}

	// The speed of the player (Y is ignored)
	if(superspeed)
		speed = speed.normalize() * walkspeed_max * 5.0;
	else if(control.sneak)
		speed = speed.normalize() * walkspeed_max / 3.0;
	else
		speed = speed.normalize() * walkspeed_max;
	
	f32 inc = walk_acceleration * BS * dtime;
	
	// Faster acceleration if fast and free movement
	if(free_move && fast_move)
		inc = walk_acceleration * BS * dtime * 10;
	
	// Accelerate to target speed with maximum increment
	accelerate(speed, inc);
}
Esempio n. 22
0
PD_UI_Dialogue::PD_UI_Dialogue(BulletWorld * _world, PD_UI_Bubble * _uiBubble) :
	NodeUI(_world),
	uiBubble(_uiBubble),
	textBubble(new NodeUI_NineSliced(world, dynamic_cast<Texture_NineSliced *>(PD_ResourceManager::scenario->getTexture("NPC-BUBBLE")->texture))),
	text(new TextArea(world, PD_ResourceManager::scenario->getFont("FONT")->font, uiBubble->textShader)),
	currentSpeaker(nullptr),
	speechTimeout(nullptr),
	hadNextDialogue(false)
{
	text->setWrapMode(kWORD);
	setRenderMode(kTEXTURE);
	VerticalLinearLayout * vl = new VerticalLinearLayout(world);
	vl->setRationalWidth(1.f, this);
	vl->setRationalHeight(1.f, this);

	vl->horizontalAlignment = kCENTER;
	vl->verticalAlignment = kTOP;

	VerticalLinearLayout * vl2 = new VerticalLinearLayout(world);

	vl2->horizontalAlignment = kCENTER;
	vl2->verticalAlignment = kMIDDLE;

	addChild(vl);
	vl->addChild(textBubble);
	textBubble->setMargin(15,15,0,15);
	textBubble->setBorder(PD_ResourceManager::scenario->getFont("FONT")->font->getLineHeight());
	textBubble->setRationalWidth(0.9f, vl);
	textBubble->setRationalHeight(0.25f, vl);
	textBubble->addChild(vl2);
	vl2->setRationalWidth(1.f, textBubble);
	vl2->setRationalHeight(1.f, textBubble);
	vl2->addChild(text);
	vl2->setPadding(0.03f, 0.f);
	text->setRationalWidth(1.f, vl2);
	text->verticalAlignment = kMIDDLE;
	background->setVisible(false);

	// disable and hide by default
	setVisible(false);

	speechTimeout = new Timeout(0.15, [this](sweet::Event * _event){
		if(speechBuffer.size() > 0) {
			std::wstring word = speechBuffer.front();
			char fc = tolower(word.at(word.size()/2));
			speechBuffer.pop();
			if(currentSpeaker != nullptr){
				auto sound = currentSpeaker->voice;
				if(sweet::CharacterUtils::isLetter(fc) || sweet::CharacterUtils::isDigit(fc)){
					sound->setPitch((fc-100.f)/100.f+1.0f);
					sound->play();
				}
			}
			speechTimeout->restart();
		}else {
			if(currentSpeaker != nullptr) {
				currentSpeaker->pr->talking = false;
			}
		}
	});
}
Esempio n. 23
0
void PlayerSAO::setPitchAndSend(const float pitch)
{
	setPitch(pitch);
	m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
Esempio n. 24
0
void sfSoundStream_setPitch(sfSoundStream* soundStream, float pitch)
{
    CSFML_CALL(soundStream, setPitch(pitch));
}
Esempio n. 25
0
void Kompas::on()
{

    timer->stop();
    QSerialPortInfo *info = new QSerialPortInfo(*port);
    if(!(port->isOpen() && info->portName() == settings->m_name_COM))
    {
        if(port->isOpen())
            port->close();

        qDebug()<<settings->m_name_COM;
        port->setPortName(settings->m_name_COM);
        if (port->open(QIODevice::ReadWrite))
        {
            QFile file("dataRead.dat");
            if (file.open(QIODevice::ReadOnly | QIODevice::Text))
            {
               QTextStream stream(&file);
               m_skl = stream.readLine().toInt();
               m_coef_A = stream.readLine().toInt();
               file.close();
            }

            updateSettings();
            QSerialPortInfo *info = new QSerialPortInfo(*port);
            qDebug() << "Name        : " << info->portName();
            qDebug() << "Description : " << info->description();
            qDebug() << "Manufacturer: " << info->manufacturer();
            qDebug() << "BaudRate: " << port->baudRate();
            qDebug() << "Parity: " << port->parity();
            qDebug() << "Data bits: " << port->dataBits();
            qDebug() << "Stop Bits: " << port->stopBits();
            delete info;
            m_state=1;
            emit stateChanged();
            m_connect_state=1;
            emit connect_stateChanged();
            qDebug()<<"state = 1 ON";
            qDebug()<<settings->m_name_COM<<"opened";
        }
        else
        {
            if(port->isOpen())
                port->close();
            qDebug()<<"Error while opening";
        }
    }
    if(port->isOpen() && port->waitForReadyRead(1000))
    {
        QString data;
        QByteArray ByteArray;
        m_state = 1;
        while(m_state)
        {
            qint64 byteAvail = port->bytesAvailable();
            qApp->processEvents();
            if(byteAvail >=13)
            {
                ByteArray = port->readAll();
                data = data.fromLocal8Bit(ByteArray).trimmed();
                if(ByteArray[3]=='p')
                {
                    QBitArray bitdata(104),two_bytes(16);
                    for(int i = 0,j; i < 104; ++i)
                    {
                        j=i/8;
                        if(j<=13)
                            bitdata[i] = ByteArray[j] & (1 << i%8);
                        else
                            break;
                    }

                    for(int i=40,j=15;i<56&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Roll
                    setRoll(Round(toDec(two_bytes,1)*1.41,1));
                    for(int i=56,j=15;i<72&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Pitch
                    setPitch(Round(toDec(two_bytes,1)*1.41,1));
                    for(int i=72,j=15;i<88&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Azimuth

                    setAngle(Round(toDec(two_bytes,0)*1.41,1));
                    m_state=0;
                    qApp->processEvents();
                }
            }
        }
    }
    else
    {
        qDebug()<<"WaitForReadyRead failed";
        qDebug()<<port->error();
    }
    kompasThread1->quit();
    timer->start(10);
}
Esempio n. 26
0
bool SFXSource::_allocVoice( SFXDevice* device )
{
   // We shouldn't have any existing voice!
   AssertFatal( !mVoice, "SFXSource::_allocVoice() - Already had a voice!" );

   // Must not assign voice to source that isn't playing.
   AssertFatal( getLastStatus() == SFXStatusPlaying,
      "SFXSource::_allocVoice() - Source is not playing!" );

   // The buffer can be lost when the device is reset 
   // or changed, so initialize it if we have to.  If
   // that fails then we cannot create the voice.
   
   if( mBuffer.isNull() )
   {
      if( mProfile != NULL )
         _setBuffer( mProfile->getBuffer() );

      if( mBuffer.isNull() )
         return false;
   }

   // Ask the device for a voice based on this buffer.
   mVoice = device->createVoice( mIs3D, mBuffer );
   if( !mVoice )
      return false;

   setVolume( mVolume );
   if( mPitch != 1.0f )
      setPitch( mPitch );
   
   if( mIs3D )
   {
      setTransform( mTransform );
      setVelocity( mVelocity );
      setMinMaxDistance( mMinDistance, mMaxDistance );
      setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume );
   }

   // Update the duration... it shouldn't have changed, but
   // its probably better that we're accurate if it did.
   mDuration = mBuffer->getDuration();

   // If virtualized playback has been started, we transfer its position to the
   // voice and stop virtualization.

   if( mVirtualPlayTimer.isStarted() )
   {
      const U32 playTime = mVirtualPlayTimer.getPosition();
      const U32 pos = mBuffer->getFormat().getSampleCount( playTime );
      mVoice->setPosition( pos);
      mVirtualPlayTimer.stop();
   }

   mVoice->play( mIsLooping );
   
   #ifdef DEBUG_SPEW
   Platform::outputDebugString( "[SFXSource] allocated voice for source '%i'", getId() );
   #endif
   
   return true;
}
Esempio n. 27
0
void LocalPlayer::applyControl(float dtime, ClientEnvironment *env)
{
	// Clear stuff
	swimming_vertical = false;

	setPitch(control.pitch);
	setYaw(control.yaw);

	// Nullify speed and don't run positioning code if the player is attached
	if(isAttached)
	{
		setSpeed(v3f(0,0,0));
		return;
	}

	v3f move_direction = v3f(0,0,1);
	move_direction.rotateXZBy(getYaw());

	v3f speedH = v3f(0,0,0); // Horizontal (X, Z)
	v3f speedV = v3f(0,0,0); // Vertical (Y)

	bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
	bool fast_allowed = m_gamedef->checkLocalPrivilege("fast");

	free_move = fly_allowed && g_settings->getBool("free_move");
	bool fast_move = fast_allowed && g_settings->getBool("fast_move");
	// When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
	bool fast_climb = fast_move && control.aux1 && !g_settings->getBool("aux1_descends");
	bool continuous_forward = g_settings->getBool("continuous_forward");
	bool fast_pressed = false;
	bool always_fly_fast = g_settings->getBool("always_fly_fast");

	// Whether superspeed mode is used or not
	superspeed = false;

	if (always_fly_fast && free_move && fast_move)
		superspeed = true;

	// Old descend control
	if(g_settings->getBool("aux1_descends"))
	{
		// If free movement and fast movement, always move fast
		if(free_move && fast_move)
			superspeed = true;

		// Auxiliary button 1 (E)
		if(control.aux1)
		{
			if(free_move)
			{
				// In free movement mode, aux1 descends
				if(fast_move)
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_walk;
			}
			else if(in_liquid || in_liquid_stable)
			{
				speedV.Y = -movement_speed_walk;
				swimming_vertical = true;
			}
			else if(is_climbing)
			{
				speedV.Y = -movement_speed_climb;
			}
			else
			{
				// If not free movement but fast is allowed, aux1 is
				// "Turbo button"
				if(fast_allowed)
					superspeed = true;
			}
		}
	}
	// New minecraft-like descend control
	else
	{
		// Auxiliary button 1 (E)
		if(control.aux1)
		{
			if(!is_climbing)
			{
				// aux1 is "Turbo button"
				if(fast_allowed)
					superspeed = true;
			}
			if(fast_allowed)
				fast_pressed = true;
		}

		if(control.sneak)
		{
			if(free_move)
			{
				// In free movement mode, sneak descends
				if (fast_move && (control.aux1 || always_fly_fast))
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_walk;
			}
			else if(in_liquid || in_liquid_stable)
			{
				if(fast_climb)
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_walk;
				swimming_vertical = true;
			}
			else if(is_climbing)
			{
				if(fast_climb)
					speedV.Y = -movement_speed_fast;
				else
					speedV.Y = -movement_speed_climb;
			}
		}
	}

	if (continuous_forward)
		speedH += move_direction;

	if (control.up) {
		if (continuous_forward) {
			if (fast_move)
				superspeed = true;
		} else {
			speedH += move_direction;
		}
	}
	if(control.down)
	{
		speedH -= move_direction;
	}
	if(control.left)
	{
		speedH += move_direction.crossProduct(v3f(0,1,0));
	}
	if(control.right)
	{
		speedH += move_direction.crossProduct(v3f(0,-1,0));
	}
	if(control.jump)
	{
		if (free_move) {
			if (g_settings->getBool("aux1_descends") || always_fly_fast) {
				if (fast_move)
					speedV.Y = movement_speed_fast;
				else
					speedV.Y = movement_speed_walk;
			} else {
				if(fast_move && control.aux1)
					speedV.Y = movement_speed_fast;
				else
					speedV.Y = movement_speed_walk;
			}
		}
		else if(m_can_jump)
		{
			/*
				NOTE: The d value in move() affects jump height by
				raising the height at which the jump speed is kept
				at its starting value
			*/
			v3f speedJ = getSpeed();
			if(speedJ.Y >= -0.5 * BS)
			{
				speedJ.Y = movement_speed_jump * physics_override_jump;
				setSpeed(speedJ);

				MtEvent *e = new SimpleTriggerEvent("PlayerJump");
				m_gamedef->event()->put(e);
			}
		}
		else if(in_liquid)
		{
			if(fast_climb)
				speedV.Y = movement_speed_fast;
			else
				speedV.Y = movement_speed_walk;
			swimming_vertical = true;
		}
		else if(is_climbing)
		{
			if(fast_climb)
				speedV.Y = movement_speed_fast;
			else
				speedV.Y = movement_speed_climb;
		}
	}

	// The speed of the player (Y is ignored)
	if(superspeed || (is_climbing && fast_climb) || ((in_liquid || in_liquid_stable) && fast_climb) || fast_pressed)
		speedH = speedH.normalize() * movement_speed_fast;
	else if(control.sneak && !free_move && !in_liquid && !in_liquid_stable)
		speedH = speedH.normalize() * movement_speed_crouch;
	else
		speedH = speedH.normalize() * movement_speed_walk;

	// Acceleration increase
	f32 incH = 0; // Horizontal (X, Z)
	f32 incV = 0; // Vertical (Y)
	if((!touching_ground && !free_move && !is_climbing && !in_liquid) || (!free_move && m_can_jump && control.jump))
	{
		// Jumping and falling
		if(superspeed || (fast_move && control.aux1))
			incH = movement_acceleration_fast * BS * dtime;
		else
			incH = movement_acceleration_air * BS * dtime;
		incV = 0; // No vertical acceleration in air

		// better air control when falling fast
		float speed = m_speed.getLength();
		if (!superspeed && speed > movement_speed_fast && (control.down || control.up || control.left || control.right)) {
			v3f rotate = move_direction * (speed / (movement_fall_aerodynamics * BS));

			if(control.up)		rotate = rotate.crossProduct(v3f(0,1,0));
			if(control.down)	rotate = rotate.crossProduct(v3f(0,-1,0));
			if(control.left)	rotate *=-1;
			m_speed.rotateYZBy(rotate.X);
			m_speed.rotateXZBy(rotate.Y);
			m_speed.rotateXYBy(rotate.Z);
			m_speed = m_speed.normalize() * speed * (1-speed*0.00001); // 0.998
			if (m_speed.Y)
				return;
		}
	}
	else if (superspeed || (is_climbing && fast_climb) || ((in_liquid || in_liquid_stable) && fast_climb))
		incH = incV = movement_acceleration_fast * BS * dtime;
	else
		incH = incV = movement_acceleration_default * BS * dtime;

	// Accelerate to target speed with maximum increment
	INodeDefManager *nodemgr = m_gamedef->ndef();
	Map *map = &env->getMap();
	v3s16 p = floatToInt(getPosition() - v3f(0,BS/2,0), BS);
	float slippery = 0;
	try {
		slippery = itemgroup_get(nodemgr->get(map->getNode(p)).groups, "slippery");
	}
	catch (...) {}
	accelerateHorizontal(speedH * physics_override_speed, incH * physics_override_speed, slippery);
	accelerateVertical(speedV * physics_override_speed, incV * physics_override_speed);
}
Esempio n. 28
0
void LocalPlayer::applyControl(float dtime)
{
	// Clear stuff
	swimming_up = false;

	// Random constants
	f32 walk_acceleration = 4.0 * BS;
	f32 walkspeed_max = 4.0 * BS;
	
	setPitch(control.pitch);
	setYaw(control.yaw);

	// Nullify speed and don't run positioning code if the player is attached
	if(isAttached)
	{
		setSpeed(v3f(0,0,0));
		return;
	}

	v3f move_direction = v3f(0,0,1);
	move_direction.rotateXZBy(getYaw());
	
	v3f speed = v3f(0,0,0);
	
	bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
	bool fast_allowed = m_gamedef->checkLocalPrivilege("fast");

	bool free_move = fly_allowed && g_settings->getBool("free_move");
	bool fast_move = fast_allowed && g_settings->getBool("fast_move");
	bool continuous_forward = g_settings->getBool("continuous_forward");

	if(free_move || is_climbing)
	{
		v3f speed = getSpeed();
		speed.Y = 0;
		setSpeed(speed);
	}

	// Whether superspeed mode is used or not
	bool superspeed = false;
	
	// Old descend control
	if(g_settings->getBool("aux1_descends"))
	{
		// If free movement and fast movement, always move fast
		if(free_move && fast_move)
			superspeed = true;
		
		// Auxiliary button 1 (E)
		if(control.aux1)
		{
			if(free_move)
			{
				// In free movement mode, aux1 descends
				v3f speed = getSpeed();
				if(fast_move)
					speed.Y = -20*BS;
				else
					speed.Y = -walkspeed_max;
				setSpeed(speed);
			}
			else if(is_climbing)
			{
					v3f speed = getSpeed();
				speed.Y = -3*BS;
				setSpeed(speed);
			}
			else
			{
				// If not free movement but fast is allowed, aux1 is
				// "Turbo button"
				if(fast_move)
					superspeed = true;
			}
		}
	}
	// New minecraft-like descend control
	else
	{
		// Auxiliary button 1 (E)
		if(control.aux1)
		{
			if(!is_climbing)
			{
				// aux1 is "Turbo button"
				if(fast_move)
					superspeed = true;
			}
		}

		if(control.sneak)
		{
			if(free_move)
			{
				// In free movement mode, sneak descends
				v3f speed = getSpeed();
				if(fast_move && control.aux1)
					speed.Y = -20*BS;
				else
					speed.Y = -walkspeed_max;
					setSpeed(speed);
			}
			else if(is_climbing)
			{
				v3f speed = getSpeed();
				speed.Y = -3*BS;
				setSpeed(speed);
			}
		}
	}

	if(continuous_forward)
		speed += move_direction;

	if(control.up)
	{
		if(continuous_forward)
			superspeed = true;
		else
			speed += move_direction;
	}
	if(control.down)
	{
		speed -= move_direction;
	}
	if(control.left)
	{
		speed += move_direction.crossProduct(v3f(0,1,0));
	}
	if(control.right)
	{
		speed += move_direction.crossProduct(v3f(0,-1,0));
	}
	if(control.jump)
	{
		if(free_move)
		{
			v3f speed = getSpeed();
			
			if(g_settings->getBool("aux1_descends"))
			{
				if(fast_move)
					speed.Y = 20*BS;
				else
					speed.Y = walkspeed_max;
			} else {
				if(fast_move && control.aux1)
					speed.Y = 20*BS;
				else
					speed.Y = walkspeed_max;
			}
			
			setSpeed(speed);
		}
		else if(m_can_jump)
		{
			/*
				NOTE: The d value in move() affects jump height by
				raising the height at which the jump speed is kept
				at its starting value
			*/
			v3f speed = getSpeed();
			if(speed.Y >= -0.5*BS)
			{
				speed.Y = 6.5*BS;
				setSpeed(speed);
				
				MtEvent *e = new SimpleTriggerEvent("PlayerJump");
				m_gamedef->event()->put(e);
			}
		}
		// Use the oscillating value for getting out of water
		// (so that the player doesn't fly on the surface)
		else if(in_water)
		{
			v3f speed = getSpeed();
			speed.Y = 1.5*BS;
			setSpeed(speed);
			swimming_up = true;
		}
		else if(is_climbing)
		{
	                v3f speed = getSpeed();
			speed.Y = 3*BS;
			setSpeed(speed);
		}
	}

	// The speed of the player (Y is ignored)
	if(superspeed)
		speed = speed.normalize() * walkspeed_max * 5.0;
	else if(control.sneak && !free_move)
		speed = speed.normalize() * walkspeed_max / 3.0;
	else
		speed = speed.normalize() * walkspeed_max;
	
	f32 inc = walk_acceleration * BS * dtime;
	
	// Faster acceleration if fast and free movement
	if(free_move && fast_move && superspeed)
		inc = walk_acceleration * BS * dtime * 10;
	
	// Accelerate to target speed with maximum increment
	accelerate(speed, inc);
}
Oscillator::Oscillator(void)
{
  m_tempo = 120.0f;

  m_sync = true;

  m_waveform = k_sine;

  m_startphase = 0.0;
  m_phase=m_startphase;
  m_pitch = 0.0f;
  m_detune = 0.0f;
  m_semi = 0.0f;
  m_pw = 0.0f;
  m_pwm = 0.0f;
  m_pw_mod = 0.0f;
  m_pitch_mod = 0.0f;

  //noise generation
  m_gaussian_noise_constant_a = 0x67452301;
  m_gaussian_noise_constant_c = static_cast<int>(0xefcdab89);
  m_sampleandhold_period=1;
  m_sampleandhold_counter=0;
  m_sample = 0.0f;
  m_fintmax = static_cast<float>(std::numeric_limits<int>::max());

  isActive=false;

  setOscMode(k_oscmode_oscillator);
  setDetune(0.5f);
  setSemi(0.5f);
  setVolume(1.0f);
  setPW(0.5f);
  setPWM(0.0f);
  setPitch(440.0f);

  /* populate bpm denominators
     4 full notes				= BPM / 960 => speed 0
     Dotted 2 full notes			= BPM / 720
     Triplets for 4 full notes	= BPM / 640
     2 full notes				= BPM / 480
     Dotted full note			= BPM / 360
     Triplets for 2 full notes	= BPM / 320
     Full note					= BPM / 240
     Dotted-half note			= BPM / 180
     Triplet-full note			= BPM / 160
     Half note					= BPM / 120
     Dotted-quarter note			= BPM / 90
     Triplet-half note			= BPM / 80
     Quarter note				= BPM / 60
     Dotted-eighth note			= BPM / 45
     Triplet-quarter note		= BPM / 40
     Eighth note					= BPM / 30
     Dotted-sixteenth note		= BPM / 22.5
     Triplet-eighth note			= BPM / 20
     Sixteenth note				= BPM / 15
     Dotted-32th note			= BPM / 11.25
     Triplet-sixteenth note		= BPM / 10
     32th note					= BPM / 7.5
     Dotted-64th note			= BPM / 5.5125
     Triplet-32th note			= BPM / 5
     64th note					= BPM / 3.75
     Dotted-128th note			= BPM / 2.75625
     Triplet-64th note			= BPM / 2.5
     128th note					= BPM / 1.875
     Triplet-128th note			= BPM / 1.25 => speed g_num_bpm_synced_lfo_speeds-1
     */
//TODO: less hardcoding
  m_bpm_denominators[0]=960.0f;
  m_bpm_denominators[1]=720.0f;
  m_bpm_denominators[2]=640.0f;
  m_bpm_denominators[3]=480.0f;
  m_bpm_denominators[4]=360.0f;
  m_bpm_denominators[5]=320.0f;
  m_bpm_denominators[6]=240.0f;
  m_bpm_denominators[7]=180.0f;
  m_bpm_denominators[8]=160.0f;
  m_bpm_denominators[9]=120.0f;
  m_bpm_denominators[10]=90.0f;
  m_bpm_denominators[11]=80.0f;
  m_bpm_denominators[12]=60.0f;
  m_bpm_denominators[13]=45.0f;
  m_bpm_denominators[14]=40.0f;
  m_bpm_denominators[15]=30.0f;
  m_bpm_denominators[16]=22.5f;
  m_bpm_denominators[17]=20.0f;
  m_bpm_denominators[18]=15.0f;
  m_bpm_denominators[19]=11.25f;
  m_bpm_denominators[20]=10.0f;
  m_bpm_denominators[21]=7.5f;
  m_bpm_denominators[22]=5.5125f;
  m_bpm_denominators[23]=5.0f;
  m_bpm_denominators[24]=3.750f;
  m_bpm_denominators[25]=2.75625f;
  m_bpm_denominators[26]=2.5f;
  m_bpm_denominators[27]=1.875f;
  m_bpm_denominators[28]=1.25f;
}
void PlaneState::updateState(const Basic::Component* const actor)
{
   const Simulation::AirVehicle* airVehicle = dynamic_cast<const Simulation::AirVehicle*>(actor);
   setAlive(false);
   if (airVehicle != nullptr && airVehicle->isActive()) {
      setAltitude(airVehicle->getAltitude());
      setAlive(airVehicle->getMode() == Simulation::Player::ACTIVE);
      setHeading(airVehicle->getHeading());
      setPitch(airVehicle->getPitch());
      setRoll(airVehicle->getRoll());
      osg::Vec3d angularVels = airVehicle->getAngularVelocities();
      setRollRate(angularVels.x());
      setPitchRate(angularVels.y());
      setYawRate(angularVels.z());
      setTracking(false);
      setTargetTrack(MAX_TRACKS);  // 0 is a valid target track, use MAX_TRACKS to
                                   // signal "no tgt track"
      setSpeed(airVehicle->getCalibratedAirspeed());
      setNumEngines(airVehicle->getNumberOfEngines());
      setIncomingMissile(false);
      setMissileFired(false);

      // determine if we have a missile to fire
#if 1
      const Simulation::StoresMgr* stores = airVehicle->getStoresManagement();
      if (stores == nullptr || stores->getNextMissile() == nullptr) {
         // either we have no SMS, or we have no more missile
         setMissileFired(true);
      }
      else {
         // we have an sms, and we have a missile available
         // loop through player list and attempt to find out if one of our missiles is active
         // if there is an active missile, then for the time being, we do not have a missile to fire
         const Simulation::Simulation* sim = airVehicle->getSimulation();
         const Basic::PairStream* players = sim->getPlayers();
         bool finished = false;
         for (const Basic::List::Item* item = players->getFirstItem(); item != nullptr && !finished; item = item->getNext()) {
            // Get the pointer to the target player
            const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue());
            const Simulation::Player* player = static_cast<const Simulation::Player*>(pair->object());
            if (player->isMajorType(Simulation::Player::WEAPON) && (player->isActive() || player->isMode(Simulation::Player::PRE_RELEASE)) && (player->getSide() == airVehicle->getSide())) {
               // our side has a weapon on-the-way/in-the-air;
               setMissileFired(true);
               finished=true;
            }
         }
      }
#else
      // this state class has no way to determine whether we've fired a missile other than checking to see if sms is out of missiles to fire.
      // which means, it will fire all its missiles at first target.
      const Simulation::StoresMgr* stores = airVehicle->getStoresManagement();
      if (stores != 0) {
         const Simulation::Missile* wpn = stores->getNextMissile();
         if (!wpn)
            setMissileFired(true);
      }
      else {
         // we have no SMS, we can't fire a missile;
         setMissileFired(true);
      }
#endif

      //const Basic::String* playerName = airVehicle->getName();
      // DH - DOES NOT COMPILE WITH CONST -- ????
      Simulation::AirVehicle* airVehicleX = const_cast<Simulation::AirVehicle*>(airVehicle);
      const Basic::Pair* sensorPair = airVehicleX->getSensorByType(typeid(Simulation::Radar));

      if (sensorPair != nullptr) {
         const Simulation::Radar* radar = static_cast<const Simulation::Radar*>(sensorPair->object());
         if (radar != nullptr) {
            const Simulation::TrackManager* trackManager = radar->getTrackManager();
            Basic::safe_ptr<Simulation::Track> trackList[50];
            unsigned int nTracks = trackManager->getTrackList(trackList, 50);

            for (int trackIndex = nTracks -1; trackIndex >= 0; trackIndex--) {
               setHeadingToTracked(trackIndex, trackList[trackIndex]->getRelAzimuth());
               setPitchToTracked(trackIndex, trackList[trackIndex]->getElevation());
               setDistanceToTracked(trackIndex, trackList[trackIndex]->getRange());

               // do we have a live "target track"? (shootlist is 1-based)
               if (getTargetTrack()==MAX_TRACKS && (trackList[trackIndex]->getShootListIndex() == 1) && trackList[trackIndex]->getTarget()->isActive()  ) {
                  setTargetTrack(trackIndex);
               }
               setTracking(true);
               setNumTracks(nTracks);

               // hack to implement "missile warning"
               if (isIncomingMissile() == false) {
                  // is this track a weapon, and if so, is it targeting me?
                  Simulation::Player* target = trackList[trackIndex]->getTarget();
                  Simulation::Weapon* weapon = dynamic_cast<Simulation::Weapon*> (target);
                  if (weapon!=nullptr && !weapon->isDead()) {
                     Simulation::Player* wpntgt = weapon->getTargetPlayer();
                     if (wpntgt == airVehicle) {
                        setIncomingMissile(true);
                     }
                  }
               }

            }
         }
      }

      const Simulation::OnboardComputer* oc = airVehicle->getOnboardComputer();
      if (oc != nullptr) {
         const Simulation::TrackManager* rtm = oc->getTrackManagerByType(typeid(Simulation::RwrTrkMgr));
         if(rtm !=nullptr) {
            Basic::safe_ptr<Simulation::Track> trackList[50];
            unsigned int nTracks = rtm->getTrackList(trackList, 50);
            int newTracks = 0;
            for (unsigned int trackIndex = 0; trackIndex < nTracks; trackIndex++) {
               Simulation::Player* target = trackList[trackIndex]->getTarget();
               bool alreadyTracked = false;
               for (unsigned int currTracks = 0; currTracks>getNumTracks(); currTracks++) {
                  // tracks are the same if the associated players are the same
                  if(trackList[currTracks]->getTarget()==target) {
                     alreadyTracked = true;
                     break;
                  }
               }

               if (!alreadyTracked && (getNumTracks() + newTracks) < MAX_TRACKS) {
                  int newTrackIndex = getNumTracks() + newTracks;
                  newTracks++;
                  setHeadingToTracked(newTrackIndex, trackList[trackIndex]->getRelAzimuth());
                  setPitchToTracked(newTrackIndex, trackList[trackIndex]->getElevation());
                  setDistanceToTracked(newTrackIndex, trackList[trackIndex]->getRange());
                  setTracking(true);

                  // update numTracks to new sum of radar + rwr tracks
                  setNumTracks(getNumTracks()+newTracks);
               }

               // do we have a live "target track"? (shootlist is 1-based)
               if (getTargetTrack()==MAX_TRACKS && (trackList[trackIndex]->getShootListIndex() == 1) && trackList[trackIndex]->getTarget()->isActive()  ) {
                  setTargetTrack(trackIndex);
               }

               // hack to implement "missile warning"
               if (isIncomingMissile() == false) {
                  // is this track a weapon, and if so, is it targeting me?
                  Simulation::Weapon* weapon = dynamic_cast<Simulation::Weapon*> (target);
                  if (weapon!=nullptr && !weapon->isDead()) {
                     Simulation::Player* wpntgt = weapon->getTargetPlayer();
                     if (wpntgt == airVehicle) {
                        setIncomingMissile(true);
                     }
                  }
               }

            }
         }
      }
   }
   BaseClass::updateState(actor);
}