GL4Java

I have a method objZoom that I use to pass the values from my gui to the glTranslate in the z position. However, if I set the gui value to 6000 or below the image is upside down. I tried doing an if statement and in there scaling the object but that doesn’t work. Can anyone assist?

//------------------------------------------------------------------------------
// void distance_textfield_actionPerformed(ActionEvent e)
//------------------------------------------------------------------------------
void distance_textfield_actionPerformed(ActionEvent e){

String x = distance_textfield.getText();
try{
view= Float.parseFloat(x);
//System.out.println(viewDistance);
canvas.objZoom(view);
canvas.repaint();
}
catch(NumberFormatException n){
JOptionPane.showMessageDialog(null,x + “is an invalid entry”,“Error Occurred”, JOptionPane.ERROR_MESSAGE);
}
}

//------------------------------------------------------------------------------
// void objZoom
//------------------------------------------------------------------------------
public void objZoom(float viewDistance){
if(viewDistance < 6000){
gl.glScalef(0.0f,1.0f,0.0f);
pos_z = -viewDistance;
}
else
pos_z = -viewDistance;
//gl.glTranslatef(pos_x,pos_y,pos_z);
}

That code shouldn’t work at all. You’ve got zero scales on two axes which would be handy for rendering one-dimensional objects but not much else.

Cas :slight_smile: