Apply camera position and rotation to an object(as an fps hand or gun etc)

Hi,i’m having an hard time to apply my camera rotation to a simple object,i really don’t understand what’s going wrong this is my code for now :

MAT4 model_mat;


  MAT4 cam_inverse;


  VEC3 world_cam_pos;

  world_cam_pos[0] = cam_inverse[3][0];

  world_cam_pos[1] = cam_inverse[3][1];

  world_cam_pos[2] = cam_inverse[3][2];



with this i can put an object in front of the camera view,but it gets no rotation…so i tried :


and i tried disperatly different combinations,but the maximum that i got was the model rotating in the opposite axis and opposite angle of my view (like i was rotatin and moving up the model would go left) if i go right the model goes down etc…please i need help i have to clue on what’s happening this is becoming a nightmare for me

It is hard for me to tell you what is going on with your implementation. If cannot provide more specifics of your transforms setup I suggest you start debugging on your own by decomposing your transforms step by step, as in performing rotation about a specific axis only. Once you are happy with that, start developing your transform chain by adding a transform at a time: a second rotation, a translation, etc.

Make sure you separate your projection, view and model transforms and work on one of them at a time. Usually projection and view transforms are applied to the whole set of objects you are rendering, the only one that should be updated is the model transform (per rendered model/mesh/etc).


hi thank you for your answer, i just wasted a month rebuildling models on blender,now i have 2 models almost perfect to deal with,i made a pistol and the arms,they have like 6k vertices,the problem is clearly that blender doesn’t provide me of the correlation between 2 different models,so i dont have the 2 models initial location,said that it’s not a problem of vulkan clearly i just spammed there to receive any help and i can build the 2 different locations in some way,still,i will build my own format,(kind of gltf but with my goals to speed up the process,and in this way i will set up the initial matrices),if you have easy solutions at this problem i would glad for your help a lot <3