Implement verified Grappler body camera and helpers in VR08
This commit is contained in:
1 parent
ffea678e90
commit
43806fe862
39 files changed
+2429
-40
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
public readonly record struct GrapplerCameraLocals(Vector3 Eye,Vector3 Look,Vector3 Gains)
|
||||
{
|
||||
public static GrapplerCameraLocals Default=>new(new(0,200,-350),new(0,80,0),new(1.6f,1,1.6f));
|
||||
public GrapplerCameraLocals Equip()=>this with{Eye=new(0,50,-350),Look=new(0,150,80)};
|
||||
public GrapplerCameraLocals Attach()=>this with{Eye=new(Eye.X,400,-650),Gains=new(.8f,1,.8f)};
|
||||
public GrapplerCameraLocals Detach()=>new(new(0,50,-350),new(0,130,100),new(1.6f,1,1.6f));
|
||||
}
|
||||
public readonly record struct GrapplerCameraResult(Vector3 Eye,Vector3 Target,Vector3 Look,Vector3 DesiredEye,float RayGain);
|
||||
|
||||
/// <summary>Ordinary438BC0/439900 follow branches. Excludes flags828/851 and
|
||||
/// Bubble mode2; aim is quantized from look minus OLD shared eye.</summary>
|
||||
public static class GrapplerCamera
|
||||
{
|
||||
public static GrapplerCameraResult Follow(GrapplerCameraLocals locals,Vector3 root,Vector3 rotation,
|
||||
float turnRate,int movementMode,Vector3 oldEye,float seconds,Func<Vector3,Vector3,SupportHit?>? ray)
|
||||
{
|
||||
GrapplerMotion.Time(seconds);GrapplerMotion.Finite(root);GrapplerMotion.Finite(rotation);GrapplerMotion.Finite(oldEye);
|
||||
if(movementMode==2)throw new NotSupportedException("Grappler camera excludes Bubble mode2");
|
||||
var eyeLocal=locals.Eye;var lookLocal=locals.Look;var eyeRotation=rotation;Vector3 gains;
|
||||
if(movementMode==0)
|
||||
{eyeLocal.Y-=20;lookLocal.Y=(float)(lookLocal.Y+1.9*10);gains=locals.Gains+new Vector3(0,.2f,0);}
|
||||
else {eyeRotation=new(0,RocketOrientation.AddAxis(rotation.Y,turnRate),rotation.Z);gains=new(1.2f,2,1.2f);}
|
||||
var desired=root+RocketOrientation.Rotate(eyeLocal,eyeRotation);
|
||||
var look=root+RocketOrientation.Rotate(lookLocal,rotation);float gain=1;
|
||||
if(ray?.Invoke(look,desired) is{} hit){desired=look-(look-hit.Position)*.75f;gain=1.5f;}
|
||||
var eye=oldEye+(desired-oldEye)*gains*(gain*seconds);
|
||||
var(pitch,yaw)=OriginalHeading.Angles(look-oldEye);
|
||||
var direction=RocketOrientation.Rotate(Vector3.UnitZ,new(pitch*.02197265625f,yaw*.02197265625f,0));
|
||||
return new(eye,eye+direction*200,look,desired,gain);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user