working, fixing texture mapping

This commit is contained in:
GoaLitiuM
2021-08-15 12:30:28 +03:00
parent b3f51ab1e9
commit 4714b888a8
13 changed files with 998 additions and 261 deletions

View File

@@ -9,13 +9,12 @@ namespace Game
[Limit(0, 9000), Tooltip("Camera speed")]
public float MoveSpeed { get; set; } = 400;
private float _pitch;
private float _yaw;
private float viewPitch;
private float viewYaw;
private float viewRoll;
private float xAxis;
private float yAxis;
private float inputH;
private float inputV;
private InputEvent onExit = new InputEvent("Exit");
@@ -40,33 +39,45 @@ namespace Game
public override void OnStart()
{
var initialEulerAngles = Actor.Orientation.EulerAngles;
_pitch = initialEulerAngles.X;
_yaw = initialEulerAngles.Y;
viewPitch = initialEulerAngles.X;
viewYaw = initialEulerAngles.Y;
viewRoll = initialEulerAngles.Z;
}
public override void OnUpdate()
{
var camTrans = Actor.Transform;
var rootActor = Actor.GetChild(0);
var camera = rootActor.GetChild<Camera>();
xAxis = InputManager.GetAxis("Mouse X");
yAxis = InputManager.GetAxis("Mouse Y");
float xAxis = InputManager.GetAxisRaw("Mouse X");
float yAxis = InputManager.GetAxisRaw("Mouse Y");
if (xAxis != 0.0f || yAxis != 0.0f)
{
_pitch += yAxis;
_yaw += xAxis;
camTrans.Orientation = Quaternion.Euler(_pitch, _yaw, 0);
viewPitch += yAxis;
viewYaw += xAxis;
viewPitch = Mathf.Clamp(viewPitch, -90.0f, 90.0f);
// root orientation must be set first
rootActor.Orientation = Quaternion.Euler(0, viewYaw, 0);
camera.Orientation = Quaternion.Euler(viewPitch, viewYaw, viewRoll);
}
inputH = InputManager.GetAxis("Horizontal");
inputV = InputManager.GetAxis("Vertical");
float inputH = InputManager.GetAxis("Horizontal");
float inputV = InputManager.GetAxis("Vertical");
var move = new Vector3(inputH, 0.0f, inputV);
if (!move.IsZero)
{
move.Normalize();
move = camTrans.TransformDirection(move) * MoveSpeed;
move = camera.Transform.TransformDirection(move) * MoveSpeed;
{
Vector3 delta = move * Time.UnscaledDeltaTime;