EOS 2  1.1.0
Einfache Objektbasierte Sprache
GLBaseRenderObject.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.robot.gui;
2 
3 import java.awt.Color;
4 
5 import com.jogamp.opengl.GL;
6 import com.jogamp.opengl.GL2;
7 
8 import de.lathanda.eos.robot.geom3d.Face;
9 import de.lathanda.eos.robot.geom3d.Polyhedron;
10 
11 public class GLBaseRenderObject implements GLRenderObject {
12  private final Polyhedron data;
14  this.data = data;
15  }
16  public void render(GL2 gl, Color base) {
17  data.faces.stream().forEach(f -> renderFace(f, base, gl));
18  }
19  protected void renderFace(Face f, Color base, GL2 gl) {
20  GLTextureBuffer texture = GLTextureBuffer.get(f.m, gl);
21  texture.openMaterial(base, gl);
22  gl.glBegin(GL.GL_TRIANGLES);
23  for (int i = 0; i < f.v.length; i++) {
24  if (f.vn != null) {
25  gl.glNormal3f(f.vn[i].dx, f.vn[i].dy, f.vn[i].dz);
26  }
27  if (f.vt != null) {
28  gl.glTexCoord2f(f.vt[i].u, 1 - f.vt[i].v); // I have no idea why
29  // jogamp is
30  // inverted
31  }
32  gl.glVertex3f(f.v[i].x, f.v[i].y, f.v[i].z);
33 
34  }
35  gl.glEnd();
36  texture.closeMaterial(gl);
37  }
38  @Override
39  public void destroy(GL gl) {
40  // free data?
41  }
42 }
final VerticeTexture[] vt
Definition: Face.java:11
final VerticeNormal[] vn
Definition: Face.java:12
final LinkedList< Face > faces
Definition: Polyhedron.java:12
void renderFace(Face f, Color base, GL2 gl)
static synchronized GLTextureBuffer get(Material m, GL gl)
Impressum