mirror of
https://github.com/DrBeef/Doom3Quest.git
synced 2024-11-23 12:22:20 +00:00
rotation applied to sound triggered patterns
This commit is contained in:
parent
5d8c608873
commit
05cd450829
3 changed files with 49 additions and 22 deletions
|
@ -1621,6 +1621,37 @@ bool idEntity::StartSoundShader( const idSoundShader *shader, const s_channelTyp
|
|||
*length = len;
|
||||
}
|
||||
|
||||
idPlayer *player = gameLocal.GetLocalPlayer();
|
||||
if (vr_bhaptics.GetBool() &&
|
||||
player != NULL) {
|
||||
idVec3 playerOrigin = gameLocal.GetLocalPlayer()->GetPlayerPhysics()->GetOrigin(0);
|
||||
idVec3 entityOrigin = GetPhysics()->GetOrigin(0);
|
||||
idVec3 direction = playerOrigin - entityOrigin;
|
||||
|
||||
float distance = direction.Length();
|
||||
|
||||
if (distance <= 150.0F) {
|
||||
bool repeat = (shader->GetParms()->soundShaderFlags & SSF_LOOPING) != 0;
|
||||
|
||||
direction.Normalize();
|
||||
idVec3 bodyOrigin = vec3_zero;
|
||||
idMat3 bodyAxis;
|
||||
player->GetViewPos( bodyOrigin, bodyAxis );
|
||||
idAngles bodyAng = bodyAxis.ToAngles();
|
||||
|
||||
/* float pitch = direction.ToPitch();
|
||||
if (pitch > 180)
|
||||
pitch -= 360;
|
||||
float yHeight = idMath::ClampFloat(-0.5f, 0.45f, -pitch / 90.0f);*/
|
||||
idAngles directionYaw(0, 180 + (direction.ToYaw() - bodyAng.yaw), 0);
|
||||
directionYaw.Normalize360();
|
||||
|
||||
//Pass sound on in case it can trigger a haptic event (like doors)
|
||||
float intensity = 40 + Min<float>((int)(150.0f - distance), 80);
|
||||
common->HapticEvent(shader->GetName(), 4, repeat ? 1 : 0, intensity, directionYaw.yaw, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// set reference to the sound for shader synced effects
|
||||
renderEntity.referenceSound = refSound.referenceSound;
|
||||
|
||||
|
@ -1649,6 +1680,10 @@ void idEntity::StopSound( const s_channelType channel, bool broadcast ) {
|
|||
|
||||
if ( refSound.referenceSound ) {
|
||||
refSound.referenceSound->StopSound( channel );
|
||||
|
||||
if (refSound.shader) {
|
||||
common->HapticStopEvent(refSound.shader->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12630,12 +12630,12 @@ void idPlayer::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &di
|
|||
GetViewPos( bodyOrigin, bodyAxis );
|
||||
idAngles bodyAng = bodyAxis.ToAngles();
|
||||
|
||||
float yHeight = idMath::ClampFloat(-0.5f, 0.5f, damage_from.ToPitch() / 45.0f);
|
||||
float damageYaw = 180 + (damage_from.ToYaw() - bodyAng.yaw);
|
||||
if (damageYaw < 0.0f)
|
||||
damageYaw += 360.0f;
|
||||
if (damageYaw >= 360.0f)
|
||||
damageYaw -= 360.0f;
|
||||
float pitch = damage_from.ToPitch();
|
||||
if (pitch > 180)
|
||||
pitch -= 360;
|
||||
float yHeight = idMath::ClampFloat(-0.4f, 0.4f, -pitch / 90.0f);
|
||||
idAngles damageYaw(0, 180 + (damage_from.ToYaw() - bodyAng.yaw), 0);
|
||||
damageYaw.Normalize360();
|
||||
|
||||
//Ensure a decent level of haptic feedback for any damage
|
||||
float hapticLevel = 80 + Min<float>(damage * 4, 120.0);
|
||||
|
@ -12643,9 +12643,9 @@ void idPlayer::Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &di
|
|||
//Indicate head damage if appropriate
|
||||
if ( location >= 0 && location < damageGroups.Size() &&
|
||||
strstr( damageGroups[location].c_str(), "head" ) ) {
|
||||
common->HapticEvent(damageDefName, 4, 0, hapticLevel, damageYaw, yHeight);
|
||||
common->HapticEvent(damageDefName, 4, 0, hapticLevel, damageYaw.yaw, yHeight);
|
||||
} else {
|
||||
common->HapticEvent(damageDefName, 0, 0, hapticLevel, damageYaw, yHeight);
|
||||
common->HapticEvent(damageDefName, 0, 0, hapticLevel, damageYaw.yaw, yHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,15 +132,14 @@ public class bHaptics {
|
|||
registerFromAsset(context, "bHaptics/Interaction/Arms/Healthstation_L.tact", PositionType.ForearmL, "healstation", "pickup");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Arms/Healthstation_R.tact", PositionType.ForearmR, "healstation", "pickup");
|
||||
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/DoorSlide.tact", "dooropen", "door");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/DoorSlide.tact", "doorclose", "door");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/DoorSlide.tact", "doorslide", "door");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Scan.tact", PositionType.Vest, "scan", "environment", 1.0f, 1.15f);
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Scan.tact", PositionType.Vest, "decontaminate", "environment", 0.5f, 0.75f);
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Chamber_Up.tact", "liftup", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Chamber_Down.tact", "liftdown", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_Machine.tact", "machine", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Spark.tact", "spark", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Head/Spark.tact", "spark", "environment");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Head/Spark.tact", PositionType.Head, "spark", "environment");
|
||||
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_PDA_Open.tact", "pda_open", "pda");
|
||||
registerFromAsset(context, "bHaptics/Interaction/Vest/Body_PDA_Open.tact", "pda_close", "pda");
|
||||
|
@ -424,7 +423,7 @@ public class bHaptics {
|
|||
if (enabled && hasPairedDevice) {
|
||||
String key = getHapticEventKey(event);
|
||||
|
||||
Log.v(TAG, event);
|
||||
//Log.v(TAG, event);
|
||||
|
||||
//Special rumble effect that changes intensity per frame
|
||||
if (key.compareTo("rumble") == 0)
|
||||
|
@ -527,7 +526,7 @@ public class bHaptics {
|
|||
}
|
||||
else
|
||||
{
|
||||
//Log.v(TAG, "Unknown Event: " + event);
|
||||
Log.v(TAG, "Unknown Event: " + event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,16 +564,9 @@ public class bHaptics {
|
|||
key = "fall";
|
||||
}
|
||||
}
|
||||
else if (key.contains("door") || key.contains("panel"))
|
||||
else if (key.contains("door") || key.contains("panel") || key.contains("silver_sliding"))
|
||||
{
|
||||
if (key.contains("close"))
|
||||
{
|
||||
key = "doorclose";
|
||||
}
|
||||
else if (key.contains("open"))
|
||||
{
|
||||
key = "dooropen";
|
||||
}
|
||||
key = "doorslide";
|
||||
}
|
||||
else if (key.contains("lift"))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue