edit shader
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -9,6 +10,28 @@ public class InputHandler : MonoBehaviour, IGameComponent
|
||||
private Controls inputSystem;
|
||||
private Transform cameraTransform;
|
||||
|
||||
private float X0;
|
||||
private float P0;
|
||||
private readonly float F = 1;
|
||||
private readonly float Q = 2;
|
||||
private readonly float H = 1;
|
||||
private readonly float R = 15;
|
||||
|
||||
private float Covariance = .1f;
|
||||
private float state = 0;
|
||||
|
||||
float GetValueAfterFilter(float value)
|
||||
{
|
||||
X0 = F * state;
|
||||
P0 = F * Covariance * F + Q;
|
||||
|
||||
var K = H *P0 / (H * P0 * H + R);
|
||||
state = X0 + K * (value - H * X0);
|
||||
Covariance = (1 - K * H) * P0;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
inputSystem = new Controls();
|
||||
@@ -39,7 +62,23 @@ public class InputHandler : MonoBehaviour, IGameComponent
|
||||
.Gyroscope
|
||||
.ReadValue<Quaternion>();
|
||||
|
||||
cameraTransform.rotation = phoneRotation;
|
||||
// phoneRotation = new Quaternion
|
||||
// (
|
||||
// GetValueAfterFilter(phoneRotation.x),
|
||||
// GetValueAfterFilter(phoneRotation.y),
|
||||
// GetValueAfterFilter(phoneRotation.z),
|
||||
// GetValueAfterFilter(phoneRotation.w)
|
||||
// );
|
||||
|
||||
Quaternion filtredRotation = new Quaternion
|
||||
(
|
||||
GetValueAfterFilter(phoneRotation.x),
|
||||
GetValueAfterFilter(phoneRotation.y),
|
||||
GetValueAfterFilter(phoneRotation.z),
|
||||
GetValueAfterFilter(phoneRotation.w)
|
||||
);
|
||||
|
||||
cameraTransform.rotation = filtredRotation;
|
||||
cameraTransform.Rotate(0, 0, 180, Space.Self);
|
||||
cameraTransform.Rotate(90, 180, 0, Space.World);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user