Reputation: 5616
I have an OpenGL ES object which I am trying to draw. The object has fairly large vertice values with the x and y co-ordinates lying between -30,000 and +30,000. The z values are between 2000 and -2000.
Can anybody advise me how I should be setting up my viewport ? I am using the following code :
public void onSurfaceChanged(GL10 gl, int width, int height) {
//Define the view frustrum
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
float ratio = (float)width/height;
GLU.gluPerspective(gl, 45.0f, ratio, 1, 100f);
}
public void onDrawFrame (GL10 gl) {
// Clear the screen to black.
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
//Position the model.
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, 0.0f);
//gl.glScalef(0.000015f,0.000015f,0.000015f);
This compiles ok, but I cannot see my object at all.
Thank you.
Upvotes: 2
Views: 1473
Reputation: 35933
You probably can't see it because your camera's inside the object. Maybe try first scaling it by 0.001 to get it down to about 60 units across, translate it by -50 in the z direction (to get it to the middle of your z range), and see if it shows up then.
Alternatively you could just make your z-range a lot bigger, and translate it by some -50,000 units in the z direction to move the object back from the camera. You'll have to adjust znear/zfar then to be much larger.
Upvotes: 1