NexusVR - Connecting the Metaverse

This flow almost exactly matches WidgetComponent.cpp line 1107 (UWidgetComponent::GetLocalHitLocation(…)) in the UE 4.11.2 source code:

[FONT=Courier New]
void UWidgetComponent::GetLocalHitLocation(FVector WorldHitLocation, FVector2D& OutLocalWidgetHitLocation) const
{
// Find the hit location on the component
FVector ComponentHitLocation = ComponentToWorld.InverseTransformPosition(WorldHitLocation);

// Convert the 3D position of component space, into the 2D equivalent
if ( bUseLegacyRotation )
{
	OutLocalWidgetHitLocation = FVector2D(ComponentHitLocation.X, ComponentHitLocation.Y);
}
else
{
	OutLocalWidgetHitLocation = FVector2D(-ComponentHitLocation.Y, -ComponentHitLocation.Z);
}

// Offset the position by the pivot to get the position in widget space.
OutLocalWidgetHitLocation.X += DrawSize.X * Pivot.X;
OutLocalWidgetHitLocation.Y += DrawSize.Y * Pivot.Y;

// Apply the parabola distortion
FVector2D NormalizedLocation = OutLocalWidgetHitLocation / DrawSize;
NormalizedLocation.Y += ParabolaDistortion * ( -2.0f * NormalizedLocation.Y + 1.0f ) * NormalizedLocation.X * ( NormalizedLocation.X - 1.0f );

OutLocalWidgetHitLocation.Y = DrawSize.Y * NormalizedLocation.Y;

}

So you’re on the right track :wink:

I’m working on a tiny plugin that you can just pop into UE4 editor and expose this stuff to BluePrints… because… well yeah

For anyone wondering what the “ParabolaDistortion” is - it’s in the same file:

[FONT=Courier New]
/**
* When enabled, distorts the UI along a parabola shape giving the UI the appearance
* that it’s on a curved surface in front of the users face. This only works for UI
* rendered to a render target.
*/
UPROPERTY(EditAnywhere, Category=Rendering)
float ParabolaDistortion;

I took a different route to 3D VR gaze input: I implemented basic gaze-to-actor-with-widget-component and widget-cursor-display in Blueprint, then made a GazeInput plugin using code adapted from SlateApplication’s input processing code. This way the gaze input works with all widgets as-is without the need to add new detection geometry or create new widget types.

I hope to clean it up and release the plugin and instructions in future, unless Epic beats me and releases similar functionality themselves.
[/QUOTE]

This all sounds very interesting; I’m looking to get some similar functionality going for a project, before I start off implementing all that though; do you have any more concrete plans by now as to if and/or when you think you’ll be making this available?

@dodgin
nice man, if nothing else its validating to see i wasnt heading down the wrong path, the current issue is definitely detecting hits, please PLEASE get in touch when that plugin is done, it’d prove super handy :slight_smile: