Currently I'm working on a 3D project. This project consists of having sphere attracted to boxes in the x,y and z dimensions. Till now I've managed to create the spheres and boxes and the relevant force. Now I need to create the 3D dimension which must be accessed with the mouse or keyboard. e.g if the up arrow button is pressed you can zoom in or rotate left.
I know that Peasy cam can do the trick quite easily but for this project I'm not allowed to used Peasy cam. I must create my own camera fuctions. I'm supplying the code I'm working on so you can get an idea of what I'm after.
Thanks all
import processing.opengl.*;
int width,height; float xCube, yCube, zCube; // x,y and z coordiante of Cube float xSph, ySph, zSph; // x,y and z coordinate of sphere float dX,dY,dZ; // Variables for sphere velocity
Cube c; Sphere s;
void setup() { width=height=800; size(width,height,OPENGL); c = new Cube(); s = new Sphere(); xCube=yCube=zCube=0; // Initial variables for cube ySph=zSph=0; // Initial y and z coordinates for sphere xSph =40; // Initial x coordinates for sphere dY=4; // Inital velocity of sphere }
void draw() { background(150); translate(width/2,height/2); //Translate coordinate to centre of sketch c.drawCube(xCube,yCube,zCube); // Draw Cube s.drawSphere(xSph,ySph,zSph); // Draw Sphere force(); movement(); }