Jump to content
  • Advertisement
yaboiryan

Gun Keeps Moving Away from Camera in OpenGL program

Recommended Posts

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

 

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)
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)

Edited by yaboiryan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!