Kampfsystem für Zweihänder vorerst abgeschlossen
This commit is contained in:
@@ -407,6 +407,8 @@ public class PlayerInputControl implements CombatStyleBase.AnimReceiver {
|
|||||||
this.visual = visual;
|
this.visual = visual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Spatial getVisual() { return visual; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setzt die Navigationsquellen (PathFinder + Terrain). Muss vor oder beim
|
* Setzt die Navigationsquellen (PathFinder + Terrain). Muss vor oder beim
|
||||||
* ersten setAnimationContext gesetzt sein, damit der CharacterNavigator
|
* ersten setAnimationContext gesetzt sein, damit der CharacterNavigator
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class WeaponAttachmentControl extends AbstractControl {
|
|||||||
// Wird im 2. Frame aus den Runtime-Node-Positionen berechnet (skalierungs-unabhängig).
|
// Wird im 2. Frame aus den Runtime-Node-Positionen berechnet (skalierungs-unabhängig).
|
||||||
private Vector3f palmOffsetLocal;
|
private Vector3f palmOffsetLocal;
|
||||||
|
|
||||||
|
|
||||||
private Item lastEquippedWeapon;
|
private Item lastEquippedWeapon;
|
||||||
private boolean lastDrawnState = false;
|
private boolean lastDrawnState = false;
|
||||||
private Spatial weaponSpatial;
|
private Spatial weaponSpatial;
|
||||||
@@ -368,20 +369,19 @@ public class WeaponAttachmentControl extends AbstractControl {
|
|||||||
DEG_TO_RAD * grip.getRotY(),
|
DEG_TO_RAD * grip.getRotY(),
|
||||||
DEG_TO_RAD * grip.getRotZ())
|
DEG_TO_RAD * grip.getRotZ())
|
||||||
: new Quaternion();
|
: new Quaternion();
|
||||||
// Klinge bei -Z erkannt (grip2PosZ > posZ) → 180° um X vorschalten, damit BACK_ROT_NORM
|
|
||||||
// dieselbe Wirkung hat wie bei korrekt ausgerichtetem Modell (Klinge bei +Z).
|
|
||||||
boolean bladeAtMinusZ = grip != null && grip.getGrip2PosZ() != 0f && grip.getGrip2PosZ() > grip.getPosZ();
|
boolean bladeAtMinusZ = grip != null && grip.getGrip2PosZ() != 0f && grip.getGrip2PosZ() > grip.getPosZ();
|
||||||
Quaternion bladeFlip = bladeAtMinusZ
|
Quaternion bladeFlip = bladeAtMinusZ
|
||||||
? new Quaternion().fromAngles(com.jme3.math.FastMath.PI, 0f, 0f)
|
? new Quaternion().fromAngles(com.jme3.math.FastMath.PI, 0f, 0f)
|
||||||
: new Quaternion();
|
: new Quaternion();
|
||||||
|
|
||||||
Quaternion weaponRot = boneRotInChar.mult(BACK_ROT_NORM).mult(bladeFlip).mult(gripRot.inverse());
|
Quaternion weaponRot = boneRotInChar.mult(BACK_ROT_NORM).mult(bladeFlip).mult(gripRot.inverse());
|
||||||
Vector3f gripTarget = bonePosInChar.add(boneRotInChar.mult(
|
Vector3f offset = twoHanded ? TWO_HAND_BACK_GRIP_OFFSET : BACK_GRIP_OFFSET;
|
||||||
twoHanded ? TWO_HAND_BACK_GRIP_OFFSET : BACK_GRIP_OFFSET));
|
Vector3f gripTarget = bonePosInChar.add(boneRotInChar.mult(offset));
|
||||||
|
// X=0: Waffenmitte (nicht handspezifischer Griffpunkt) auf Wirbelsäule zentrieren
|
||||||
Vector3f gripPos = (grip != null)
|
Vector3f gripPos = (grip != null)
|
||||||
? new Vector3f(grip.getPosX(), grip.getPosY(), grip.getPosZ())
|
? new Vector3f(0f, grip.getPosY(), grip.getPosZ())
|
||||||
: Vector3f.ZERO;
|
: Vector3f.ZERO;
|
||||||
Vector3f backPos = gripTarget.subtract(weaponRot.mult(gripPos));
|
Vector3f backPos = gripTarget.subtract(weaponRot.mult(gripPos));
|
||||||
if (bladeAtMinusZ) backPos = backPos.add(0.1f, 0f, 0f);
|
|
||||||
weaponSpatial.setLocalRotation(weaponRot);
|
weaponSpatial.setLocalRotation(weaponRot);
|
||||||
weaponSpatial.setLocalTranslation(backPos);
|
weaponSpatial.setLocalTranslation(backPos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user