Hallo!
Ich arbeite z.Z. an einem 3D Universium. Dabei habe ich mich für das normale SI-Einheiten System entschieden - die Distanzen zwischen den Planeten sind also groß. (~ E11 für Erde). Nun werden meine Planeten wenn ich von weitem auf sie zufliege nicht sauber dargestellt, sie sind pixelig,flimmern und flackern. Double-Buffering verwende ich dabei. Vielleicht weiß ja jemand einen Rat. Eventuell liegts auch an falschen zNear, zFar in gluPerspective. Ich verwende JOGL 2.0
Initalisierungsdatei in einer Main-Klasse
in der zentralen Renderingklasse:
Vielleicht weiß ja jemand einen Tipp?
Ein KSKB ist in dem fortgeschrittenem Status des Projektes schwierig zu extrahieren, es sind mittlerweile über 40 Klassen.
Danke, Daniel.S
Ich arbeite z.Z. an einem 3D Universium. Dabei habe ich mich für das normale SI-Einheiten System entschieden - die Distanzen zwischen den Planeten sind also groß. (~ E11 für Erde). Nun werden meine Planeten wenn ich von weitem auf sie zufliege nicht sauber dargestellt, sie sind pixelig,flimmern und flackern. Double-Buffering verwende ich dabei. Vielleicht weiß ja jemand einen Rat. Eventuell liegts auch an falschen zNear, zFar in gluPerspective. Ich verwende JOGL 2.0
Initalisierungsdatei in einer Main-Klasse
Java:
public void init() {
this.capabilities = new GLCapabilities(this.profile);
this.capabilities.setDoubleBuffered(true);
this.canvas = new GLCanvas(this.capabilities);
this.orbit = new OrbitSimulator(this);
this.animator = new FPSAnimator(this.canvas, 25);
this.canvas.addGLEventListener(this.orbit);
this.frame.add(canvas);
this.frame.setSize(1280, 800);
Container con = this.frame.getContentPane();
con.setBackground(Color.gray);
this.frame.setLayout(null);
this.canvas.setBounds(0, 0, 800, 700);
this.canvas.addMouseMotionListener(orbit);
this.canvas.addMouseListener(orbit);
this.canvas.addKeyListener(orbit);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
new Thread(new Runnable() {
public void run() {
animator.stop();
System.exit(0);
}
}).start();
}
});
frame.setVisible(true);
animator.start();
this.initLabels();
this.initProgressBars();
}
in der zentralen Renderingklasse:
Java:
public class OrbitSimulator extends JFrame implements GLEventListener, MouseMotionListener, KeyListener, MouseListener {
/**
*
*/
private static final long serialVersionUID = 1L;
public GLU glu = new GLU();
public GL2 gl;
public ArrayList<AOrbitObject> objects = new ArrayList<AOrbitObject>(); /** Array-list of AOrbitOjects*/
public Daten daten = new Daten();
float[] colorBlack = {0.0f,0.0f,0.0f,1.0f};
float[] colorWhite = {1.0f,1.0f,1.0f,1.0f};
float[] colorGray = {0.6f,0.6f,0.6f,1.0f};
float[] colorRed = {1.0f,0.0f,0.0f,1.0f};
float[] colorBlue = {0.0f,0.0f,0.1f,1.0f};
float[] colorYellow = {1.0f,1.0f,0.0f,1.0f};
float[] colorLightYellow = {.5f,.5f,0.0f,1.0f};
private float lightPos[] = {0.0f, 0.0f, 0.0f, 1.0f};
private int _width;
private int _height;
public boolean reset = false;
public Point lastMousePoint = new Point();
public Point currentMousePoint = new Point();
public KeyHandler keyHandler;
public MouseHandler mouseHandler;
public TextRenderer textRenderer = null;
public Camera camera = new Camera();
public Main b = null;
public Time t = new Time();
public GUIUpdater updater;
OrbitSimulator(Main b) {
this.b = b;
this.keyHandler = new KeyHandler(this);
this.mouseHandler = new MouseHandler(this);
}
public void init(GLAutoDrawable drawable) {
gl = drawable.getGL().getGL2();
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GLLightingFunc.GL_LIGHTING);
gl.glEnable(GLLightingFunc.GL_LIGHT0);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_DIFFUSE, colorWhite, 0);
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_AMBIENT, colorBlack, 0);
textRenderer = new TextRenderer(new Font("SansSerif", Font.BOLD, (int)32),true,true);
this.objects.add(0, new Sun(this));
this.objects.add(1, new Earth(this));
this.objects.add(2, new Viewer(this));
this.objects.get(0).init();
this.objects.get(1).init();
this.objects.get(2).init();
this.objects.get(1).start();
this.objects.get(2).start();
this.keyHandler.init();
this.keyHandler.start();
this.updater = new GUIUpdater(this);
this.updater.start();
}
public void display(GLAutoDrawable drawable) {
if (reset) {
int width = _width;
int height = _height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(60.0, (double) width / (double) height, 0.001 , 100);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
reset = false;
}
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
updateView(gl);
//Sonnenlicht
gl.glPushMatrix();
gl.glTranslatef(0.0f, 0.0f, 0.0f);
gl.glLightf(GL2.GL_LIGHT0, GL2.GL_CONSTANT_ATTENUATION, 0.01f);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, lightPos, 0);
gl.glDisable(GL2.GL_LIGHT0);
gl.glPopMatrix();
this.objects.get(0).render(gl, glu);
this.objects.get(1).render(gl, glu);
t.run();
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
if (height <= 0) {
height = 1;
}
this._height = height;
this._width = width;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0, (double) width / (double) height, 10000 , 5E15);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
Vielleicht weiß ja jemand einen Tipp?
Ein KSKB ist in dem fortgeschrittenem Status des Projektes schwierig zu extrahieren, es sind mittlerweile über 40 Klassen.
Danke, Daniel.S
Zuletzt bearbeitet: