Created
June 30, 2018 21:24
-
-
Save Frooxius/9526ed12b53e8b04f03b90fd633741b4 to your computer and use it in GitHub Desktop.
Debug Vector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using BaseX; | |
namespace FrooxEngine | |
{ | |
[Category("Debug")] | |
public class DebugVector : Component | |
{ | |
public readonly Sync<float3> PositionOffset; | |
public readonly Sync<floatQ> RotationOffset; | |
public readonly Sync<color> Color; | |
public readonly Sync<bool> UseGlobalSpace; | |
protected override void OnAwake() | |
{ | |
RotationOffset.Value = floatQ.Identity; | |
Color.Value = color.Magenta; | |
} | |
protected override void OnCommonUpdate() | |
{ | |
float3 point = PositionOffset; | |
floatQ rotation = RotationOffset; | |
if(UseGlobalSpace) | |
{ | |
// transform to local first (this is for debugging purposes) | |
point = Slot.GlobalPointToLocal(Slot.GlobalPosition + PositionOffset); | |
rotation = Slot.GlobalRotationToLocal(RotationOffset); | |
} | |
point = Slot.LocalPointToGlobal(point); | |
rotation = Slot.LocalRotationToGlobal(rotation); | |
Debug.Vector(point, rotation * float3.Forward, Color); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment