Jump to content
  • Advertisement
Sign in to follow this  
Monkan

camera in the middle

This topic is 2719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I'm a bit lost.

I have a maze and I want to get my camera to be in the centre, i.e. the centre of the maze is in the centre of my screen but its not really working.

For the maze I have its width and height in array size and I have the cell size so I multiply them together to get my real dimensions.

At the moment I have this which does not work and I have tried other variations but cant get it right. Please help.


cameraPosition = Vector3f(windowWidth * 0.5f - ((currentMaze->GetWidth() * currentMaze->GetCellSize()) * 0.5f),
windowHeight * 0.5f - ((currentMaze->GetHeight() * currentMaze->GetCellSize()) * 0.5f), 1500);



Thanks

Share this post


Link to post
Share on other sites
Advertisement
Your equation places the camera at one of the corners of the maze. If the maze is in the center of the screen, and you want the camera in the center of the maze: cameraPosition = (windowWidth*0.5f, windowHeight*0.5f,1500). (I'm not sure what 1500 is for)

Share this post


Link to post
Share on other sites
Thanks for the reply.

I actually ended up with this:


cameraPosition = Vector3f((currentMaze->GetWidth() * currentMaze->GetCellSize()) >> 1,
(currentMaze->GetHeight() * currentMaze->GetCellSize()) >> 1, cameraZ);

As the camera is initially at 0, 0 which is the bottom left of the maze.

the 1500 was the camera z.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!