I’d like to know if there is a way to rotate a 3D camera atound it’s own axis. I want to create a 3D game like Minecraft and for that I of course need to make the camera be rotatable I tried following code (unnecessary code excluded):
camera(0, 0, 300, x, 0, 0, 0, 1, 0);
if(mouseX < 0)
else if(mouseX > 0)
translate(0, 0, 0);
translate(400, 0, 0);
translate(400, 0, 400);
But it only goes like a quarter of a circle and then stops. So, can I rotate the camera around it’s own axis?
This is a great thing to want to do, and I first have a word of caution before you go down this path – 3D camera rotation is hard. How hard can it be? Surprisingly hard.
Instead, I would recommend using an existing library, like installing QuesyCam (“a super-simple FPS camera library for Processing”) through the PDE Contributions Manager. In particular, check out the MazeRunner demo, which shows you how to set up an FPS camera in a MineCraft-like block environment.
If you want to make that a third-person camera then you will have to do a bit more work, but once you learn how to use the library you are now 75% of the way there, instead of 5% of the way there.
I should also mention that you don’t use rotateX(), rotateY(), or rotateZ() in your example code – you only use translate(), which is for sliding things, not turning them. If you haven’t done so already, review the 2D tutorial and then read up on the 3D tutorial examples: