No announcement yet.

Help with normals and vector math

  • Filter
  • Time
  • Show
Clear All
new posts

    Help with normals and vector math


    I am trying to move some specific vertices of a mesh in the direction of a vertex normal from another mesh.
    Basically, i'm trying to offset a mesh from another mesh. Think of a glove that i'm trying to offset from the hand inside it. (i'm not doing this at runtime)
    I want to incrementally offset the glove from the hand by multiplying it by the surface normal of the closest vertex on the hand.
    I already have the closest vertices mapped, so that is not the problem. I cant figure out how to calculate the correct direction of the normal so it doesnt always move in the positive axis.
    Here is a simplified version my existing code, it will help explain better.

    FSoftSkinVertex Closest = SourceMeshVerts[closestTargetVerts[0]]; // just use first closest for now instead of average
    FVector4 TangentZ = Closest.TangentZ;
    FVector TanY = Closest.TangentY;
    FVector TanX = Closest.TangentX;
    float offsetMultiplier = 1.1f;
    FVector MoveMe = FVector(0,0,0);
    //now i want to move this "Move" vector in the direction of the surface normal from "Closest"
    //currently im just multplying it by TangentZ, but that moves it in the positive direction always.
    MoveMe = MoveMe* TangentZ * offsetMultiplier;
    My math is rusty, how can i calculate the correct direction of the normal? Currently it always just moves to the positive axis.

    Any help is appreciated!
    TressFX For Unreal | Morph Tools Plugin