aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve')
-rwxr-xr-xsrc/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java56
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java210
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java368
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java252
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp148
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java80
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java160
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/HEdge.java190
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java668
-rw-r--r--src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java230
-rw-r--r--src/jogl/classes/jogamp/graph/curve/text/GlyphString.java228
11 files changed, 1295 insertions, 1295 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
index 34b46a8b5..683a72d96 100755
--- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
@@ -43,10 +43,10 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class RegionRendererImpl01 extends RegionRenderer {
- /**Sharpness is equivalent to the value of t value of texture coord
- * on the off-curve vertex. The high value of sharpness will
- * result in high curvature.
- */
+ /**Sharpness is equivalent to the value of t value of texture coord
+ * on the off-curve vertex. The high value of sharpness will
+ * result in high curvature.
+ */
private GLUniformData mgl_sharpness = new GLUniformData("p1y", 0.5f);
GLUniformData mgl_alpha = new GLUniformData("g_alpha", 1.0f);
private GLUniformData mgl_color = new GLUniformData("g_color", 3, FloatBuffer.allocate(3));
@@ -174,35 +174,35 @@ public class RegionRendererImpl01 extends RegionRenderer {
}
}
-
- @Override
+
+ @Override
public void renderOutlineShape(GL2ES2 gl, OutlineShape outlineShape, float[] position, int texSize) {
- if(!isInitialized()){
- throw new GLException("RegionRendererImpl01: not initialized!");
- }
- int hashCode = getHashCode(outlineShape);
- Region region = regions.get(hashCode);
-
- if(null == region) {
- region = createRegion(gl, outlineShape, mgl_sharpness.floatValue());
- regions.put(hashCode, region);
- }
- region.render(pmvMatrix, vp_width, vp_height, texSize);
- }
-
- @Override
+ if(!isInitialized()){
+ throw new GLException("RegionRendererImpl01: not initialized!");
+ }
+ int hashCode = getHashCode(outlineShape);
+ Region region = regions.get(hashCode);
+
+ if(null == region) {
+ region = createRegion(gl, outlineShape, mgl_sharpness.floatValue());
+ regions.put(hashCode, region);
+ }
+ region.render(pmvMatrix, vp_width, vp_height, texSize);
+ }
+
+ @Override
public void renderOutlineShapes(GL2ES2 gl, OutlineShape[] outlineShapes, float[] position, int texSize) {
if(!isInitialized()){
throw new GLException("RegionRendererImpl01: not initialized!");
}
-
- int hashCode = getHashCode(outlineShapes);
- Region region = regions.get(hashCode);
-
- if(null == region) {
+
+ int hashCode = getHashCode(outlineShapes);
+ Region region = regions.get(hashCode);
+
+ if(null == region) {
region = createRegion(gl, outlineShapes, mgl_sharpness.floatValue());
- regions.put(hashCode, region);
- }
+ regions.put(hashCode, region);
+ }
region.render(pmvMatrix, vp_width, vp_height, texSize);
- }
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java
index 69a8e470b..bc94ab180 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java
@@ -44,39 +44,39 @@ import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
public class TextRendererImpl01 extends TextRenderer {
- /**Sharpness is equivalent to the value of t value of texture coord
- * on the off-curve vertex. The high value of sharpness will
- * result in high curvature.
- */
+ /**Sharpness is equivalent to the value of t value of texture coord
+ * on the off-curve vertex. The high value of sharpness will
+ * result in high curvature.
+ */
private GLUniformData mgl_sharpness = new GLUniformData("p1y", 0.5f);
GLUniformData mgl_alpha = new GLUniformData("g_alpha", 1.0f);
private GLUniformData mgl_color = new GLUniformData("g_color", 3, FloatBuffer.allocate(3));
private GLUniformData mgl_strength = new GLUniformData("a_strength", 1.8f);
-
- public TextRendererImpl01(Vertex.Factory<? extends Vertex> factory, int type) {
- super(factory, type);
- }
+
+ public TextRendererImpl01(Vertex.Factory<? extends Vertex> factory, int type) {
+ super(factory, type);
+ }
- @Override
+ @Override
protected boolean initImpl(GL2ES2 gl){
- boolean VBOsupported = gl.isFunctionAvailable("glGenBuffers") &&
- gl.isFunctionAvailable("glBindBuffer") &&
- gl.isFunctionAvailable("glBufferData") &&
- gl.isFunctionAvailable("glDrawElements") &&
- gl.isFunctionAvailable("glVertexAttribPointer") &&
- gl.isFunctionAvailable("glDeleteBuffers");
-
- if(DEBUG) {
- System.err.println("TextRendererImpl01: VBO Supported = " + VBOsupported);
- }
-
- if(!VBOsupported){
- return false;
- }
-
- gl.glEnable(GL2ES2.GL_BLEND);
- gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA);
-
+ boolean VBOsupported = gl.isFunctionAvailable("glGenBuffers") &&
+ gl.isFunctionAvailable("glBindBuffer") &&
+ gl.isFunctionAvailable("glBufferData") &&
+ gl.isFunctionAvailable("glDrawElements") &&
+ gl.isFunctionAvailable("glVertexAttribPointer") &&
+ gl.isFunctionAvailable("glDeleteBuffers");
+
+ if(DEBUG) {
+ System.err.println("TextRendererImpl01: VBO Supported = " + VBOsupported);
+ }
+
+ if(!VBOsupported){
+ return false;
+ }
+
+ gl.glEnable(GL2ES2.GL_BLEND);
+ gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA);
+
ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, TextRendererImpl01.class,
"shader", "shader/bin", "curverenderer01");
ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, TextRendererImpl01.class,
@@ -95,62 +95,62 @@ public class TextRendererImpl01 extends TextRenderer {
}
st.attachShaderProgram(gl, sp);
-
- st.glUseProgram(gl, true);
+
+ st.glUseProgram(gl, true);
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmvMatrix.glLoadIdentity();
-
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- resetModelview(null);
-
- mgl_PMVMatrix = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
- if(!st.glUniform(gl, mgl_PMVMatrix)) {
- if(DEBUG){
- System.err.println("Error setting PMVMatrix in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_sharpness)) {
- if(DEBUG){
- System.err.println("Error setting sharpness in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_alpha)) {
- if(DEBUG){
- System.err.println("Error setting global alpha in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_color)) {
- if(DEBUG){
- System.err.println("Error setting global color in shader: "+st);
- }
- return false;
- }
-
- if(!st.glUniform(gl, mgl_strength)) {
- System.err.println("Error setting antialias strength in shader: "+st);
- }
-
- if(DEBUG) {
- System.err.println("TextRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
- }
- return true;
- }
-
- @Override
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ resetModelview(null);
+
+ mgl_PMVMatrix = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ if(!st.glUniform(gl, mgl_PMVMatrix)) {
+ if(DEBUG){
+ System.err.println("Error setting PMVMatrix in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_sharpness)) {
+ if(DEBUG){
+ System.err.println("Error setting sharpness in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_alpha)) {
+ if(DEBUG){
+ System.err.println("Error setting global alpha in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_color)) {
+ if(DEBUG){
+ System.err.println("Error setting global color in shader: "+st);
+ }
+ return false;
+ }
+
+ if(!st.glUniform(gl, mgl_strength)) {
+ System.err.println("Error setting antialias strength in shader: "+st);
+ }
+
+ if(DEBUG) {
+ System.err.println("TextRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
+ }
+ return true;
+ }
+
+ @Override
protected void disposeImpl(GL2ES2 gl) {
- super.disposeImpl(gl);
- }
-
+ super.disposeImpl(gl);
+ }
+
@Override
public float getAlpha() {
return mgl_alpha.floatValue();
@@ -163,30 +163,30 @@ public class TextRendererImpl01 extends TextRenderer {
st.glUniform(gl, mgl_alpha);
}
}
-
- @Override
+
+ @Override
public void setColor(GL2ES2 gl, float r, float g, float b){
- FloatBuffer fb = (FloatBuffer) mgl_color.getBuffer();
- fb.put(0, r);
- fb.put(1, r);
- fb.put(2, r);
- if(null != gl && st.inUse()) {
- st.glUniform(gl, mgl_color);
- }
- }
-
- @Override
+ FloatBuffer fb = (FloatBuffer) mgl_color.getBuffer();
+ fb.put(0, r);
+ fb.put(1, r);
+ fb.put(2, r);
+ if(null != gl && st.inUse()) {
+ st.glUniform(gl, mgl_color);
+ }
+ }
+
+ @Override
public void renderString3D(GL2ES2 gl, Font font, String str, float[] position, int fontSize, int texSize) {
- if(!isInitialized()){
- throw new GLException("TextRendererImpl01: not initialized!");
- }
- GlyphString glyphString = getCachedGlyphString(font, str, fontSize);
- if(null == glyphString) {
- glyphString = createString(gl, font, fontSize, str, mgl_sharpness.floatValue());
- addCachedGlyphString(font, str, fontSize, glyphString);
- }
-
- glyphString.renderString3D(pmvMatrix, vp_width, vp_height, texSize);
- }
-
+ if(!isInitialized()){
+ throw new GLException("TextRendererImpl01: not initialized!");
+ }
+ GlyphString glyphString = getCachedGlyphString(font, str, fontSize);
+ if(null == glyphString) {
+ glyphString = createString(gl, font, fontSize, str, mgl_sharpness.floatValue());
+ addCachedGlyphString(font, str, fontSize, glyphString);
+ }
+
+ glyphString.renderString3D(pmvMatrix, vp_width, vp_height, texSize);
+ }
+
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
index 81d9d1858..05814965e 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java
@@ -49,35 +49,35 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class VBORegion2PES2 implements Region {
private int numVertices = 0;
- private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
- private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
- private GLArrayDataServer verticeTxtAttr = null;
- private GLArrayDataServer texCoordTxtAttr = null;
- private GLArrayDataServer indicesTxt = null;
+ private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
+ private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
+ private GLArrayDataServer verticeTxtAttr = null;
+ private GLArrayDataServer texCoordTxtAttr = null;
+ private GLArrayDataServer indicesTxt = null;
private GLArrayDataServer verticeFboAttr = null;
private GLArrayDataServer texCoordFboAttr = null;
private GLArrayDataServer indicesFbo = null;
-
- private GLContext context;
-
- private boolean flipped = false;
-
- private boolean dirty = false;
-
- private AABBox box = null;
- private FBObject fbo = null;
+
+ private GLContext context;
+
+ private boolean flipped = false;
+
+ private boolean dirty = false;
+
+ private AABBox box = null;
+ private FBObject fbo = null;
- private int tex_width_c = 0;
- private int tex_height_c = 0;
-
- private ShaderState st;
-
- public VBORegion2PES2(GLContext context, ShaderState st){
- this.context =context;
- this.st = st;
-
- GL2ES2 gl = context.getGL().getGL2ES2();
-
+ private int tex_width_c = 0;
+ private int tex_height_c = 0;
+
+ private ShaderState st;
+
+ public VBORegion2PES2(GLContext context, ShaderState st){
+ this.context =context;
+ this.st = st;
+
+ GL2ES2 gl = context.getGL().getGL2ES2();
+
indicesFbo = GLArrayDataServer.createGLSL(gl, null, 3, GL2ES2.GL_SHORT, false,
2, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3);
@@ -108,132 +108,132 @@ public class VBORegion2PES2 implements Region {
if(DEBUG) {
System.err.println("VBORegion2PES2 Create: " + this);
}
- }
-
- public void update(){
- GL2ES2 gl = context.getGL().getGL2ES2();
-
+ }
+
+ public void update(){
+ GL2ES2 gl = context.getGL().getGL2ES2();
+
destroyTxtAttr(gl);
box = new AABBox();
indicesTxt = GLArrayDataServer.createGLSL(gl, null, 3, GL2ES2.GL_SHORT, false,
triangles.size(), GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
- for(Triangle t:triangles){
- if(t.getVertices()[0].getId() == Integer.MAX_VALUE){
- t.getVertices()[0].setId(numVertices++);
- t.getVertices()[1].setId(numVertices++);
- t.getVertices()[2].setId(numVertices++);
-
- vertices.add(t.getVertices()[0]);
- vertices.add(t.getVertices()[1]);
- vertices.add(t.getVertices()[2]);
-
- indicesTxt.puts((short) t.getVertices()[0].getId());
- indicesTxt.puts((short) t.getVertices()[1].getId());
- indicesTxt.puts((short) t.getVertices()[2].getId());
- }
- else{
- Vertex v1 = t.getVertices()[0];
- Vertex v2 = t.getVertices()[1];
- Vertex v3 = t.getVertices()[2];
-
- indicesTxt.puts((short) v1.getId());
- indicesTxt.puts((short) v2.getId());
- indicesTxt.puts((short) v3.getId());
- }
- }
+ for(Triangle t:triangles){
+ if(t.getVertices()[0].getId() == Integer.MAX_VALUE){
+ t.getVertices()[0].setId(numVertices++);
+ t.getVertices()[1].setId(numVertices++);
+ t.getVertices()[2].setId(numVertices++);
+
+ vertices.add(t.getVertices()[0]);
+ vertices.add(t.getVertices()[1]);
+ vertices.add(t.getVertices()[2]);
+
+ indicesTxt.puts((short) t.getVertices()[0].getId());
+ indicesTxt.puts((short) t.getVertices()[1].getId());
+ indicesTxt.puts((short) t.getVertices()[2].getId());
+ }
+ else{
+ Vertex v1 = t.getVertices()[0];
+ Vertex v2 = t.getVertices()[1];
+ Vertex v3 = t.getVertices()[2];
+
+ indicesTxt.puts((short) v1.getId());
+ indicesTxt.puts((short) v2.getId());
+ indicesTxt.puts((short) v3.getId());
+ }
+ }
indicesTxt.seal(gl, true);
verticeTxtAttr = GLArrayDataServer.createGLSL(gl, Region.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false,
vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
verticeTxtAttr.setLocation(Region.VERTEX_ATTR_IDX);
- for(Vertex v:vertices){
- verticeTxtAttr.putf(v.getX());
- if(flipped){
- verticeTxtAttr.putf(-1*v.getY());
- } else {
- verticeTxtAttr.putf(v.getY());
- }
- verticeTxtAttr.putf(v.getZ());
- if(flipped){
- box.resize(v.getX(), -1*v.getY(), v.getZ());
- } else {
- box.resize(v.getX(), v.getY(), v.getZ());
- }
- }
+ for(Vertex v:vertices){
+ verticeTxtAttr.putf(v.getX());
+ if(flipped){
+ verticeTxtAttr.putf(-1*v.getY());
+ } else {
+ verticeTxtAttr.putf(v.getY());
+ }
+ verticeTxtAttr.putf(v.getZ());
+ if(flipped){
+ box.resize(v.getX(), -1*v.getY(), v.getZ());
+ } else {
+ box.resize(v.getX(), v.getY(), v.getZ());
+ }
+ }
verticeTxtAttr.seal(gl, true);
-
+
texCoordTxtAttr = GLArrayDataServer.createGLSL(gl, Region.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false,
vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
texCoordTxtAttr.setLocation(Region.TEXCOORD_ATTR_IDX);
- for(Vertex v:vertices){
- float[] tex = v.getTexCoord();
- texCoordTxtAttr.putf(tex[0]);
- texCoordTxtAttr.putf(tex[1]);
- }
+ for(Vertex v:vertices){
+ float[] tex = v.getTexCoord();
+ texCoordTxtAttr.putf(tex[0]);
+ texCoordTxtAttr.putf(tex[1]);
+ }
texCoordTxtAttr.seal(gl, true);
// leave the buffers enabled for subsequent render call
- dirty = false;
- }
-
- public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
+ dirty = false;
+ }
+
+ public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
GL2ES2 gl = context.getGL().getGL2ES2();
- if(null == matrix || vp_width <=0 || vp_height <= 0 || width <= 0){
- renderRegion(gl);
- } else {
- if(width != tex_width_c){
+ if(null == matrix || vp_width <=0 || vp_height <= 0 || width <= 0){
+ renderRegion(gl);
+ } else {
+ if(width != tex_width_c){
renderRegion2FBO(gl, matrix, width);
setupBBox2FboAttr(gl);
- }
-// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
- renderFBO(gl, matrix, vp_width, vp_height);
- }
- }
-
- private void renderFBO(GL2ES2 gl, PMVMatrix matrix, int width, int hight) {
- gl.glViewport(0, 0, width, hight);
- if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, matrix.glGetPMvMatrixf()))){
- System.out.println("Cnt set tex based mat");
- }
- gl.glEnable(GL2ES2.GL_TEXTURE_2D);
- gl.glActiveTexture(GL2ES2.GL_TEXTURE0);
- fbo.use(gl);
-
- st.glUniform(gl, new GLUniformData("texture", fbo.getTextureName()));
- int loc = gl.glGetUniformLocation(st.shaderProgram().program(), "texture");
- gl.glUniform1i(loc, 0);
-
-
+ }
+// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
+ renderFBO(gl, matrix, vp_width, vp_height);
+ }
+ }
+
+ private void renderFBO(GL2ES2 gl, PMVMatrix matrix, int width, int hight) {
+ gl.glViewport(0, 0, width, hight);
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, matrix.glGetPMvMatrixf()))){
+ System.out.println("Cnt set tex based mat");
+ }
+ gl.glEnable(GL2ES2.GL_TEXTURE_2D);
+ gl.glActiveTexture(GL2ES2.GL_TEXTURE0);
+ fbo.use(gl);
+
+ st.glUniform(gl, new GLUniformData("texture", fbo.getTextureName()));
+ int loc = gl.glGetUniformLocation(st.shaderProgram().program(), "texture");
+ gl.glUniform1i(loc, 0);
+
+
verticeFboAttr.enableBuffer(gl, true);
texCoordFboAttr.enableBuffer(gl, true);
indicesFbo.enableBuffer(gl, true);
gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesFbo.getElementNumber() * indicesFbo.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
-
+
verticeFboAttr.enableBuffer(gl, false);
texCoordFboAttr.enableBuffer(gl, false);
indicesFbo.enableBuffer(gl, false);
- }
-
- private void setupBBox2FboAttr(GL2ES2 gl){
+ }
+
+ private void setupBBox2FboAttr(GL2ES2 gl){
verticeFboAttr.seal(gl, false);
verticeFboAttr.rewind();
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
-
+ verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
+ verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
+ verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
+ verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
+
verticeFboAttr.seal(gl, true);
- }
-
- private void renderRegion2FBO(GL2ES2 gl, PMVMatrix m, int tex_width){
- tex_width_c = tex_width;
- tex_height_c = (int)(tex_width_c*box.getHeight()/box.getWidth());
-
+ }
+
+ private void renderRegion2FBO(GL2ES2 gl, PMVMatrix m, int tex_width){
+ tex_width_c = tex_width;
+ tex_height_c = (int)(tex_width_c*box.getHeight()/box.getWidth());
+
// System.out.println("FBO Size: "+tex_width+" -> "+tex_height_c+"x"+tex_width_c);
// System.out.println("FBO Scale: " + m.glGetMatrixf().get(0) +" " + m.glGetMatrixf().get(5));
@@ -245,79 +245,79 @@ public class VBORegion2PES2 implements Region {
if(null == fbo) {
fbo = new FBObject(tex_width_c, tex_height_c);
// FIXME: shall not use bilinear, due to own AA ? However, w/o bilinear result is not smooth
- fbo.init(gl, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- // fbo.init(gl, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
- fbo.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); // FIXME: or shall we use 24 or 32 bit depth ?
+ fbo.init(gl, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
+ // fbo.init(gl, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
+ fbo.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); // FIXME: or shall we use 24 or 32 bit depth ?
} else {
fbo.bind(gl);
}
-
- //render texture
- PMVMatrix tex_matrix = new PMVMatrix();
- gl.glViewport(0, 0, tex_width_c, tex_height_c);
- tex_matrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- tex_matrix.glLoadIdentity();
- tex_matrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
-
- if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, tex_matrix.glGetPMvMatrixf()))){
- System.out.println("Cnt set tex based mat");
- }
-
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
- renderRegion(gl);
+
+ //render texture
+ PMVMatrix tex_matrix = new PMVMatrix();
+ gl.glViewport(0, 0, tex_width_c, tex_height_c);
+ tex_matrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ tex_matrix.glLoadIdentity();
+ tex_matrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
+
+ if(!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, tex_matrix.glGetPMvMatrixf()))){
+ System.out.println("Cnt set tex based mat");
+ }
+
+ gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT);
+ renderRegion(gl);
- fbo.unbind(gl);
- }
-
- private void renderRegion(GL2ES2 gl) {
+ fbo.unbind(gl);
+ }
+
+ private void renderRegion(GL2ES2 gl) {
verticeTxtAttr.enableBuffer(gl, true);
texCoordTxtAttr.enableBuffer(gl, true);
indicesTxt.enableBuffer(gl, true);
-
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementNumber() * indicesTxt.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
-
+
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementNumber() * indicesTxt.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+
verticeTxtAttr.enableBuffer(gl, false);
texCoordTxtAttr.enableBuffer(gl, false);
indicesTxt.enableBuffer(gl, false);
- }
-
- public void addTriangles(ArrayList<Triangle> tris) {
- triangles.addAll(tris);
- dirty = true;
- }
-
- public int getNumVertices(){
- return numVertices;
- }
-
- public void addVertices(ArrayList<Vertex> verts){
- vertices.addAll(verts);
- numVertices = vertices.size();
- dirty = true;
- }
-
- public boolean isDirty(){
- return dirty;
- }
-
- public void destroy() {
- if(DEBUG) {
- System.err.println("VBORegion2PES2 Destroy: " + this);
- }
- GL2ES2 gl = context.getGL().getGL2ES2();
- destroyFbo(gl);
+ }
+
+ public void addTriangles(ArrayList<Triangle> tris) {
+ triangles.addAll(tris);
+ dirty = true;
+ }
+
+ public int getNumVertices(){
+ return numVertices;
+ }
+
+ public void addVertices(ArrayList<Vertex> verts){
+ vertices.addAll(verts);
+ numVertices = vertices.size();
+ dirty = true;
+ }
+
+ public boolean isDirty(){
+ return dirty;
+ }
+
+ public void destroy() {
+ if(DEBUG) {
+ System.err.println("VBORegion2PES2 Destroy: " + this);
+ }
+ GL2ES2 gl = context.getGL().getGL2ES2();
+ destroyFbo(gl);
destroyTxtAttr(gl);
destroyFboAttr(gl);
triangles.clear();
vertices.clear();
- }
- final void destroyFbo(GL2ES2 gl) {
+ }
+ final void destroyFbo(GL2ES2 gl) {
if(null != fbo) {
fbo.destroy(gl);
fbo = null;
- }
- }
+ }
+ }
final void destroyTxtAttr(GL2ES2 gl) {
if(null != verticeTxtAttr) {
verticeTxtAttr.destroy(gl);
@@ -331,7 +331,7 @@ public class VBORegion2PES2 implements Region {
indicesTxt.destroy(gl);
indicesTxt = null;
}
- }
+ }
final void destroyFboAttr(GL2ES2 gl) {
if(null != verticeFboAttr) {
verticeFboAttr.destroy(gl);
@@ -347,15 +347,15 @@ public class VBORegion2PES2 implements Region {
}
}
- public boolean isFlipped() {
- return flipped;
- }
+ public boolean isFlipped() {
+ return flipped;
+ }
- public void setFlipped(boolean flipped) {
- this.flipped = flipped;
- }
-
- public AABBox getBounds(){
- return box;
- }
+ public void setFlipped(boolean flipped) {
+ this.flipped = flipped;
+ }
+
+ public AABBox getBounds(){
+ return box;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 0d68be8ce..83cd6b80d 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -41,143 +41,143 @@ import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
public class VBORegionSPES2 implements Region {
- private int numVertices = 0;
-
- private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
- private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
- private GLArrayDataServer verticeAttr = null;
- private GLArrayDataServer texCoordAttr = null;
- private GLArrayDataServer indices = null;
-
- private GLContext context;
-
- private boolean flipped = false;
- private boolean dirty = false;
-
- private AABBox box = null;
-
- public VBORegionSPES2(GLContext context){
- this.context =context;
- }
-
- public void update(){
- box = new AABBox();
- GL2ES2 gl = context.getGL().getGL2ES2();
-
+ private int numVertices = 0;
+
+ private ArrayList<Triangle> triangles = new ArrayList<Triangle>();
+ private ArrayList<Vertex> vertices = new ArrayList<Vertex>();
+ private GLArrayDataServer verticeAttr = null;
+ private GLArrayDataServer texCoordAttr = null;
+ private GLArrayDataServer indices = null;
+
+ private GLContext context;
+
+ private boolean flipped = false;
+ private boolean dirty = false;
+
+ private AABBox box = null;
+
+ public VBORegionSPES2(GLContext context){
+ this.context =context;
+ }
+
+ public void update(){
+ box = new AABBox();
+ GL2ES2 gl = context.getGL().getGL2ES2();
+
destroy(gl);
indices = GLArrayDataServer.createGLSL(gl, null, 3, GL2ES2.GL_SHORT, false,
triangles.size(), GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER);
- for(Triangle t:triangles){
- final Vertex[] t_vertices = t.getVertices();
-
- if(t_vertices[0].getId() == Integer.MAX_VALUE){
- t_vertices[0].setId(numVertices++);
- t_vertices[1].setId(numVertices++);
- t_vertices[2].setId(numVertices++);
-
- vertices.add(t.getVertices()[0]);
- vertices.add(t.getVertices()[1]);
- vertices.add(t.getVertices()[2]);
+ for(Triangle t:triangles){
+ final Vertex[] t_vertices = t.getVertices();
+
+ if(t_vertices[0].getId() == Integer.MAX_VALUE){
+ t_vertices[0].setId(numVertices++);
+ t_vertices[1].setId(numVertices++);
+ t_vertices[2].setId(numVertices++);
+
+ vertices.add(t.getVertices()[0]);
+ vertices.add(t.getVertices()[1]);
+ vertices.add(t.getVertices()[2]);
- indices.puts((short) t.getVertices()[0].getId());
- indices.puts((short) t.getVertices()[1].getId());
- indices.puts((short) t.getVertices()[2].getId());
- }
- else{
- Vertex v1 = t_vertices[0];
- Vertex v2 = t_vertices[1];
- Vertex v3 = t_vertices[2];
-
- indices.puts((short) v1.getId());
- indices.puts((short) v2.getId());
- indices.puts((short) v3.getId());
- }
- }
+ indices.puts((short) t.getVertices()[0].getId());
+ indices.puts((short) t.getVertices()[1].getId());
+ indices.puts((short) t.getVertices()[2].getId());
+ }
+ else{
+ Vertex v1 = t_vertices[0];
+ Vertex v2 = t_vertices[1];
+ Vertex v3 = t_vertices[2];
+
+ indices.puts((short) v1.getId());
+ indices.puts((short) v2.getId());
+ indices.puts((short) v3.getId());
+ }
+ }
indices.seal(gl, true);
-
- verticeAttr = GLArrayDataServer.createGLSL(gl, Region.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false,
- vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
- verticeAttr.setLocation(Region.VERTEX_ATTR_IDX);
- for(Vertex v:vertices){
-
- if(flipped){
- verticeAttr.putf(v.getX());
- verticeAttr.putf(-1*v.getY());
- verticeAttr.putf(v.getZ());
-
- box.resize(v.getX(),-1*v.getY(),v.getZ());
- }
- else{
- verticeAttr.putf(v.getX());
- verticeAttr.putf(v.getY());
- verticeAttr.putf(v.getZ());
-
- box.resize(v.getX(),v.getY(),v.getZ());
- }
- }
- verticeAttr.seal(gl, true);
+
+ verticeAttr = GLArrayDataServer.createGLSL(gl, Region.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false,
+ vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
+ verticeAttr.setLocation(Region.VERTEX_ATTR_IDX);
+ for(Vertex v:vertices){
+
+ if(flipped){
+ verticeAttr.putf(v.getX());
+ verticeAttr.putf(-1*v.getY());
+ verticeAttr.putf(v.getZ());
+
+ box.resize(v.getX(),-1*v.getY(),v.getZ());
+ }
+ else{
+ verticeAttr.putf(v.getX());
+ verticeAttr.putf(v.getY());
+ verticeAttr.putf(v.getZ());
+
+ box.resize(v.getX(),v.getY(),v.getZ());
+ }
+ }
+ verticeAttr.seal(gl, true);
texCoordAttr = GLArrayDataServer.createGLSL(gl, Region.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false,
vertices.size(), GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER);
texCoordAttr.setLocation(Region.TEXCOORD_ATTR_IDX);
- for(Vertex v:vertices){
- float[] tex = v.getTexCoord();
- texCoordAttr.putf(tex[0]);
- texCoordAttr.putf(tex[1]);
- }
- texCoordAttr.seal(gl, true);
+ for(Vertex v:vertices){
+ float[] tex = v.getTexCoord();
+ texCoordAttr.putf(tex[0]);
+ texCoordAttr.putf(tex[1]);
+ }
+ texCoordAttr.seal(gl, true);
verticeAttr.enableBuffer(gl, false);
texCoordAttr.enableBuffer(gl, false);
indices.enableBuffer(gl, false);
- dirty = false;
- }
-
- private void render() {
- GL2ES2 gl = context.getGL().getGL2ES2();
+ dirty = false;
+ }
+
+ private void render() {
+ GL2ES2 gl = context.getGL().getGL2ES2();
verticeAttr.enableBuffer(gl, true);
texCoordAttr.enableBuffer(gl, true);
indices.enableBuffer(gl, true);
-
- gl.glDrawElements(GL2ES2.GL_TRIANGLES, indices.getElementNumber() * indices.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
-
+
+ gl.glDrawElements(GL2ES2.GL_TRIANGLES, indices.getElementNumber() * indices.getComponentNumber(), GL2ES2.GL_UNSIGNED_SHORT, 0);
+
verticeAttr.enableBuffer(gl, false);
texCoordAttr.enableBuffer(gl, false);
indices.enableBuffer(gl, false);
- }
-
- public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
- render();
- }
-
- public void addTriangles(ArrayList<Triangle> tris) {
- triangles.addAll(tris);
- dirty = true;
- }
-
- public int getNumVertices(){
- return numVertices;
- }
-
- public void addVertices(ArrayList<Vertex> verts){
- vertices.addAll(verts);
- numVertices = vertices.size();
- dirty = true;
- }
-
- public boolean isDirty(){
- return dirty;
- }
-
- public void destroy() {
- GL2ES2 gl = context.getGL().getGL2ES2();
- destroy(gl);
- }
-
- final void destroy(GL2ES2 gl) {
+ }
+
+ public void render(PMVMatrix matrix, int vp_width, int vp_height, int width){
+ render();
+ }
+
+ public void addTriangles(ArrayList<Triangle> tris) {
+ triangles.addAll(tris);
+ dirty = true;
+ }
+
+ public int getNumVertices(){
+ return numVertices;
+ }
+
+ public void addVertices(ArrayList<Vertex> verts){
+ vertices.addAll(verts);
+ numVertices = vertices.size();
+ dirty = true;
+ }
+
+ public boolean isDirty(){
+ return dirty;
+ }
+
+ public void destroy() {
+ GL2ES2 gl = context.getGL().getGL2ES2();
+ destroy(gl);
+ }
+
+ final void destroy(GL2ES2 gl) {
if(null != verticeAttr) {
verticeAttr.destroy(gl);
verticeAttr = null;
@@ -190,16 +190,16 @@ public class VBORegionSPES2 implements Region {
indices.destroy(gl);
indices = null;
}
- }
-
- public boolean isFlipped() {
- return flipped;
- }
+ }
+
+ public boolean isFlipped() {
+ return flipped;
+ }
- public void setFlipped(boolean flipped) {
- this.flipped = flipped;
- }
- public AABBox getBounds(){
- return box;
- }
+ public void setFlipped(boolean flipped) {
+ this.flipped = flipped;
+ }
+ public AABBox getBounds(){
+ return box;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp
index 3a1ef5157..166937f7f 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.fp
@@ -15,81 +15,81 @@ vec4 weights = vec4(0.075, 0.06, 0.045, 0.025);
void main (void)
{
- vec2 rtex = vec2(abs(v_texCoord.x),abs(v_texCoord.y));
- vec3 c = g_color;
-
- float alpha = 0.0;
-
- if((v_texCoord.x == 0.0) && (v_texCoord.y == 0.0)){
- alpha = g_alpha;
- }
- else if((v_texCoord.x >= 5.0)){
- vec2 dfx = dFdx(v_texCoord);
- vec2 dfy = dFdy(v_texCoord);
-
- vec2 size = 1.0/textureSize(texture,0); //version 130
- rtex -= 5.0;
- vec4 t = texture2D(texture, rtex)* 0.18;
+ vec2 rtex = vec2(abs(v_texCoord.x),abs(v_texCoord.y));
+ vec3 c = g_color;
+
+ float alpha = 0.0;
+
+ if((v_texCoord.x == 0.0) && (v_texCoord.y == 0.0)){
+ alpha = g_alpha;
+ }
+ else if((v_texCoord.x >= 5.0)){
+ vec2 dfx = dFdx(v_texCoord);
+ vec2 dfy = dFdy(v_texCoord);
+
+ vec2 size = 1.0/textureSize(texture,0); //version 130
+ rtex -= 5.0;
+ vec4 t = texture2D(texture, rtex)* 0.18;
- t += texture2D(texture, rtex + size*(vec2(1, 0)))*weights.x;
- t += texture2D(texture, rtex - size*(vec2(1, 0)))*weights.x;
- t += texture2D(texture, rtex + size*(vec2(0, 1)))*weights.x;
- t += texture2D(texture, rtex - size*(vec2(0, 1)))*weights.x;
-
- t += texture2D(texture, rtex + 2.0*size*(vec2(1, 0))) *weights.y;
- t += texture2D(texture, rtex - 2.0*size*(vec2(1, 0)))*weights.y;
- t += texture2D(texture, rtex + 2.0*size*(vec2(0, 1)))*weights.y;
- t += texture2D(texture, rtex - 2.0*size*(vec2(0, 1)))*weights.y;
-
- t += texture2D(texture, rtex + 3.0*size*(vec2(1, 0))) *weights.z;
- t += texture2D(texture, rtex - 3.0*size*(vec2(1, 0)))*weights.z;
- t += texture2D(texture, rtex + 3.0*size*(vec2(0, 1)))*weights.z;
- t += texture2D(texture, rtex - 3.0*size*(vec2(0, 1)))*weights.z;
-
- t += texture2D(texture, rtex + 4.0*size*(vec2(1, 0))) *weights.w;
- t += texture2D(texture, rtex - 4.0*size*(vec2(1, 0)))*weights.w;
- t += texture2D(texture, rtex + 4.0*size*(vec2(0, 1)))*weights.w;
- t += texture2D(texture, rtex - 4.0*size*(vec2(0, 1)))*weights.w;
-
- if(t.w == 0.0){
- discard;
- }
-
- c = t.xyz;
- alpha = g_alpha* t.w;
- }
- ///////////////////////////////////////////////////////////
- else if ((v_texCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
- vec2 dtx = dFdx(rtex);
- vec2 dty = dFdy(rtex);
-
- rtex.y -= 0.1;
-
- if(rtex.y < 0.0) {
- if(v_texCoord.y < 0.0)
- discard;
- else{
- rtex.y = 0.0;
- }
- }
-
- vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
- float position = rtex.y - (rtex.x * (1.0 - rtex.x));
- float d = position/(length(f));
+ t += texture2D(texture, rtex + size*(vec2(1, 0)))*weights.x;
+ t += texture2D(texture, rtex - size*(vec2(1, 0)))*weights.x;
+ t += texture2D(texture, rtex + size*(vec2(0, 1)))*weights.x;
+ t += texture2D(texture, rtex - size*(vec2(0, 1)))*weights.x;
+
+ t += texture2D(texture, rtex + 2.0*size*(vec2(1, 0))) *weights.y;
+ t += texture2D(texture, rtex - 2.0*size*(vec2(1, 0)))*weights.y;
+ t += texture2D(texture, rtex + 2.0*size*(vec2(0, 1)))*weights.y;
+ t += texture2D(texture, rtex - 2.0*size*(vec2(0, 1)))*weights.y;
+
+ t += texture2D(texture, rtex + 3.0*size*(vec2(1, 0))) *weights.z;
+ t += texture2D(texture, rtex - 3.0*size*(vec2(1, 0)))*weights.z;
+ t += texture2D(texture, rtex + 3.0*size*(vec2(0, 1)))*weights.z;
+ t += texture2D(texture, rtex - 3.0*size*(vec2(0, 1)))*weights.z;
+
+ t += texture2D(texture, rtex + 4.0*size*(vec2(1, 0))) *weights.w;
+ t += texture2D(texture, rtex - 4.0*size*(vec2(1, 0)))*weights.w;
+ t += texture2D(texture, rtex + 4.0*size*(vec2(0, 1)))*weights.w;
+ t += texture2D(texture, rtex - 4.0*size*(vec2(0, 1)))*weights.w;
+
+ if(t.w == 0.0){
+ discard;
+ }
+
+ c = t.xyz;
+ alpha = g_alpha* t.w;
+ }
+ ///////////////////////////////////////////////////////////
+ else if ((v_texCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)){
+ vec2 dtx = dFdx(rtex);
+ vec2 dty = dFdy(rtex);
+
+ rtex.y -= 0.1;
+
+ if(rtex.y < 0.0) {
+ if(v_texCoord.y < 0.0)
+ discard;
+ else{
+ rtex.y = 0.0;
+ }
+ }
+
+ vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x));
+ float position = rtex.y - (rtex.x * (1.0 - rtex.x));
+ float d = position/(length(f));
- float a = (0.5 - d * sign(v_texCoord.y));
-
- if (a >= 1.0) {
- alpha = g_alpha;
- }
- else if (a <= 0.0) {
- alpha = 0.0;//discard;
- }
- else {
- alpha = g_alpha*a;
- mix(b_color,g_color, a);
- }
- }
-
+ float a = (0.5 - d * sign(v_texCoord.y));
+
+ if (a >= 1.0) {
+ alpha = g_alpha;
+ }
+ else if (a <= 0.0) {
+ alpha = 0.0;//discard;
+ }
+ else {
+ alpha = g_alpha*a;
+ mix(b_color,g_color, a);
+ }
+ }
+
gl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java
index 5dae296e5..a0d1923a9 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java
@@ -33,49 +33,49 @@ import com.jogamp.graph.geom.Outline;
import com.jogamp.graph.geom.Vertex;
public class GraphOutline {
- final private Outline outline;
- final private ArrayList<GraphVertex> controlpoints = new ArrayList<GraphVertex>(3);
-
- public GraphOutline(){
- this.outline = new Outline();
- }
-
- /**Create a control polyline of control vertices
- * the curve pieces can be identified by onCurve flag
- * of each cp the control polyline is open by default
- */
- public GraphOutline(Outline ol){
- this.outline = ol;
- ArrayList<Vertex> vertices = this.outline.getVertices();
- for(Vertex v:vertices){
- this.controlpoints.add(new GraphVertex(v));
- }
- }
+ final private Outline outline;
+ final private ArrayList<GraphVertex> controlpoints = new ArrayList<GraphVertex>(3);
+
+ public GraphOutline(){
+ this.outline = new Outline();
+ }
+
+ /**Create a control polyline of control vertices
+ * the curve pieces can be identified by onCurve flag
+ * of each cp the control polyline is open by default
+ */
+ public GraphOutline(Outline ol){
+ this.outline = ol;
+ ArrayList<Vertex> vertices = this.outline.getVertices();
+ for(Vertex v:vertices){
+ this.controlpoints.add(new GraphVertex(v));
+ }
+ }
- public Outline getOutline() {
- return outline;
- }
+ public Outline getOutline() {
+ return outline;
+ }
- /*public void setOutline(Outline<T> outline) {
- this.outline = outline;
- }*/
-
+ /*public void setOutline(Outline<T> outline) {
+ this.outline = outline;
+ }*/
+
- public ArrayList<GraphVertex> getGraphPoint() {
- return controlpoints;
- }
-
- public ArrayList<Vertex> getPoints() {
- return outline.getVertices();
- }
+ public ArrayList<GraphVertex> getGraphPoint() {
+ return controlpoints;
+ }
+
+ public ArrayList<Vertex> getPoints() {
+ return outline.getVertices();
+ }
- /*public void setControlpoints(ArrayList<GraphPoint<T>> controlpoints) {
- this.controlpoints = controlpoints;
- }*/
+ /*public void setControlpoints(ArrayList<GraphPoint<T>> controlpoints) {
+ this.controlpoints = controlpoints;
+ }*/
- public void addVertex(GraphVertex v) {
- controlpoints.add(v);
- outline.addVertex(v.getPoint());
- }
-
+ public void addVertex(GraphVertex v) {
+ controlpoints.add(v);
+ outline.addVertex(v.getPoint());
+ }
+
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java
index b9f95a0e7..5efe57c28 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java
@@ -32,89 +32,89 @@ import java.util.ArrayList;
import com.jogamp.graph.geom.Vertex;
public class GraphVertex {
- private Vertex point;
- private ArrayList<HEdge> edges = null;
- private boolean boundaryContained = false;
-
- public GraphVertex(Vertex point) {
- this.point = point;
- }
+ private Vertex point;
+ private ArrayList<HEdge> edges = null;
+ private boolean boundaryContained = false;
+
+ public GraphVertex(Vertex point) {
+ this.point = point;
+ }
- public Vertex getPoint() {
- return point;
- }
-
- public float getX(){
- return point.getX();
- }
-
- public float getY(){
- return point.getY();
- }
-
- public float getZ(){
- return point.getZ();
- }
- public float[] getCoord() {
- return point.getCoord();
- }
+ public Vertex getPoint() {
+ return point;
+ }
+
+ public float getX(){
+ return point.getX();
+ }
+
+ public float getY(){
+ return point.getY();
+ }
+
+ public float getZ(){
+ return point.getZ();
+ }
+ public float[] getCoord() {
+ return point.getCoord();
+ }
- public void setPoint(Vertex point) {
- this.point = point;
- }
+ public void setPoint(Vertex point) {
+ this.point = point;
+ }
- public ArrayList<HEdge> getEdges() {
- return edges;
- }
+ public ArrayList<HEdge> getEdges() {
+ return edges;
+ }
- public void setEdges(ArrayList<HEdge> edges) {
- this.edges = edges;
- }
-
- public void addEdge(HEdge edge){
- if(edges == null){
- edges = new ArrayList<HEdge>();
- }
- edges.add(edge);
- }
- public void removeEdge(HEdge edge){
- if(edges == null)
- return;
- edges.remove(edge);
- if(edges.size() == 0){
- edges = null;
- }
- }
- public HEdge findNextEdge(GraphVertex nextVert){
- for(HEdge e:edges){
- if(e.getNext().getGraphPoint() == nextVert){
- return e;
- }
- }
- return null;
- }
- public HEdge findBoundEdge(){
- for(HEdge e:edges){
- if((e.getType() == HEdge.BOUNDARY) || (e.getType() == HEdge.HOLE)){
- return e;
- }
- }
- return null;
- }
- public HEdge findPrevEdge(GraphVertex prevVert){
- for(HEdge e:edges){
- if(e.getPrev().getGraphPoint() == prevVert){
- return e;
- }
- }
- return null;
- }
-
- public boolean isBoundaryContained() {
- return boundaryContained;
- }
+ public void setEdges(ArrayList<HEdge> edges) {
+ this.edges = edges;
+ }
+
+ public void addEdge(HEdge edge){
+ if(edges == null){
+ edges = new ArrayList<HEdge>();
+ }
+ edges.add(edge);
+ }
+ public void removeEdge(HEdge edge){
+ if(edges == null)
+ return;
+ edges.remove(edge);
+ if(edges.size() == 0){
+ edges = null;
+ }
+ }
+ public HEdge findNextEdge(GraphVertex nextVert){
+ for(HEdge e:edges){
+ if(e.getNext().getGraphPoint() == nextVert){
+ return e;
+ }
+ }
+ return null;
+ }
+ public HEdge findBoundEdge(){
+ for(HEdge e:edges){
+ if((e.getType() == HEdge.BOUNDARY) || (e.getType() == HEdge.HOLE)){
+ return e;
+ }
+ }
+ return null;
+ }
+ public HEdge findPrevEdge(GraphVertex prevVert){
+ for(HEdge e:edges){
+ if(e.getPrev().getGraphPoint() == prevVert){
+ return e;
+ }
+ }
+ return null;
+ }
+
+ public boolean isBoundaryContained() {
+ return boundaryContained;
+ }
- public void setBoundaryContained(boolean boundaryContained) {
- this.boundaryContained = boundaryContained;
- }
+ public void setBoundaryContained(boolean boundaryContained) {
+ this.boundaryContained = boundaryContained;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java b/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java
index d1bcc6e17..4d29a81f3 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java
@@ -32,99 +32,99 @@ import com.jogamp.graph.geom.Triangle;
public class HEdge {
- public static int BOUNDARY = 3;
- public static int INNER = 1;
- public static int HOLE = 2;
-
- private GraphVertex vert;
- private HEdge prev = null;
- private HEdge next = null;
- private HEdge sibling = null;
- private int type = BOUNDARY;
- private Triangle triangle = null;
-
- public HEdge(GraphVertex vert, int type) {
- this.vert = vert;
- this.type = type;
- }
-
- public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type) {
- this.vert = vert;
- this.prev = prev;
- this.next = next;
- this.sibling = sibling;
- this.type = type;
- }
-
- public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type, Triangle triangle) {
- this.vert = vert;
- this.prev = prev;
- this.next = next;
- this.sibling = sibling;
- this.type = type;
- this.triangle = triangle;
- }
-
- public GraphVertex getGraphPoint() {
- return vert;
- }
-
- public void setVert(GraphVertex vert) {
- this.vert = vert;
- }
-
- public HEdge getPrev() {
- return prev;
- }
-
- public void setPrev(HEdge prev) {
- this.prev = prev;
- }
-
- public HEdge getNext() {
- return next;
- }
-
- public void setNext(HEdge next) {
- this.next = next;
- }
-
- public HEdge getSibling() {
- return sibling;
- }
-
- public void setSibling(HEdge sibling) {
- this.sibling = sibling;
- }
-
- public int getType() {
- return type;
- }
-
- public void setType(int type) {
- this.type = type;
- }
-
- public Triangle getTriangle() {
- return triangle;
- }
-
- public void setTriangle(Triangle triangle) {
- this.triangle = triangle;
- }
-
- public static <T extends Vertex> void connect(HEdge first, HEdge next){
- first.setNext(next);
- next.setPrev(first);
- }
-
- public static <T extends Vertex> void makeSiblings(HEdge first, HEdge second){
- first.setSibling(second);
- second.setSibling(first);
- }
-
- public boolean vertexOnCurveVertex(){
- return vert.getPoint().isOnCurve();
- }
-
+ public static int BOUNDARY = 3;
+ public static int INNER = 1;
+ public static int HOLE = 2;
+
+ private GraphVertex vert;
+ private HEdge prev = null;
+ private HEdge next = null;
+ private HEdge sibling = null;
+ private int type = BOUNDARY;
+ private Triangle triangle = null;
+
+ public HEdge(GraphVertex vert, int type) {
+ this.vert = vert;
+ this.type = type;
+ }
+
+ public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type) {
+ this.vert = vert;
+ this.prev = prev;
+ this.next = next;
+ this.sibling = sibling;
+ this.type = type;
+ }
+
+ public HEdge(GraphVertex vert, HEdge prev, HEdge next, HEdge sibling, int type, Triangle triangle) {
+ this.vert = vert;
+ this.prev = prev;
+ this.next = next;
+ this.sibling = sibling;
+ this.type = type;
+ this.triangle = triangle;
+ }
+
+ public GraphVertex getGraphPoint() {
+ return vert;
+ }
+
+ public void setVert(GraphVertex vert) {
+ this.vert = vert;
+ }
+
+ public HEdge getPrev() {
+ return prev;
+ }
+
+ public void setPrev(HEdge prev) {
+ this.prev = prev;
+ }
+
+ public HEdge getNext() {
+ return next;
+ }
+
+ public void setNext(HEdge next) {
+ this.next = next;
+ }
+
+ public HEdge getSibling() {
+ return sibling;
+ }
+
+ public void setSibling(HEdge sibling) {
+ this.sibling = sibling;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public Triangle getTriangle() {
+ return triangle;
+ }
+
+ public void setTriangle(Triangle triangle) {
+ this.triangle = triangle;
+ }
+
+ public static <T extends Vertex> void connect(HEdge first, HEdge next){
+ first.setNext(next);
+ next.setPrev(first);
+ }
+
+ public static <T extends Vertex> void makeSiblings(HEdge first, HEdge second){
+ first.setSibling(second);
+ second.setSibling(first);
+ }
+
+ public boolean vertexOnCurveVertex(){
+ return vert.getPoint().isOnCurve();
+ }
+
}
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
index fd7736a20..9e29d3973 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
@@ -36,338 +36,338 @@ import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.math.VectorUtil;
public class Loop {
- private HEdge root = null;
- private AABBox box = new AABBox();
- private GraphOutline initialOutline = null;
-
- public Loop(GraphOutline polyline, int direction){
- initialOutline = polyline;
- this.root = initFromPolyline(initialOutline, direction);
- }
-
- public HEdge getHEdge(){
- return root;
- }
-
- public Triangle cut(boolean delaunay){
- if(isSimplex()){
- Triangle t = new Triangle(root.getGraphPoint().getPoint(), root.getNext().getGraphPoint().getPoint(),
- root.getNext().getNext().getGraphPoint().getPoint());
- t.setVerticesBoundary(checkVerticesBoundary(root));
- return t;
- }
- HEdge prev = root.getPrev();
- HEdge next1 = root.getNext();
-
- HEdge next2 = findClosestValidNeighbor(next1.getNext(), delaunay);
- if(next2 == null){
- root = root.getNext();
- return null;
- }
-
- GraphVertex v1 = root.getGraphPoint();
- GraphVertex v2 = next1.getGraphPoint();
- GraphVertex v3 = next2.getGraphPoint();
-
- HEdge v3Edge = new HEdge(v3, HEdge.INNER);
-
- HEdge.connect(v3Edge, root);
- HEdge.connect(next1, v3Edge);
-
- HEdge v3EdgeSib = v3Edge.getSibling();
- if(v3EdgeSib == null){
- v3EdgeSib = new HEdge(v3Edge.getNext().getGraphPoint(), HEdge.INNER);
- HEdge.makeSiblings(v3Edge, v3EdgeSib);
- }
-
- HEdge.connect(prev, v3EdgeSib);
- HEdge.connect(v3EdgeSib, next2);
-
- Triangle t = createTriangle(v1.getPoint(), v2.getPoint(), v3.getPoint(), root);
- this.root = next2;
- return t;
- }
-
- public boolean isSimplex(){
- return (root.getNext().getNext().getNext() == root);
- }
-
- /**Create a connected list of half edges (loop)
- * from the boundary profile
- * @param direction requested winding of edges (CCW or CW)
- */
- private HEdge initFromPolyline(GraphOutline outline, int direction){
- ArrayList<GraphVertex> vertices = outline.getGraphPoint();
-
- if(vertices.size()<3) {
- throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size());
- }
- boolean isCCW = VectorUtil.ccw(vertices.get(0).getPoint(), vertices.get(1).getPoint(),
- vertices.get(2).getPoint());
- boolean invert = isCCW && (direction == VectorUtil.CW);
-
- HEdge firstEdge = null;
- HEdge lastEdge = null;
- int index =0;
- int max = vertices.size();
-
- int edgeType = HEdge.BOUNDARY;
- if(invert){
- index = vertices.size() -1;
- max = -1;
- edgeType = HEdge.HOLE;
- }
-
- while(index != max){
- GraphVertex v1 = vertices.get(index);
- box.resize(v1.getX(), v1.getY(), v1.getZ());
-
- HEdge edge = new HEdge(v1, edgeType);
-
- v1.addEdge(edge);
- if(lastEdge != null){
- lastEdge.setNext(edge);
- edge.setPrev(lastEdge);
- }
- else{
- firstEdge = edge;
- }
-
- if(!invert){
- if(index == vertices.size()-1){
- edge.setNext(firstEdge);
- firstEdge.setPrev(edge);
- }
- }
- else if (index == 0){
- edge.setNext(firstEdge);
- firstEdge.setPrev(edge);
- }
-
- lastEdge = edge;
-
- if(!invert){
- index++;
- }
- else{
- index--;
- }
- }
- return firstEdge;
- }
-
- public void addConstraintCurve(GraphOutline polyline) {
- // GraphOutline outline = new GraphOutline(polyline);
- /**needed to generate vertex references.*/
- initFromPolyline(polyline, VectorUtil.CW);
-
- GraphVertex v3 = locateClosestVertex(polyline);
- HEdge v3Edge = v3.findBoundEdge();
- HEdge v3EdgeP = v3Edge.getPrev();
- HEdge crossEdge = new HEdge(root.getGraphPoint(), HEdge.INNER);
-
- HEdge.connect(root.getPrev(), crossEdge);
- HEdge.connect(crossEdge, v3Edge);
-
- HEdge crossEdgeSib = crossEdge.getSibling();
- if(crossEdgeSib == null) {
- crossEdgeSib = new HEdge(crossEdge.getNext().getGraphPoint(), HEdge.INNER);
- HEdge.makeSiblings(crossEdge, crossEdgeSib);
- }
-
- HEdge.connect(v3EdgeP, crossEdgeSib);
- HEdge.connect(crossEdgeSib, root);
- }
-
- /** Locates the vertex and update the loops root
- * to have (root + vertex) as closest pair
- * @param polyline the control polyline
- * to search for closestvertices
- * @return the vertex that is closest to the newly set root Hedge.
- */
- private GraphVertex locateClosestVertex(GraphOutline polyline) {
- HEdge closestE = null;
- GraphVertex closestV = null;
-
- float minDistance = Float.MAX_VALUE;
- boolean inValid = false;
- ArrayList<GraphVertex> initVertices = initialOutline.getGraphPoint();
- ArrayList<GraphVertex> vertices = polyline.getGraphPoint();
-
- for(int i=0; i< initVertices.size()-1; i++){
- GraphVertex v = initVertices.get(i);
- GraphVertex nextV = initVertices.get(i+1);
- for(GraphVertex cand:vertices){
- float distance = VectorUtil.computeLength(v.getCoord(), cand.getCoord());
- if(distance < minDistance){
- for (GraphVertex vert:vertices){
- if(vert == v || vert == nextV || vert == cand)
- continue;
- inValid = VectorUtil.inCircle(v.getPoint(), nextV.getPoint(),
- cand.getPoint(), vert.getPoint());
- if(inValid){
- break;
- }
- }
- if(!inValid){
- closestV = cand;
- minDistance = distance;
- closestE = v.findBoundEdge();
- }
- }
-
- }
- }
-
- if(closestE != null){
- root = closestE;
- }
-
- return closestV;
- }
-
- private HEdge findClosestValidNeighbor(HEdge edge, boolean delaunay) {
- HEdge next = root.getNext();
-
- if(!VectorUtil.ccw(root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(),
- edge.getGraphPoint().getPoint())){
- return null;
- }
-
- HEdge candEdge = edge;
- boolean inValid = false;
-
- if(delaunay){
- Vertex cand = candEdge.getGraphPoint().getPoint();
- HEdge e = candEdge.getNext();
- while (e != candEdge){
- if(e.getGraphPoint() == root.getGraphPoint()
- || e.getGraphPoint() == next.getGraphPoint()
- || e.getGraphPoint().getPoint() == cand){
- e = e.getNext();
- continue;
- }
- inValid = VectorUtil.inCircle(root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(),
- cand, e.getGraphPoint().getPoint());
- if(inValid){
- break;
- }
- e = e.getNext();
- }
- }
- if(!inValid){
- return candEdge;
- }
- return null;
- }
-
- /** Create a triangle from the param vertices only if
- * the triangle is valid. IE not outside region.
- * @param v1 vertex 1
- * @param v2 vertex 2
- * @param v3 vertex 3
- * @param root and edge of this triangle
- * @return the triangle iff it satisfies, null otherwise
- */
- private Triangle createTriangle(Vertex v1, Vertex v2, Vertex v3, HEdge rootT){
- Triangle t = new Triangle(v1, v2, v3);
- t.setVerticesBoundary(checkVerticesBoundary(rootT));
- return t;
- }
-
- private boolean[] checkVerticesBoundary(HEdge rootT) {
- boolean[] boundary = new boolean[3];
- HEdge e1 = rootT;
- HEdge e2 = rootT.getNext();
- HEdge e3 = rootT.getNext().getNext();
-
- if(e1.getGraphPoint().isBoundaryContained()){
- boundary[0] = true;
- }
- if(e2.getGraphPoint().isBoundaryContained()){
- boundary[1] = true;
- }
- if(e3.getGraphPoint().isBoundaryContained()){
- boundary[2] = true;
- }
- return boundary;
- }
-
-
- /** Check if vertex inside the Loop
- * @param vertex the Vertex
- * @return true if the vertex is inside, false otherwise
- */
- public boolean checkInside(Vertex vertex) {
- if(!box.contains(vertex.getX(), vertex.getY(), vertex.getZ())){
- return false;
- }
-
- float[] center = box.getCenter();
-
- int hits = 0;
- HEdge current = root;
- HEdge next = root.getNext();
- while(next!= root){
- if(current.getType() == HEdge.INNER || next.getType() == HEdge.INNER){
- current = next;
- next = current.getNext();
- continue;
- }
- Vertex vert1 = current.getGraphPoint().getPoint();
- Vertex vert2 = next.getGraphPoint().getPoint();
-
- /** The ray is P0+s*D0, where P0 is the ray origin, D0 is a direction vector and s >= 0.
- * The segment is P1+t*D1, where P1 and P1+D1 are the endpoints, and 0 <= t <= 1.
- * perp(x,y) = (y,-x).
- * if Dot(perp(D1),D0) is not zero,
- * s = Dot(perp(D1),P1-P0)/Dot(perp(D1),D0)
- * t = Dot(perp(D0),P1-P0)/Dot(perp(D1),D0)
- */
-
- float[] d0 = new float[]{center[0] - vertex.getX(), center[1]-vertex.getY(),
- center[2]-vertex.getZ()};
- float[] d1 = {vert2.getX() - vert1.getX(), vert2.getY() - vert1.getY(),
- vert2.getZ() - vert1.getZ()};
-
- float[] prep_d1 = {d1[1],-1*d1[0], d1[2]};
- float[] prep_d0 = {d0[1],-1*d0[0], d0[2]};
-
- float[] p0p1 = new float[]{vert1.getX() - vertex.getX(), vert1.getY() - vertex.getY(),
- vert1.getZ() - vertex.getZ()};
-
- float dotD1D0 = VectorUtil.dot(prep_d1, d0);
- if(dotD1D0 == 0){
- /** ray parallel to segment */
- current = next;
- next = current.getNext();
- continue;
- }
-
- float s = VectorUtil.dot(prep_d1,p0p1)/dotD1D0;
- float t = VectorUtil.dot(prep_d0,p0p1)/dotD1D0;
-
- if(s >= 0 && t >= 0 && t<= 1){
- hits++;
- }
- current = next;
- next = current.getNext();
- }
-
- if(hits % 2 != 0){
- /** check if hit count is even */
- return true;
- }
- return false;
- }
-
- public int computeLoopSize(){
- int size = 0;
- HEdge e = root;
- do{
- size++;
- e = e.getNext();
- }while(e != root);
- return size;
- }
+ private HEdge root = null;
+ private AABBox box = new AABBox();
+ private GraphOutline initialOutline = null;
+
+ public Loop(GraphOutline polyline, int direction){
+ initialOutline = polyline;
+ this.root = initFromPolyline(initialOutline, direction);
+ }
+
+ public HEdge getHEdge(){
+ return root;
+ }
+
+ public Triangle cut(boolean delaunay){
+ if(isSimplex()){
+ Triangle t = new Triangle(root.getGraphPoint().getPoint(), root.getNext().getGraphPoint().getPoint(),
+ root.getNext().getNext().getGraphPoint().getPoint());
+ t.setVerticesBoundary(checkVerticesBoundary(root));
+ return t;
+ }
+ HEdge prev = root.getPrev();
+ HEdge next1 = root.getNext();
+
+ HEdge next2 = findClosestValidNeighbor(next1.getNext(), delaunay);
+ if(next2 == null){
+ root = root.getNext();
+ return null;
+ }
+
+ GraphVertex v1 = root.getGraphPoint();
+ GraphVertex v2 = next1.getGraphPoint();
+ GraphVertex v3 = next2.getGraphPoint();
+
+ HEdge v3Edge = new HEdge(v3, HEdge.INNER);
+
+ HEdge.connect(v3Edge, root);
+ HEdge.connect(next1, v3Edge);
+
+ HEdge v3EdgeSib = v3Edge.getSibling();
+ if(v3EdgeSib == null){
+ v3EdgeSib = new HEdge(v3Edge.getNext().getGraphPoint(), HEdge.INNER);
+ HEdge.makeSiblings(v3Edge, v3EdgeSib);
+ }
+
+ HEdge.connect(prev, v3EdgeSib);
+ HEdge.connect(v3EdgeSib, next2);
+
+ Triangle t = createTriangle(v1.getPoint(), v2.getPoint(), v3.getPoint(), root);
+ this.root = next2;
+ return t;
+ }
+
+ public boolean isSimplex(){
+ return (root.getNext().getNext().getNext() == root);
+ }
+
+ /**Create a connected list of half edges (loop)
+ * from the boundary profile
+ * @param direction requested winding of edges (CCW or CW)
+ */
+ private HEdge initFromPolyline(GraphOutline outline, int direction){
+ ArrayList<GraphVertex> vertices = outline.getGraphPoint();
+
+ if(vertices.size()<3) {
+ throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size());
+ }
+ boolean isCCW = VectorUtil.ccw(vertices.get(0).getPoint(), vertices.get(1).getPoint(),
+ vertices.get(2).getPoint());
+ boolean invert = isCCW && (direction == VectorUtil.CW);
+
+ HEdge firstEdge = null;
+ HEdge lastEdge = null;
+ int index =0;
+ int max = vertices.size();
+
+ int edgeType = HEdge.BOUNDARY;
+ if(invert){
+ index = vertices.size() -1;
+ max = -1;
+ edgeType = HEdge.HOLE;
+ }
+
+ while(index != max){
+ GraphVertex v1 = vertices.get(index);
+ box.resize(v1.getX(), v1.getY(), v1.getZ());
+
+ HEdge edge = new HEdge(v1, edgeType);
+
+ v1.addEdge(edge);
+ if(lastEdge != null){
+ lastEdge.setNext(edge);
+ edge.setPrev(lastEdge);
+ }
+ else{
+ firstEdge = edge;
+ }
+
+ if(!invert){
+ if(index == vertices.size()-1){
+ edge.setNext(firstEdge);
+ firstEdge.setPrev(edge);
+ }
+ }
+ else if (index == 0){
+ edge.setNext(firstEdge);
+ firstEdge.setPrev(edge);
+ }
+
+ lastEdge = edge;
+
+ if(!invert){
+ index++;
+ }
+ else{
+ index--;
+ }
+ }
+ return firstEdge;
+ }
+
+ public void addConstraintCurve(GraphOutline polyline) {
+ // GraphOutline outline = new GraphOutline(polyline);
+ /**needed to generate vertex references.*/
+ initFromPolyline(polyline, VectorUtil.CW);
+
+ GraphVertex v3 = locateClosestVertex(polyline);
+ HEdge v3Edge = v3.findBoundEdge();
+ HEdge v3EdgeP = v3Edge.getPrev();
+ HEdge crossEdge = new HEdge(root.getGraphPoint(), HEdge.INNER);
+
+ HEdge.connect(root.getPrev(), crossEdge);
+ HEdge.connect(crossEdge, v3Edge);
+
+ HEdge crossEdgeSib = crossEdge.getSibling();
+ if(crossEdgeSib == null) {
+ crossEdgeSib = new HEdge(crossEdge.getNext().getGraphPoint(), HEdge.INNER);
+ HEdge.makeSiblings(crossEdge, crossEdgeSib);
+ }
+
+ HEdge.connect(v3EdgeP, crossEdgeSib);
+ HEdge.connect(crossEdgeSib, root);
+ }
+
+ /** Locates the vertex and update the loops root
+ * to have (root + vertex) as closest pair
+ * @param polyline the control polyline
+ * to search for closestvertices
+ * @return the vertex that is closest to the newly set root Hedge.
+ */
+ private GraphVertex locateClosestVertex(GraphOutline polyline) {
+ HEdge closestE = null;
+ GraphVertex closestV = null;
+
+ float minDistance = Float.MAX_VALUE;
+ boolean inValid = false;
+ ArrayList<GraphVertex> initVertices = initialOutline.getGraphPoint();
+ ArrayList<GraphVertex> vertices = polyline.getGraphPoint();
+
+ for(int i=0; i< initVertices.size()-1; i++){
+ GraphVertex v = initVertices.get(i);
+ GraphVertex nextV = initVertices.get(i+1);
+ for(GraphVertex cand:vertices){
+ float distance = VectorUtil.computeLength(v.getCoord(), cand.getCoord());
+ if(distance < minDistance){
+ for (GraphVertex vert:vertices){
+ if(vert == v || vert == nextV || vert == cand)
+ continue;
+ inValid = VectorUtil.inCircle(v.getPoint(), nextV.getPoint(),
+ cand.getPoint(), vert.getPoint());
+ if(inValid){
+ break;
+ }
+ }
+ if(!inValid){
+ closestV = cand;
+ minDistance = distance;
+ closestE = v.findBoundEdge();
+ }
+ }
+
+ }
+ }
+
+ if(closestE != null){
+ root = closestE;
+ }
+
+ return closestV;
+ }
+
+ private HEdge findClosestValidNeighbor(HEdge edge, boolean delaunay) {
+ HEdge next = root.getNext();
+
+ if(!VectorUtil.ccw(root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(),
+ edge.getGraphPoint().getPoint())){
+ return null;
+ }
+
+ HEdge candEdge = edge;
+ boolean inValid = false;
+
+ if(delaunay){
+ Vertex cand = candEdge.getGraphPoint().getPoint();
+ HEdge e = candEdge.getNext();
+ while (e != candEdge){
+ if(e.getGraphPoint() == root.getGraphPoint()
+ || e.getGraphPoint() == next.getGraphPoint()
+ || e.getGraphPoint().getPoint() == cand){
+ e = e.getNext();
+ continue;
+ }
+ inValid = VectorUtil.inCircle(root.getGraphPoint().getPoint(), next.getGraphPoint().getPoint(),
+ cand, e.getGraphPoint().getPoint());
+ if(inValid){
+ break;
+ }
+ e = e.getNext();
+ }
+ }
+ if(!inValid){
+ return candEdge;
+ }
+ return null;
+ }
+
+ /** Create a triangle from the param vertices only if
+ * the triangle is valid. IE not outside region.
+ * @param v1 vertex 1
+ * @param v2 vertex 2
+ * @param v3 vertex 3
+ * @param root and edge of this triangle
+ * @return the triangle iff it satisfies, null otherwise
+ */
+ private Triangle createTriangle(Vertex v1, Vertex v2, Vertex v3, HEdge rootT){
+ Triangle t = new Triangle(v1, v2, v3);
+ t.setVerticesBoundary(checkVerticesBoundary(rootT));
+ return t;
+ }
+
+ private boolean[] checkVerticesBoundary(HEdge rootT) {
+ boolean[] boundary = new boolean[3];
+ HEdge e1 = rootT;
+ HEdge e2 = rootT.getNext();
+ HEdge e3 = rootT.getNext().getNext();
+
+ if(e1.getGraphPoint().isBoundaryContained()){
+ boundary[0] = true;
+ }
+ if(e2.getGraphPoint().isBoundaryContained()){
+ boundary[1] = true;
+ }
+ if(e3.getGraphPoint().isBoundaryContained()){
+ boundary[2] = true;
+ }
+ return boundary;
+ }
+
+
+ /** Check if vertex inside the Loop
+ * @param vertex the Vertex
+ * @return true if the vertex is inside, false otherwise
+ */
+ public boolean checkInside(Vertex vertex) {
+ if(!box.contains(vertex.getX(), vertex.getY(), vertex.getZ())){
+ return false;
+ }
+
+ float[] center = box.getCenter();
+
+ int hits = 0;
+ HEdge current = root;
+ HEdge next = root.getNext();
+ while(next!= root){
+ if(current.getType() == HEdge.INNER || next.getType() == HEdge.INNER){
+ current = next;
+ next = current.getNext();
+ continue;
+ }
+ Vertex vert1 = current.getGraphPoint().getPoint();
+ Vertex vert2 = next.getGraphPoint().getPoint();
+
+ /** The ray is P0+s*D0, where P0 is the ray origin, D0 is a direction vector and s >= 0.
+ * The segment is P1+t*D1, where P1 and P1+D1 are the endpoints, and 0 <= t <= 1.
+ * perp(x,y) = (y,-x).
+ * if Dot(perp(D1),D0) is not zero,
+ * s = Dot(perp(D1),P1-P0)/Dot(perp(D1),D0)
+ * t = Dot(perp(D0),P1-P0)/Dot(perp(D1),D0)
+ */
+
+ float[] d0 = new float[]{center[0] - vertex.getX(), center[1]-vertex.getY(),
+ center[2]-vertex.getZ()};
+ float[] d1 = {vert2.getX() - vert1.getX(), vert2.getY() - vert1.getY(),
+ vert2.getZ() - vert1.getZ()};
+
+ float[] prep_d1 = {d1[1],-1*d1[0], d1[2]};
+ float[] prep_d0 = {d0[1],-1*d0[0], d0[2]};
+
+ float[] p0p1 = new float[]{vert1.getX() - vertex.getX(), vert1.getY() - vertex.getY(),
+ vert1.getZ() - vertex.getZ()};
+
+ float dotD1D0 = VectorUtil.dot(prep_d1, d0);
+ if(dotD1D0 == 0){
+ /** ray parallel to segment */
+ current = next;
+ next = current.getNext();
+ continue;
+ }
+
+ float s = VectorUtil.dot(prep_d1,p0p1)/dotD1D0;
+ float t = VectorUtil.dot(prep_d0,p0p1)/dotD1D0;
+
+ if(s >= 0 && t >= 0 && t<= 1){
+ hits++;
+ }
+ current = next;
+ next = current.getNext();
+ }
+
+ if(hits % 2 != 0){
+ /** check if hit count is even */
+ return true;
+ }
+ return false;
+ }
+
+ public int computeLoopSize(){
+ int size = 0;
+ HEdge e = root;
+ do{
+ size++;
+ e = e.getNext();
+ }while(e != root);
+ return size;
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java
index 36ba57244..4d1880064 100644
--- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java
+++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java
@@ -38,124 +38,124 @@ import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.math.Quaternion;
public class GlyphShape {
-
- private Quaternion quat= null;
- private int numVertices = 0;
- private OutlineShape shape = null;
-
- /** Create a new Glyph shape
- * based on Parametric curve control polyline
- */
- public GlyphShape(Vertex.Factory<? extends Vertex> factory){
- shape = new OutlineShape(factory);
- }
-
- /** Create a GlyphShape from a font Path Iterator
- * @param pathIterator the path iterator
- *
- * @see PathIterator
- */
- public GlyphShape(Vertex.Factory<? extends Vertex> factory, PathIterator pathIterator){
- this(factory);
-
- if(null != pathIterator){
- while(!pathIterator.isDone()){
- float[] coords = new float[6];
- int segmentType = pathIterator.currentSegment(coords);
- addOutlineVerticesFromGlyphVector(coords, segmentType);
+
+ private Quaternion quat= null;
+ private int numVertices = 0;
+ private OutlineShape shape = null;
+
+ /** Create a new Glyph shape
+ * based on Parametric curve control polyline
+ */
+ public GlyphShape(Vertex.Factory<? extends Vertex> factory){
+ shape = new OutlineShape(factory);
+ }
+
+ /** Create a GlyphShape from a font Path Iterator
+ * @param pathIterator the path iterator
+ *
+ * @see PathIterator
+ */
+ public GlyphShape(Vertex.Factory<? extends Vertex> factory, PathIterator pathIterator){
+ this(factory);
+
+ if(null != pathIterator){
+ while(!pathIterator.isDone()){
+ float[] coords = new float[6];
+ int segmentType = pathIterator.currentSegment(coords);
+ addOutlineVerticesFromGlyphVector(coords, segmentType);
- pathIterator.next();
- }
- }
- shape.transformOutlines(OutlineShape.QUADRATIC_NURBS);
- }
-
- public final Vertex.Factory<? extends Vertex> vertexFactory() { return shape.vertexFactory(); }
-
- private void addVertexToLastOutline(Vertex vertex){
- shape.addVertex(vertex);
- }
-
- private void addOutlineVerticesFromGlyphVector(float[] coords, int segmentType){
- if(segmentType == PathIterator.SEG_MOVETO){
- if(!shape.getLastOutline().isEmpty()){
- shape.addEmptyOutline();
- }
- Vertex vert = vertexFactory().create(coords[0],coords[1]);
- vert.setOnCurve(true);
- addVertexToLastOutline(vert);
-
- numVertices++;
- }
- else if(segmentType == PathIterator.SEG_LINETO){
- Vertex vert1 = vertexFactory().create(coords[0],coords[1]);
- vert1.setOnCurve(true);
- addVertexToLastOutline(vert1);
-
- numVertices++;
- }
- else if(segmentType == PathIterator.SEG_QUADTO){
- Vertex vert1 = vertexFactory().create(coords[0],coords[1]);
- vert1.setOnCurve(false);
- addVertexToLastOutline(vert1);
+ pathIterator.next();
+ }
+ }
+ shape.transformOutlines(OutlineShape.QUADRATIC_NURBS);
+ }
+
+ public final Vertex.Factory<? extends Vertex> vertexFactory() { return shape.vertexFactory(); }
+
+ private void addVertexToLastOutline(Vertex vertex){
+ shape.addVertex(vertex);
+ }
+
+ private void addOutlineVerticesFromGlyphVector(float[] coords, int segmentType){
+ if(segmentType == PathIterator.SEG_MOVETO){
+ if(!shape.getLastOutline().isEmpty()){
+ shape.addEmptyOutline();
+ }
+ Vertex vert = vertexFactory().create(coords[0],coords[1]);
+ vert.setOnCurve(true);
+ addVertexToLastOutline(vert);
+
+ numVertices++;
+ }
+ else if(segmentType == PathIterator.SEG_LINETO){
+ Vertex vert1 = vertexFactory().create(coords[0],coords[1]);
+ vert1.setOnCurve(true);
+ addVertexToLastOutline(vert1);
+
+ numVertices++;
+ }
+ else if(segmentType == PathIterator.SEG_QUADTO){
+ Vertex vert1 = vertexFactory().create(coords[0],coords[1]);
+ vert1.setOnCurve(false);
+ addVertexToLastOutline(vert1);
- Vertex vert2 = vertexFactory().create(coords[2],coords[3]);
- vert2.setOnCurve(true);
- addVertexToLastOutline(vert2);
-
- numVertices+=2;
- }
- else if(segmentType == PathIterator.SEG_CUBICTO){
- Vertex vert1 = vertexFactory().create(coords[0],coords[1]);
- vert1.setOnCurve(false);
- addVertexToLastOutline(vert1);
+ Vertex vert2 = vertexFactory().create(coords[2],coords[3]);
+ vert2.setOnCurve(true);
+ addVertexToLastOutline(vert2);
+
+ numVertices+=2;
+ }
+ else if(segmentType == PathIterator.SEG_CUBICTO){
+ Vertex vert1 = vertexFactory().create(coords[0],coords[1]);
+ vert1.setOnCurve(false);
+ addVertexToLastOutline(vert1);
- Vertex vert2 = vertexFactory().create(coords[2],coords[3]);
- vert2.setOnCurve(false);
- addVertexToLastOutline(vert2);
+ Vertex vert2 = vertexFactory().create(coords[2],coords[3]);
+ vert2.setOnCurve(false);
+ addVertexToLastOutline(vert2);
- Vertex vert3 = vertexFactory().create(coords[4],coords[5]);
- vert3.setOnCurve(true);
- addVertexToLastOutline(vert3);
-
- numVertices+=3;
- }
- else if(segmentType == PathIterator.SEG_CLOSE){
- shape.closeLastOutline();
- }
- }
-
- public int getNumVertices() {
- return numVertices;
- }
-
- /** Get the rotational Quaternion attached to this Shape
- * @return the Quaternion Object
- */
- public Quaternion getQuat() {
- return quat;
- }
-
- /** Set the Quaternion that shall defien the rotation
- * of this shape.
- * @param quat
- */
- public void setQuat(Quaternion quat) {
- this.quat = quat;
- }
-
- /** Triangluate the glyph shape
- * @param sharpness sharpness of the curved regions default = 0.5
- * @return ArrayList of triangles which define this shape
- */
- public ArrayList<Triangle> triangulate(float sharpness){
- return shape.triangulate(sharpness);
- }
+ Vertex vert3 = vertexFactory().create(coords[4],coords[5]);
+ vert3.setOnCurve(true);
+ addVertexToLastOutline(vert3);
+
+ numVertices+=3;
+ }
+ else if(segmentType == PathIterator.SEG_CLOSE){
+ shape.closeLastOutline();
+ }
+ }
+
+ public int getNumVertices() {
+ return numVertices;
+ }
+
+ /** Get the rotational Quaternion attached to this Shape
+ * @return the Quaternion Object
+ */
+ public Quaternion getQuat() {
+ return quat;
+ }
+
+ /** Set the Quaternion that shall defien the rotation
+ * of this shape.
+ * @param quat
+ */
+ public void setQuat(Quaternion quat) {
+ this.quat = quat;
+ }
+
+ /** Triangluate the glyph shape
+ * @param sharpness sharpness of the curved regions default = 0.5
+ * @return ArrayList of triangles which define this shape
+ */
+ public ArrayList<Triangle> triangulate(float sharpness){
+ return shape.triangulate(sharpness);
+ }
- /** Get the list of Vertices of this Object
- * @return arrayList of Vertices
- */
- public ArrayList<Vertex> getVertices(){
- return shape.getVertices();
- }
+ /** Get the list of Vertices of this Object
+ * @return arrayList of Vertices
+ */
+ public ArrayList<Vertex> getVertices(){
+ return shape.getVertices();
+ }
}
diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
index 7c7bb816f..705613447 100644
--- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
+++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
@@ -47,122 +47,122 @@ import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderState;
public class GlyphString {
- private final Vertex.Factory<? extends Vertex> pointFactory;
- private ArrayList<GlyphShape> glyphs = new ArrayList<GlyphShape>();
- private String str = "";
- private String fontname = "";
- private Region region;
-
- private SVertex origin = new SVertex();
+ private final Vertex.Factory<? extends Vertex> pointFactory;
+ private ArrayList<GlyphShape> glyphs = new ArrayList<GlyphShape>();
+ private String str = "";
+ private String fontname = "";
+ private Region region;
+
+ private SVertex origin = new SVertex();
- /** Create a new GlyphString object
- * @param fontname the name of the font that this String is
- * associated with
- * @param str the string object
- */
- public GlyphString(Vertex.Factory<? extends Vertex> factory, String fontname, String str){
- pointFactory = factory;
- this.fontname = fontname;
- this.str = str;
- }
-
- public final Vertex.Factory<? extends Vertex> pointFactory() { return pointFactory; }
-
- public void addGlyphShape(GlyphShape glyph){
- glyphs.add(glyph);
- }
- public String getString(){
- return str;
- }
+ /** Create a new GlyphString object
+ * @param fontname the name of the font that this String is
+ * associated with
+ * @param str the string object
+ */
+ public GlyphString(Vertex.Factory<? extends Vertex> factory, String fontname, String str){
+ pointFactory = factory;
+ this.fontname = fontname;
+ this.str = str;
+ }
+
+ public final Vertex.Factory<? extends Vertex> pointFactory() { return pointFactory; }
+
+ public void addGlyphShape(GlyphShape glyph){
+ glyphs.add(glyph);
+ }
+ public String getString(){
+ return str;
+ }
- /** Creates the Curve based Glyphs from a Font
- * @param paths a list of FontPath2D objects that define the outline
- * @param affineTransform a global affine transformation applied to the paths.
- */
- public void createfromFontPath(Path2D[] paths, AffineTransform affineTransform){
- final int numGlyps = paths.length;
- for (int index=0;index<numGlyps;index++){
- if(paths[index] == null){
- continue;
- }
- PathIterator iterator = paths[index].iterator(affineTransform);
- GlyphShape glyphShape = new GlyphShape(pointFactory, iterator);
-
- if(glyphShape.getNumVertices() < 3) {
- continue;
- }
- addGlyphShape(glyphShape);
- }
- }
-
- private ArrayList<Triangle> initializeTriangles(float sharpness){
- ArrayList<Triangle> triangles = new ArrayList<Triangle>();
- for(GlyphShape glyph:glyphs){
- ArrayList<Triangle> tris = glyph.triangulate(sharpness);
- triangles.addAll(tris);
- }
- return triangles;
- }
-
- /** Generate a OGL Region to represent this Object.
- * @param context the GLContext which the region is defined by.
- * @param shaprness the curvature sharpness of the object.
- * @param st shader state
- */
- public void generateRegion(GLContext context, float shaprness, ShaderState st, int type){
- region = RegionFactory.create(context, st, type);
- region.setFlipped(true);
-
- ArrayList<Triangle> tris = initializeTriangles(shaprness);
- region.addTriangles(tris);
-
- int numVertices = region.getNumVertices();
- for(GlyphShape glyph:glyphs){
- ArrayList<Vertex> gVertices = glyph.getVertices();
- for(Vertex vert:gVertices){
- vert.setId(numVertices++);
- }
- region.addVertices(gVertices);
- }
-
- /** initialize the region */
- region.update();
- }
-
- /** Generate a Hashcode for this object
- * @return a string defining the hashcode
- */
- public String getTextHashCode(){
- return "" + fontname.hashCode() + str.hashCode();
- }
+ /** Creates the Curve based Glyphs from a Font
+ * @param paths a list of FontPath2D objects that define the outline
+ * @param affineTransform a global affine transformation applied to the paths.
+ */
+ public void createfromFontPath(Path2D[] paths, AffineTransform affineTransform){
+ final int numGlyps = paths.length;
+ for (int index=0;index<numGlyps;index++){
+ if(paths[index] == null){
+ continue;
+ }
+ PathIterator iterator = paths[index].iterator(affineTransform);
+ GlyphShape glyphShape = new GlyphShape(pointFactory, iterator);
+
+ if(glyphShape.getNumVertices() < 3) {
+ continue;
+ }
+ addGlyphShape(glyphShape);
+ }
+ }
+
+ private ArrayList<Triangle> initializeTriangles(float sharpness){
+ ArrayList<Triangle> triangles = new ArrayList<Triangle>();
+ for(GlyphShape glyph:glyphs){
+ ArrayList<Triangle> tris = glyph.triangulate(sharpness);
+ triangles.addAll(tris);
+ }
+ return triangles;
+ }
+
+ /** Generate a OGL Region to represent this Object.
+ * @param context the GLContext which the region is defined by.
+ * @param shaprness the curvature sharpness of the object.
+ * @param st shader state
+ */
+ public void generateRegion(GLContext context, float shaprness, ShaderState st, int type){
+ region = RegionFactory.create(context, st, type);
+ region.setFlipped(true);
+
+ ArrayList<Triangle> tris = initializeTriangles(shaprness);
+ region.addTriangles(tris);
+
+ int numVertices = region.getNumVertices();
+ for(GlyphShape glyph:glyphs){
+ ArrayList<Vertex> gVertices = glyph.getVertices();
+ for(Vertex vert:gVertices){
+ vert.setId(numVertices++);
+ }
+ region.addVertices(gVertices);
+ }
+
+ /** initialize the region */
+ region.update();
+ }
+
+ /** Generate a Hashcode for this object
+ * @return a string defining the hashcode
+ */
+ public String getTextHashCode(){
+ return "" + fontname.hashCode() + str.hashCode();
+ }
- /** Render the Object based using the associated Region
- * previously generated.
- */
- public void renderString3D() {
- region.render(null, 0, 0, 0);
- }
- /** Render the Object based using the associated Region
- * previously generated.
- */
- public void renderString3D(PMVMatrix matrix, int vp_width, int vp_height, int size) {
- region.render(matrix, vp_width, vp_height, size);
- }
-
- /** Get the Origion of this GlyphString
- * @return
- */
- public Vertex getOrigin() {
- return origin;
- }
+ /** Render the Object based using the associated Region
+ * previously generated.
+ */
+ public void renderString3D() {
+ region.render(null, 0, 0, 0);
+ }
+ /** Render the Object based using the associated Region
+ * previously generated.
+ */
+ public void renderString3D(PMVMatrix matrix, int vp_width, int vp_height, int size) {
+ region.render(matrix, vp_width, vp_height, size);
+ }
+
+ /** Get the Origion of this GlyphString
+ * @return
+ */
+ public Vertex getOrigin() {
+ return origin;
+ }
- /** Destroy the associated OGL objects
- */
- public void destroy(){
- region.destroy();
- }
-
- public AABBox getBounds(){
- return region.getBounds();
- }
+ /** Destroy the associated OGL objects
+ */
+ public void destroy(){
+ region.destroy();
+ }
+
+ public AABBox getBounds(){
+ return region.getBounds();
+ }
}