Skip to content

Instantly share code, notes, and snippets.

@Frooxius
Created June 30, 2018 21:24
Show Gist options
  • Save Frooxius/9526ed12b53e8b04f03b90fd633741b4 to your computer and use it in GitHub Desktop.
Save Frooxius/9526ed12b53e8b04f03b90fd633741b4 to your computer and use it in GitHub Desktop.
Debug Vector
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