public void Translate(Core.Vector3 translation, SpaceType relativeTo = SpaceType.Local) { switch (relativeTo) { case SpaceType.Local: { localPosition += translation; } break; case SpaceType.World: { if (parent != null) { localPosition = (parent.localRotation.conjugate * (localPosition + translation - parent.localPosition)) / parent.localScale; } else { localPosition += translation; } } break; } isDirty = true; }
public override void Update() { if (isDirty) { if (parent != null) { position = parent.localPosition + parent.localRotation * (localPosition * parent.localScale); rotation = parent.localRotation * localRotation; scale = parent.localScale * localScale; localEulerAngles = Core.Quaternion.EulerAngles(localRotation); eulerAngles = Core.Quaternion.EulerAngles(rotation); } else { position = localPosition; rotation = localRotation; scale = localScale; localEulerAngles = Core.Quaternion.EulerAngles(localRotation); eulerAngles = localEulerAngles; } isDirty = false; } }
public void Rotate(Core.Vector3 eulerAngles, SpaceType relativeTo = SpaceType.Local) { switch (relativeTo) { case SpaceType.Local: { localRotation *= Core.Quaternion.EulerAngles(eulerAngles); } break; case SpaceType.World: { if (parent != null) { Core.Quaternion scaleAdjust = new Core.Quaternion(parent.localScale.Y * parent.localScale.Z, parent.localScale.X * parent.localScale.Z, parent.localScale.X * parent.localScale.Y, 0f); localRotation *= (parent.localRotation.conjugate * Core.Quaternion.EulerAngles(eulerAngles)) * scaleAdjust; } else { localRotation *= Core.Quaternion.EulerAngles(eulerAngles); } } break; } isDirty = true; }
void SetGlobalPosition(Core.Vector3 value) { if (parent != null) { localPosition = (parent.localRotation.conjugate * (value - parent.localPosition)) / parent.localScale; } else { localPosition = value; } isDirty = true; }
private void RenderProgressive() { Frames = 0; FrameBuffer = new Core.Vector3[RT.Width, RT.Height]; RT.Samples = 1; for (int i = 0; i < Samples; i++) { RT.Render(); Frames++; Color[] Data = new Color[RT.Width * RT.Height]; for (int x = 0; x < RT.Width; x++) { for (int y = 0; y < RT.Height; y++) { //Accumulate buffer FrameBuffer[x, y] += RT.Framebuffer[x, y]; //Tone mapping Core.Vector3 CurrentColor = FrameBuffer[x, y] / Frames; Core.Vector3 Mapped = CurrentColor / (CurrentColor + Core.Vector3.One); Mapped = new Core.Vector3(Math.Pow(Mapped.X, 1.0 / 2.2), Math.Pow(Mapped.Y, 1.0 / 2.2), Math.Pow(Mapped.Z, 1.0 / 2.2)); //Draw Data[RT.Width * y + x] = new Color((int)(Mapped.X * 255), (int)(Mapped.Y * 255), (int)(Mapped.Z * 255)); } } RenderTarget.SetData(Data); } Window.AllowUserResizing = true; }
private void RenderStandard() { RT.Samples = Samples; RT.Render(); Color[] Data = new Color[RT.Width * RT.Height]; for (int x = 0; x < RT.Width; x++) { for (int y = 0; y < RT.Height; y++) { //Tone mapping Core.Vector3 CurrentColor = RT.Framebuffer[x, y]; Core.Vector3 Mapped = CurrentColor / (CurrentColor + Core.Vector3.One); Mapped = new Core.Vector3(Math.Pow(Mapped.X, 1.0 / 2.2), Math.Pow(Mapped.Y, 1.0 / 2.2), Math.Pow(Mapped.Z, 1.0 / 2.2)); //Draw Data[RT.Width * y + x] = new Color((int)(Mapped.X * 255), (int)(Mapped.Y * 255), (int)(Mapped.Z * 255)); } } RenderTarget.SetData(Data); Window.AllowUserResizing = true; }
/// <summary> /// Converts a Fox Engine Vector3 to a Unity Vector3. /// </summary> /// <param name="foxVector">The Fox Engine vector.</param> /// <returns>The Unity vector.</returns> public static Vector3 FoxToUnity(Core.Vector3 foxVector) { return(new Vector3(-foxVector.X, foxVector.Y, foxVector.Z)); }