Dear Community & Friends at Epic,
Because I working on an editor mode I cant use the UCanvas projection function, and the FCanvas versions for getting a matrix are currently not exposed to Rocket Users.
So I need to get a plane and do the projection myself.
but I do not understand the math involved
#The Plane
I have a UE4 plane:
UPROPERTY()
FPlane ClickPlane;
#The Point
I have a 3D point to project onto this plane (the plane of the editor’s canvas)
FVector Point (Actor's location for example)
How do I use one of these two functions to project the 3d point onto the click plane?
The Functions
Vector.h
/**
* Calculate a the projection of a point on the plane defined by CCW points A,B,C
*
* @param Point - the point to project onto the plane
* @param A,B,C - three points in CCW order defining the plane
*
* @return Projection of Point onto plane ABC
*/
static FVector PointPlaneProject(const FVector& Point, const FVector& A, const FVector& B, const FVector& C);
/**
* Calculate a the projection of a point on the plane defined by PlaneBase, and PlaneNormal
*
* @param Point - the point to project onto the plane
* @param PlaneBase - point on the plane
* @param PlaneNorm - normal of the plane
*
* @return Projection of Point onto plane ABC
*/
static FVector PointPlaneProject(const FVector& Point, const FVector& PlaneBase, const FVector& PlaneNorm);
#What is a Plane’s Base Point and Normal?
I dont understand how to calculate the base point and normal of a plane
For your Reference:
Plane.h
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* FPlane.
* Stores the coeffecients as Ax+By+Cz=D.
* Note that this is different than many other Plane classes that use Ax+By+Cz+D=0.
*/
MS_ALIGN(16) class FPlane : public FVector
{
public:
// Variables.
float W;
/** Constructor.*/
FORCEINLINE FPlane();
/**
* Copy Constructor.
*
* @param P Plane to copy from.
*/
FORCEINLINE FPlane( const FPlane& P );
/**
* Constructor.
*
* @param V 4D vector to set up plane.
*/
FORCEINLINE FPlane( const FVector4& V );
/**
* Constructor.
*
* @param InX X Coordinate.
* @param InY Y Coordinate.
* @param InZ Z Coordinate.
* @param InW W Coordinate.
*/
FORCEINLINE FPlane( float InX, float InY, float InZ, float InW );
/**
* Constructor.
*
* @param InNormal Plane Normal Vector.
* @param InW Plane W Coordinate.
*/
FORCEINLINE FPlane( FVector InNormal, float InW );
/**
* Constructor.
*
* @param InBase Base point in plane.
* @param InNormal Plane Normal Vector.
*/
FORCEINLINE FPlane( FVector InBase, const FVector &InNormal );
/**
* Constructor.
*
* @param A First point in the plane.
* @param B Second point in the plane.
* @param C Third point in the plane.
*/
FPlane( FVector A, FVector B, FVector C );
/**
* Constructor
*
* @param EForceInit Force Init Enum.
*/
explicit FORCEINLINE FPlane(EForceInit);
// Functions.
/**
* Calculates distance between plane and a point.
*
* @param P The other point.
*
* @return >0: point is in front of the plane, <0: behind, =0: on the plane */
FORCEINLINE float PlaneDot( const FVector &P ) const;