Ryan-rsm-McKenzie / CommonLibF4

A reverse-engineered resource for Fallout 4
MIT License
70 stars 37 forks source link

[Question] Head world position #6

Closed dlinny-lag closed 2 years ago

dlinny-lag commented 2 years ago

I'm writing UI plugin and trying to display UI widget near to actor's head position. I've tried to use TESObjectREFR::Get3D() and TESObjectREFR::GetFaceNodeSkinned. Both returns NiAVObject that points to "feets" of actor's model when actor is staying, but points to the center (approximately) of model when actor is lying down.

Do you have any idea how to obtain actor's head world position?

Ryan-rsm-McKenzie commented 2 years ago

I would look at Actor::GetEyeVector

dlinny-lag commented 2 years ago

Thanks. But it seems usless for my purposes An example of coordinates:

staying

world pos {-35234.382813, 41025.136719, 3220.069824}
eye pos   {-35234.382813, 41025.136719, 3324.390869}

Z diff is about 124

lying down

world pos {-35461.015625, 40947.492188, 3219.156006}
eye pos   {-35461.015625, 40947.492188, 3323.477051}

Z diff is about 124 too

dlinny-lag commented 2 years ago

ok, I guess I've found solution

  1. Get NiAVObject by TESObjectREFR::Get3D. It should be NiNode actually
  2. Recursively find NiAVObject for Head in it. In my case it was _[/Root/COMOverride/COM/SPINE1/SPINE2/Chest/Neck/Head]

An example coordinates: staying actor:

                                             world pos {-34596.410156, 40947.843750, 3213.797119}
                                               eye pos {-34596.410156, 40947.843750, 3324.402100}
[/Root/COM_Override/COM/SPINE1/SPINE2/Chest/Neck/Head]:{-34596.074219, 40958.359375, 3324.402100}

laying down actor:

                                             world pos {-35461.015625, 40947.492188, 3219.156006}
                                               eye pos {-35461.015625, 40947.492188, 3329.760986}
[/Root/COM_Override/COM/SPINE1/SPINE2/Chest/Neck/Head]:{-35486.519531, 40915.753906, 3260.565430}