Gun Keeps Moving Away from Camera in OpenGL program

Started by
11 comments, last by yaboiryan 4 years, 11 months ago
19 hours ago, yaboiryan said:

The code is finally here!

 

 

 



glm::mat4 model;
glm::mat4 gun;
glm::mat4 map;
glm::mat4 windowMat;

glm::mat4 view = camera.GetViewMatrix( );

...
              
gun = glm::translate(gun, glm::vec3(camera.GetPosition().x, camera.GetPosition().y, camera.GetPosition().z));

//my attempt to make the gun work is with this line of code. I made the gun use the camera's view matrix because I thought it would work...
gun = (gun * glm::inverse(view));



//I also have this as another way (I thought) I could get it to work

gun = glm::lookAt(glm::vec3(camera.GetPosition().x, camera.GetPosition().y, camera.GetPosition().z), glm::vec3
			(camera.GetPosition().x, camera.GetPosition().y, camera.GetPosition().z) + camera.GetFront(), camera.getUp());


//this is how I draw the gun
gunModel.Draw(shader);

I kept trying, but it seemed that almost none of the code would work...

If needed, I can give you my model view shader.

Nice.. continue in dev

Dont forget to record a new videos for us follow :D

 

Advertisement
On 4/29/2019 at 3:57 PM, WhiskyAndCode said:

Nice.. continue in dev

Dont forget to record a new videos for us follow :D

 

Do you see any issues with the gun code?

 

(thanks by the way)

This topic is closed to new replies.

Advertisement