Using saito obj loader, I made an object called 'shuttle'.
Code:import processing.opengl.*;
import javax.media.opengl.*;
OBJModel model;
class Shuttle
{
Shuttle(PApplet app, String name)
{
model = new OBJModel(app, name);
}
void drawShuttle(GL gl)
{
pushMatrix();
translate(2016, 2016, 1200);
scale(50);
model.drawMode(POLYGON);
model.draw();
popMatrix();
}
}
In the main draw function:
Code: GL gl = pgl.beginGL();
cameraControl(gl);
shuttle.drawShuttle(gl);
pgl.endGL();
Using the
camera() function I move the camera around.
Code: if (keyPressed)
{
if ( key == 'w' )
camY -= cameraSpeed;
if ( key == 's' )
camY += cameraSpeed;
if ( key == 'a' )
camX -= cameraSpeed;
if ( key == 'd' )
camX += cameraSpeed;
if ( key == 'q' )
camZ -= cameraSpeed*2.5;
if ( key == 'e' )
camZ += cameraSpeed*2.5;
}
The problem is that when I move the camera around, the object moves in the opposite direction of the camera. I have also drawn a
box() which doesn't move. And if I zoom out far enough the object moves behind the box.
Why?