Implement source-backed Scooter vehicle in tutorial and outside
This commit is contained in:
1 parent
8df5e81070
commit
62c07a3d59
44 files changed
+3135
-174
No files matched your search
@@ -0,0 +1,25 @@
|
||||
using System.Numerics;
|
||||
namespace GamePort.Game;
|
||||
public readonly record struct ScooterCameraResult(Vector3 Eye,Vector3 Target,Vector3 DesiredEye,Vector3 Look,float Gain);
|
||||
/// <summary>4130A0 default mode1. Clipping follows smoothing and uses a sphere,
|
||||
/// then look minus NEW eye determines source signed14-bit aim.</summary>
|
||||
public static class ScooterCamera
|
||||
{
|
||||
public static ScooterCameraResult Follow(Vector3 root,Vector3 rotation,Vector3 oldEye,float dt,Func<Vector3,Vector3,Vector3>? clip=null,bool impact=false)
|
||||
{
|
||||
var desired=root+RocketOrientation.Rotate(new(-30,0,-200),rotation)+Vector3.UnitY*50;
|
||||
var delta=desired-oldEye;var distance=OriginalBodySupport.QuickMagnitude(delta);
|
||||
float gain=distance>400?2.8f:distance>200?1.7f:1;
|
||||
var eye=oldEye+delta*dt*gain;
|
||||
if(impact)
|
||||
{
|
||||
//413157..4131C0: approach root X/Z at .3; leave eye Y unchanged.
|
||||
desired=new(root.X,oldEye.Y,root.Z);gain=.3f;eye=oldEye+(desired-oldEye)*dt*gain;
|
||||
}
|
||||
if(clip!=null)eye=clip(root,eye);
|
||||
var look=impact?root:root+RocketOrientation.Rotate(new(0,50,100),rotation);
|
||||
var(p,y)=OriginalHeading.Angles(look-eye);
|
||||
var direction=RocketOrientation.Rotate(Vector3.UnitZ,new(p*.02197265625f,y*.02197265625f,0));
|
||||
return new(eye,eye+direction*200,desired,look,gain);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user