0

I use OpenGL's mouse display to rotate the 3D model, after that I want to make the updates to my wavefront(.obj) file so that the next time it will directly show the view that I want. Is there any idea about how to update the .obj file?

shanegu
  • 3
  • 5
  • You need to be much more specific. First, a mouse alone doesn't rotate anything. Second, you need some kind of projection to project the 3d model to a 2d image. Usually, this is done with a camera (whose parameters you can control with the mouse). Therefore, without knowing what exact procedure you use to display the model on the screen, it is impossible to give you any help. If you have some kind of camera, why not just store the camera parameters to a file instead of modifying the entire model? – Nico Schertler Jan 07 '18 at 19:11

1 Answers1

0

It might be easier to store the current ModelViewProjection matrix, then load that matrix when you restart your program. This would move your object back to the location you want.

Otherwise, you multiply each point of your object by the ModelViewProjection matrix and store it.

vincent
  • 1,370
  • 2
  • 13
  • 29
  • Hi vincent, I've rotated my model, but because I've used Mipmaps as my texture, now my model cannot be rendered correctly, do you know some way to fix this? thanks – shanegu Jan 10 '18 at 18:03
  • Do you have UV coordinates which are independent from the vertices? You might need to pass the UV coordinate associated with the vertex you are processing through to your fragment shader (without multiplying by the mvp matrix). Then use the UV coordinate you passed through in your sampler2D call. Texture mapping should be independent from vertex position. – vincent Jan 11 '18 at 20:28