PDA

View Full Version : noob question shifting the scene left or right?



bsabiston
03-16-2013, 02:38 PM
Hello,

Currently in my game, I have a 3D scene which centers in the middle of the screen. That is, my player is in the middle of the screen, and when I rotate the camera, it rotates around the center of the screen.

Because I have UI elements on the right, I want to shift things so that the scene appears to be centered 200 pixels or so to the left. So I want the player over there, and I want camera rotation to happen around that point also. I know that is a simple question but how do I do that? I am feeling very dumb today.

I have experimented, trying to translate my modelViewMatrix leftward, both before and/or after my camera rotation. Doing it afterward does shift the view, but then rotating the camera still happens around the center of the screen, not around the translated point. Do I have to add something in my camera rotation routines to shift the scene back to the center before rotation and then back leftward again afterward?

Thanks for any suggestions
Bob

marek-knows.com
03-16-2013, 05:11 PM
I believe video 8 (http://www.marek-knows.com/downloads.php5?vmk=gameEng8) on my website should explain everything you need.

Nowhere-01
03-17-2013, 03:23 AM
Because I have UI elements on the right, I want to shift things so that the scene appears to be centered 200 pixels or so to the left. So I want the player over there, and I want camera rotation to happen around that point also. I know that is a simple question but how do I do that? I am feeling very dumb today.


if you expect a specific answer - you should provide an example of your current camera math. but anyway, if you use opengl matrix stack and other deprecated functionality - check gluLookAt(...) (http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml) function or if you don't use deprecated stuff - take a look at GLM (http://glm.g-truc.net/) library, glm::lookAt(...) function. these functions allow you to set camera position and the point it looks at. it sounds like what you're looking for.


I believe video 8 (http://www.marek-knows.com/downloads.php5?vmk=gameEng8) on my website should explain everything you need.

i reported you for spamming your site, which requires either premium or registering and accessing tutorials in a very limited way("200MB download credits; Download 1 VMK per 45 minutes; VMKs must be downloaded in order"). if you want to post a link to your site with tutorial - post it without attempting e-begging, and make sure it wasn't a shitty exuse and it really contains answer to the question.