diff options
author | Sven Gothel <[email protected]> | 2011-04-08 21:35:34 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-04-08 21:35:34 +0200 |
commit | 324b85b0cc688f85a91e84b0b6d6a0378a79bea3 (patch) | |
tree | a5acbe1630d879e80ec66c6c3a72623431c57632 /src/jogl/classes/jogamp/graph | |
parent | e104e42ba9ecda8c4094bf4b183105a6ab719da5 (diff) |
Fix TAB: Replace all TAB with 4 spaces
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
25 files changed, 1540 insertions, 1540 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(); + } } diff --git a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java index a9ab902a9..bead9a5d2 100644 --- a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java @@ -74,7 +74,7 @@ public class JavaFontLoader implements FontSet { return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular } - public Font get(int family, int style) { + public Font get(int family, int style) { Font font = (Font)fontMap.get( ( family << 8 ) | style ); if (font != null) { return font; @@ -121,7 +121,7 @@ public class JavaFontLoader implements FontSet { return font; } - + Font abspath(String fname, int family, int style) { final String err = "Problem loading font "+fname+", file "+javaFontPath+fname ; diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java index 3614add5c..17db08801 100644 --- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java @@ -76,8 +76,8 @@ public class UbuntuFontLoader implements FontSet { return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular } - public Font get(int family, int style) - { + public Font get(int family, int style) + { Font font = (Font)fontMap.get( ( family << 8 ) | style ); if (font != null) { return font; @@ -119,7 +119,7 @@ public class UbuntuFontLoader implements FontSet { return font; } - + Font abspath(String fname, int family, int style) { final String err = "Problem loading font "+fname+", stream "+relPath+fname; try { @@ -136,5 +136,5 @@ public class UbuntuFontLoader implements FontSet { } catch(IOException ioe) { throw new GLException(err, ioe); } - } + } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index f702b981f..6292c8826 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -43,97 +43,97 @@ import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.geom.AABBox; class TypecastFont implements FontInt { - static final boolean DEBUG = false; - - final OTFontCollection fontset; - final OTFont font; + static final boolean DEBUG = false; + + final OTFontCollection fontset; + final OTFont font; TypecastHMetrics metrics; final CmapFormat cmapFormat; - int cmapentries; - - // FIXME: Add cache size to limit memory usage ?? + int cmapentries; + + // FIXME: Add cache size to limit memory usage ?? IntObjectHashMap char2Glyph; public TypecastFont(OTFontCollection fontset) { - this.fontset = fontset; + this.fontset = fontset; this.font = fontset.getFont(0); // FIXME: Generic attempt to find the best CmapTable, // which is assumed to be the one with the most entries (stupid 'eh?) - CmapTable cmapTable = font.getCmapTable(); + CmapTable cmapTable = font.getCmapTable(); CmapFormat[] _cmapFormatP = { null, null, null, null }; int platform = -1; int platformLength = -1; int encoding = -1; - for(int i=0; i<cmapTable.getNumTables(); i++) { - CmapIndexEntry cmapIdxEntry = cmapTable.getCmapIndexEntry(i); - int pidx = cmapIdxEntry.getPlatformId(); - CmapFormat cf = cmapIdxEntry.getFormat(); + for(int i=0; i<cmapTable.getNumTables(); i++) { + CmapIndexEntry cmapIdxEntry = cmapTable.getCmapIndexEntry(i); + int pidx = cmapIdxEntry.getPlatformId(); + CmapFormat cf = cmapIdxEntry.getFormat(); if(DEBUG) { System.err.println("CmapFormat["+i+"]: platform " + pidx + ", encoding "+cmapIdxEntry.getEncodingId() + ": "+cf); } - if( _cmapFormatP[pidx] == null || - _cmapFormatP[pidx].getLength() < cf.getLength() ) { - _cmapFormatP[pidx] = cf; - if( cf.getLength() > platformLength ) { - platformLength = cf.getLength() ; - platform = pidx; - encoding = cmapIdxEntry.getEncodingId(); - } - } - } + if( _cmapFormatP[pidx] == null || + _cmapFormatP[pidx].getLength() < cf.getLength() ) { + _cmapFormatP[pidx] = cf; + if( cf.getLength() > platformLength ) { + platformLength = cf.getLength() ; + platform = pidx; + encoding = cmapIdxEntry.getEncodingId(); + } + } + } if(0 <= platform) { cmapFormat = _cmapFormatP[platform]; if(DEBUG) { System.err.println("Selected CmapFormat: platform " + platform + ", encoding "+encoding + ": "+cmapFormat); } - } else { - CmapFormat _cmapFormat = null; - /*if(null == _cmapFormat) { + } else { + CmapFormat _cmapFormat = null; + /*if(null == _cmapFormat) { platform = ID.platformMacintosh; encoding = ID.encodingASCII; - _cmapFormat = cmapTable.getCmapFormat(platform, encoding); - } */ - if(null == _cmapFormat) { - // default unicode - platform = ID.platformMicrosoft; - encoding = ID.encodingUnicode; - _cmapFormat = cmapTable.getCmapFormat((short)platform, (short)encoding); - } - if(null == _cmapFormat) { - // maybe a symbol font ? + _cmapFormat = cmapTable.getCmapFormat(platform, encoding); + } */ + if(null == _cmapFormat) { + // default unicode + platform = ID.platformMicrosoft; + encoding = ID.encodingUnicode; + _cmapFormat = cmapTable.getCmapFormat((short)platform, (short)encoding); + } + if(null == _cmapFormat) { + // maybe a symbol font ? platform = ID.platformMicrosoft; encoding = ID.encodingSymbol; _cmapFormat = cmapTable.getCmapFormat((short)platform, (short)encoding); - } - if(null == _cmapFormat) { - throw new RuntimeException("Cannot find a suitable cmap table for font "+font); - } + } + if(null == _cmapFormat) { + throw new RuntimeException("Cannot find a suitable cmap table for font "+font); + } cmapFormat = _cmapFormat; if(DEBUG) { System.err.println("Selected CmapFormat (2): platform " + platform + ", encoding "+encoding + ": "+cmapFormat); } } - cmapentries = 0; + cmapentries = 0; for (int i = 0; i < cmapFormat.getRangeCount(); ++i) { CmapFormat.Range range = cmapFormat.getRange(i); cmapentries += range.getEndCode() - range.getStartCode() + 1; // end included - } + } if(DEBUG) { - System.err.println("num glyphs: "+font.getNumGlyphs()); - System.err.println("num cmap entries: "+cmapentries); - System.err.println("num cmap ranges: "+cmapFormat.getRangeCount()); + System.err.println("num glyphs: "+font.getNumGlyphs()); + System.err.println("num cmap entries: "+cmapentries); + System.err.println("num cmap ranges: "+cmapFormat.getRangeCount()); for (int i = 0; i < cmapFormat.getRangeCount(); ++i) { CmapFormat.Range range = cmapFormat.getRange(i); for (int j = range.getStartCode(); j <= range.getEndCode(); ++j) { - final int code = cmapFormat.mapCharCode(j); - if(code < 15) { - System.err.println(" char: " + (int)j + " ( " + (char)j +" ) -> " + code); - } + final int code = cmapFormat.mapCharCode(j); + if(code < 15) { + System.err.println(" char: " + (int)j + " ( " + (char)j +" ) -> " + code); + } } } } @@ -155,9 +155,9 @@ class TypecastFont implements FontInt { } public Glyph getGlyph(char symbol) { - TypecastGlyph result = (TypecastGlyph) char2Glyph.get(symbol); + TypecastGlyph result = (TypecastGlyph) char2Glyph.get(symbol); if (null == result) { - // final short code = (short) char2Code.get(symbol); + // final short code = (short) char2Code.get(symbol); short code = (short) cmapFormat.mapCharCode(symbol); if(0 == code && 0 != symbol) { // reserved special glyph IDs by convention @@ -168,19 +168,19 @@ class TypecastFont implements FontInt { } } - jogamp.graph.font.typecast.ot.OTGlyph glyph = font.getGlyph(code); - if(null == glyph) { - glyph = font.getGlyph(Glyph.ID_UNKNOWN); - } - if(null == glyph) { - throw new RuntimeException("Could not retrieve glyph for symbol: <"+symbol+"> "+(int)symbol+" -> glyph id "+code); - } - Path2D path = TypecastRenderer.buildPath(glyph); - result = new TypecastGlyph(this, symbol, code, glyph.getBBox(), glyph.getAdvanceWidth(), path); - if(DEBUG) { - System.err.println("New glyph: " + (int)symbol + " ( " + (char)symbol +" ) -> " + code + ", contours " + glyph.getPointCount() + ": " + path); - } - final HdmxTable hdmx = font.getHdmxTable(); + jogamp.graph.font.typecast.ot.OTGlyph glyph = font.getGlyph(code); + if(null == glyph) { + glyph = font.getGlyph(Glyph.ID_UNKNOWN); + } + if(null == glyph) { + throw new RuntimeException("Could not retrieve glyph for symbol: <"+symbol+"> "+(int)symbol+" -> glyph id "+code); + } + Path2D path = TypecastRenderer.buildPath(glyph); + result = new TypecastGlyph(this, symbol, code, glyph.getBBox(), glyph.getAdvanceWidth(), path); + if(DEBUG) { + System.err.println("New glyph: " + (int)symbol + " ( " + (char)symbol +" ) -> " + code + ", contours " + glyph.getPointCount() + ": " + path); + } + final HdmxTable hdmx = font.getHdmxTable(); if (null!= result && null != hdmx) { /*if(DEBUG) { System.err.println("hdmx "+hdmx); @@ -193,14 +193,14 @@ class TypecastFont implements FontInt { System.err.println("hdmx advance : pixelsize = "+dr.getWidth(code)+" : "+ dr.getPixelSize()); } } - } - char2Glyph.put(symbol, result); + } + char2Glyph.put(symbol, result); } return result; } public void getOutline(String string, float pixelSize, AffineTransform transform, Path2D[] result) { - TypecastRenderer.getOutline(this, string, pixelSize, transform, result); + TypecastRenderer.getOutline(this, string, pixelSize, transform, result); } public float getStringWidth(String string, float pixelSize) { @@ -217,7 +217,7 @@ class TypecastFont implements FontInt { } } - return (int)(width + 0.5f); + return (int)(width + 0.5f); } public float getStringHeight(String string, float pixelSize) { @@ -233,7 +233,7 @@ class TypecastFont implements FontInt { height = (int)Math.ceil(Math.max(bbox.getHeight(), height)); } } - return height; + return height; } public AABBox getStringBounds(CharSequence string, float pixelSize) { @@ -263,11 +263,11 @@ class TypecastFont implements FontInt { totalHeight -= advanceY; totalWidth = Math.max(curLineWidth, totalWidth); } - return new AABBox(0, 0, 0, totalWidth, totalHeight,0); + return new AABBox(0, 0, 0, totalWidth, totalHeight,0); } final public int getNumGlyphs() { - return font.getNumGlyphs(); + return font.getNumGlyphs(); } public boolean isPrintableChar( char c ) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java index 88d865f9c..f20b7d1e7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java @@ -42,7 +42,7 @@ public class TypecastGlyph implements FontInt.Glyph { final Font font; final float advance; HashMap<Float, Float> size2advance = new HashMap<Float, Float>(); - + public Advance(Font font, float advance) { this.font = font; @@ -86,12 +86,12 @@ public class TypecastGlyph implements FontInt.Glyph { "\n advances: \n"+size2advance; } } - + public class Metrics { - AABBox bbox; + AABBox bbox; Advance advance; - + public Metrics(Font font, AABBox bbox, float advance) { this.bbox = bbox; @@ -128,13 +128,13 @@ public class TypecastGlyph implements FontInt.Glyph { "\n bbox: "+this.bbox+ this.advance; } - } + } public static final short INVALID_ID = (short)((1 << 16) - 1); public static final short MAX_ID = (short)((1 << 16) - 2); private final Font font; - + char symbol; short id; int advance; @@ -143,15 +143,15 @@ public class TypecastGlyph implements FontInt.Glyph { protected Path2D path; // in EM units protected Path2D pathSized; protected float numberSized; - + protected TypecastGlyph(Font font, char symbol) { - this.font = font; + this.font = font; this.symbol = symbol; } protected TypecastGlyph(Font font, - char symbol, short id, AABBox bbox, int advance, Path2D path) { - this.font = font; + char symbol, short id, AABBox bbox, int advance, Path2D path) { + this.font = font; this.symbol = symbol; this.advance = advance; @@ -161,7 +161,7 @@ public class TypecastGlyph implements FontInt.Glyph { this.pathSized = null; this.numberSized = 0.0f; } - + void init(short id, AABBox bbox, int advance) { this.id = id; this.advance = advance; @@ -176,11 +176,11 @@ public class TypecastGlyph implements FontInt.Glyph { public Font getFont() { return this.font; } - + public char getSymbol() { return this.symbol; } - + AABBox getBBoxUnsized() { return this.metrics.getBBox(); } @@ -192,22 +192,22 @@ public class TypecastGlyph implements FontInt.Glyph { public Metrics getMetrics() { return this.metrics; } - + public short getID() { return this.id; } - + public float getScale(float pixelSize) { return this.metrics.getScale(pixelSize); } - + public AABBox getBBox(float pixelSize) { final float size = getScale(pixelSize); AABBox newBox = getBBox().clone(); newBox.scale(size); return newBox; } - + protected void addAdvance(float advance, float size) { this.metrics.addAdvance(advance, size); } @@ -217,9 +217,9 @@ public class TypecastGlyph implements FontInt.Glyph { } public Path2D getPath() { - return this.path; + return this.path; } - + public Path2D getPath(float pixelSize) { final float size = getScale(pixelSize); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java index a69948006..0dd7a6178 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java @@ -34,22 +34,22 @@ import com.jogamp.graph.font.Font.Metrics; import com.jogamp.graph.geom.AABBox; class TypecastHMetrics implements Metrics { - private final TypecastFont fontImpl; - - // HeadTable + private final TypecastFont fontImpl; + + // HeadTable private final HeadTable headTable; - private final float unitsPerEM_Inv; - private final AABBox bbox; - // HheaTable - private final HheaTable hheaTable; + private final float unitsPerEM_Inv; + private final AABBox bbox; + // HheaTable + private final HheaTable hheaTable; // VheaTable (for horizontal fonts) // private final VheaTable vheaTable; - - public TypecastHMetrics(TypecastFont fontImpl) { - this.fontImpl = fontImpl; - headTable = this.fontImpl.font.getHeadTable(); - hheaTable = this.fontImpl.font.getHheaTable(); - // vheaTable = this.fontImpl.font.getVheaTable(); + + public TypecastHMetrics(TypecastFont fontImpl) { + this.fontImpl = fontImpl; + headTable = this.fontImpl.font.getHeadTable(); + hheaTable = this.fontImpl.font.getHheaTable(); + // vheaTable = this.fontImpl.font.getVheaTable(); unitsPerEM_Inv = 1.0f / ( (float) headTable.getUnitsPerEm() ); int maxWidth = headTable.getXMax() - headTable.getXMin(); @@ -59,8 +59,8 @@ class TypecastHMetrics implements Metrics { float highx = lowx + maxWidth; float highy = lowy + maxHeight; bbox = new AABBox(lowx, lowy, 0, highx, highy, 0); // invert - } - + } + public final float getAscent(float pixelSize) { return getScale(pixelSize) * -hheaTable.getAscender(); // invert } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index 9a81d78d3..ab5e673db 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -40,48 +40,48 @@ import com.jogamp.graph.font.Font; */ public class TypecastRenderer { - public static void getOutline(TypecastFont font, - String string, float pixelSize, AffineTransform transform, Path2D[] p) - { - if (string == null) { - return; - } - Font.Metrics metrics = font.getMetrics(); - float advanceTotal = 0; - float lineGap = metrics.getLineGap(pixelSize) ; - float ascent = metrics.getAscent(pixelSize) ; - float descent = metrics.getDescent(pixelSize) ; - if (transform == null) { - transform = new AffineTransform(); - } - AffineTransform t = new AffineTransform(); + public static void getOutline(TypecastFont font, + String string, float pixelSize, AffineTransform transform, Path2D[] p) + { + if (string == null) { + return; + } + Font.Metrics metrics = font.getMetrics(); + float advanceTotal = 0; + float lineGap = metrics.getLineGap(pixelSize) ; + float ascent = metrics.getAscent(pixelSize) ; + float descent = metrics.getDescent(pixelSize) ; + if (transform == null) { + transform = new AffineTransform(); + } + AffineTransform t = new AffineTransform(); - float advanceY = lineGap - descent + ascent; - float y = 0; - for (int i=0; i<string.length(); i++) - { - p[i] = new Path2D(); - p[i].reset(); - t.setTransform(transform); - char character = string.charAt(i); - if (character == '\n') { - y -= advanceY; - advanceTotal = 0; - continue; - } else if (character == ' ') { - advanceTotal += font.font.getHmtxTable().getAdvanceWidth(TypecastGlyph.ID_SPACE) * metrics.getScale(pixelSize); + float advanceY = lineGap - descent + ascent; + float y = 0; + for (int i=0; i<string.length(); i++) + { + p[i] = new Path2D(); + p[i].reset(); + t.setTransform(transform); + char character = string.charAt(i); + if (character == '\n') { + y -= advanceY; + advanceTotal = 0; + continue; + } else if (character == ' ') { + advanceTotal += font.font.getHmtxTable().getAdvanceWidth(TypecastGlyph.ID_SPACE) * metrics.getScale(pixelSize); continue; } - TypecastGlyph glyph = (TypecastGlyph) font.getGlyph(character); - Path2D gp = glyph.getPath(); - float scale = metrics.getScale(pixelSize); - t.translate(advanceTotal, y); - t.scale(scale, scale); - p[i].append(gp.iterator(t), false); - advanceTotal += glyph.getAdvance(pixelSize, true); - } - } - + TypecastGlyph glyph = (TypecastGlyph) font.getGlyph(character); + Path2D gp = glyph.getPath(); + float scale = metrics.getScale(pixelSize); + t.translate(advanceTotal, y); + t.scale(scale, scale); + p[i].append(gp.iterator(t), false); + advanceTotal += glyph.getAdvance(pixelSize, true); + } + } + /** * Build a {@link com.jogamp.graph.geom.Path2D Path2D} from a * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}. This glyph path can then @@ -116,44 +116,44 @@ public class TypecastRenderer { Point point = glyph.getPoint(startIndex + offset%count); Point point_plus1 = glyph.getPoint(startIndex + (offset+1)%count); Point point_plus2 = glyph.getPoint(startIndex + (offset+2)%count); - if(offset == 0) + if(offset == 0) { gp.moveTo(point.x, -point.y); } - - if (point.onCurve) { - if (point_plus1.onCurve) { - // s = new Line2D.Float(point.x, -point.y, point_plus1.x, -point_plus1.y); - gp.lineTo( point_plus1.x, -point_plus1.y ); - offset++; - } else { - if (point_plus2.onCurve) { - // s = new QuadCurve2D.Float( point.x, -point.y, point_plus1.x, -point_plus1.y, point_plus2.x, -point_plus2.y); - gp.quadTo(point_plus1.x, -point_plus1.y, point_plus2.x, -point_plus2.y); - offset+=2; - } else { - // s = new QuadCurve2D.Float(point.x,-point.y,point_plus1.x,-point_plus1.y, - // midValue(point_plus1.x, point_plus2.x), -midValue(point_plus1.y, point_plus2.y)); - gp.quadTo(point_plus1.x, -point_plus1.y, midValue(point_plus1.x, point_plus2.x), -midValue(point_plus1.y, point_plus2.y)); - offset+=2; - } - } - } else { - if (point_plus1.onCurve) { - // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), -midValue(point_minus1.y, point.y), - // point.x, -point.y, point_plus1.x, -point_plus1.y); - //gp.curve3(point_plus1.x, -point_plus1.y, point.x, -point.y); - gp.quadTo(point.x, -point.y, point_plus1.x, -point_plus1.y); - offset++; - - } else { - // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), -midValue(point_minus1.y, point.y), point.x, -point.y, - // midValue(point.x, point_plus1.x), -midValue(point.y, point_plus1.y)); - //gp.curve3(midValue(point.x, point_plus1.x), -midValue(point.y, point_plus1.y), point.x, -point.y); - gp.quadTo(point.x, -point.y, midValue(point.x, point_plus1.x), -midValue(point.y, point_plus1.y)); - offset++; - } - } + + if (point.onCurve) { + if (point_plus1.onCurve) { + // s = new Line2D.Float(point.x, -point.y, point_plus1.x, -point_plus1.y); + gp.lineTo( point_plus1.x, -point_plus1.y ); + offset++; + } else { + if (point_plus2.onCurve) { + // s = new QuadCurve2D.Float( point.x, -point.y, point_plus1.x, -point_plus1.y, point_plus2.x, -point_plus2.y); + gp.quadTo(point_plus1.x, -point_plus1.y, point_plus2.x, -point_plus2.y); + offset+=2; + } else { + // s = new QuadCurve2D.Float(point.x,-point.y,point_plus1.x,-point_plus1.y, + // midValue(point_plus1.x, point_plus2.x), -midValue(point_plus1.y, point_plus2.y)); + gp.quadTo(point_plus1.x, -point_plus1.y, midValue(point_plus1.x, point_plus2.x), -midValue(point_plus1.y, point_plus2.y)); + offset+=2; + } + } + } else { + if (point_plus1.onCurve) { + // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), -midValue(point_minus1.y, point.y), + // point.x, -point.y, point_plus1.x, -point_plus1.y); + //gp.curve3(point_plus1.x, -point_plus1.y, point.x, -point.y); + gp.quadTo(point.x, -point.y, point_plus1.x, -point_plus1.y); + offset++; + + } else { + // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), -midValue(point_minus1.y, point.y), point.x, -point.y, + // midValue(point.x, point_plus1.x), -midValue(point.y, point_plus1.y)); + //gp.curve3(midValue(point.x, point_plus1.x), -midValue(point.y, point_plus1.y), point.x, -point.y); + gp.quadTo(point.x, -point.y, midValue(point.x, point_plus1.x), -midValue(point.y, point_plus1.y)); + offset++; + } + } } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java index 5afb939ab..6b3dc1f6f 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java @@ -72,9 +72,9 @@ public class Mnemonic { public static final short RS = 0x43; public static final short WCVTP = 0x44; public static final short RCVT = 0x45; - public static final short GC = 0x46; // [a] + public static final short GC = 0x46; // [a] public static final short SCFS = 0x48; - public static final short MD = 0x49; // [a] + public static final short MD = 0x49; // [a] public static final short MPPEM = 0x4B; public static final short MPS = 0x4C; public static final short FLIPON = 0x4D; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java index 17b5af594..6e7e76bc7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java @@ -182,8 +182,8 @@ public class OTFont { } public OTGlyph getGlyph(int i) { - - final GlyfDescript _glyfDescr = _glyf.getDescription(i); + + final GlyfDescript _glyfDescr = _glyf.getDescription(i); return (null != _glyfDescr) ? new OTGlyph( _glyfDescr, diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java index 4b6242d56..5c004246a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java @@ -103,7 +103,7 @@ public class OTGlyph { } public AABBox getBBox() { - return _bbox; + return _bbox; } public int getAdvanceWidth() { @@ -164,6 +164,6 @@ public class OTGlyph { // _points[gd.getPointCount()] = new Point(0, 0, true, true); // _points[gd.getPointCount()+1] = new Point(_advanceWidth, 0, true, true); - _bbox = new AABBox(gd.getXMinimum(), gd.getYMinimum(), 0, gd.getXMaximum(), gd.getYMaximum(), 0); + _bbox = new AABBox(gd.getXMinimum(), gd.getYMinimum(), 0, gd.getXMaximum(), gd.getYMaximum(), 0); } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java index ed82f2654..4804c35f2 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java @@ -175,15 +175,15 @@ public class PostTable implements Table { "lessequal", // 148 "greaterequal", // 149 "yen", // 150 - "mu", // 151 + "mu", // 151 "partialdiff", // 152 "summation", // 153 "product", // 154 - "pi", // 155 + "pi", // 155 "integral'", // 156 "ordfeminine", // 157 "ordmasculine", // 158 - "Omega", // 159 + "Omega", // 159 "ae", // 160 "oslash", // 161 "questiondown", // 162 diff --git a/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java b/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java index 252c6acc4..a659a7003 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java @@ -140,8 +140,8 @@ public class Interpreter { private void _deltac1() { int n = pop(); for (int i = 0; i < n; i++) { - pop(); // pn - pop(); // argn + pop(); // pn + pop(); // argn } } @@ -151,8 +151,8 @@ public class Interpreter { private void _deltac2() { int n = pop(); for (int i = 0; i < n; i++) { - pop(); // pn - pop(); // argn + pop(); // pn + pop(); // argn } } @@ -162,8 +162,8 @@ public class Interpreter { private void _deltac3() { int n = pop(); for (int i = 0; i < n; i++) { - pop(); // pn - pop(); // argn + pop(); // pn + pop(); // argn } } @@ -173,8 +173,8 @@ public class Interpreter { private void _deltap1() { int n = pop(); for (int i = 0; i < n; i++) { - pop(); // pn - pop(); // argn + pop(); // pn + pop(); // argn } } @@ -184,8 +184,8 @@ public class Interpreter { private void _deltap2() { int n = pop(); for (int i = 0; i < n; i++) { - pop(); // pn - pop(); // argn + pop(); // pn + pop(); // argn } } @@ -195,8 +195,8 @@ public class Interpreter { private void _deltap3() { int n = pop(); for (int i = 0; i < n; i++) { - pop(); // pn - pop(); // argn + pop(); // pn + pop(); // argn } } @@ -407,12 +407,12 @@ public class Interpreter { * to inhibit grid-fitting when a glyph is being rotated or stretched, use the * following sequence on the preprogram: * - * PUSHB[000] 6 ; ask GETINFO to check for stretching or rotation - * GETINFO[] ; will push TRUE if glyph is stretched or rotated - * IF[] ; tests value at top of stack - * PUSHB[000] 1 ; value for INSTCTRL - * PUSHB[000] 1 ; selector for INSTCTRL - * INSTRCTRL[] ; based on selector and value will turn grid-fitting off + * PUSHB[000] 6 ; ask GETINFO to check for stretching or rotation + * GETINFO[] ; will push TRUE if glyph is stretched or rotated + * IF[] ; tests value at top of stack + * PUSHB[000] 1 ; value for INSTCTRL + * PUSHB[000] 1 ; selector for INSTCTRL + * INSTRCTRL[] ; based on selector and value will turn grid-fitting off * EIF[] * * Selector flag 2 is used to establish that any parameters set in the CVT program @@ -923,8 +923,8 @@ public class Interpreter { * Set Freedom_Vector From Stack */ private void _sfvfs() { - gs.freedom_vector[1] = pop(); // y - gs.freedom_vector[0] = pop(); // x + gs.freedom_vector[1] = pop(); // y + gs.freedom_vector[0] = pop(); // x } /* @@ -988,9 +988,9 @@ public class Interpreter { * USES: loop */ private void _shpix() { - pop(); // amount + pop(); // amount while (gs.loop-- > 0) { - pop(); // p + pop(); // p } gs.loop = 1; } @@ -1017,8 +1017,8 @@ public class Interpreter { * Set Projection_Vector From Stack */ private void _spvfs() { - gs.projection_vector[1] = pop(); // y - gs.projection_vector[0] = pop(); // x + gs.projection_vector[1] = pop(); // y + gs.projection_vector[0] = pop(); // x } /* diff --git a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java index 3e2a594c5..79e842887 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java @@ -80,14 +80,14 @@ public class AffineTransform implements Cloneable, Serializable { } public AffineTransform(Factory<? extends Vertex> factory) { - pointFactory = factory; + pointFactory = factory; type = TYPE_IDENTITY; m00 = m11 = 1.0f; m10 = m01 = m02 = m12 = 0.0f; } public AffineTransform(AffineTransform t) { - this.pointFactory = t.pointFactory; + this.pointFactory = t.pointFactory; this.type = t.type; this.m00 = t.m00; this.m10 = t.m10; @@ -98,7 +98,7 @@ public class AffineTransform implements Cloneable, Serializable { } public AffineTransform(Vertex.Factory<? extends Vertex> factory, float m00, float m10, float m01, float m11, float m02, float m12) { - pointFactory = factory; + pointFactory = factory; this.type = TYPE_UNKNOWN; this.m00 = m00; this.m10 = m10; @@ -109,7 +109,7 @@ public class AffineTransform implements Cloneable, Serializable { } public AffineTransform(Vertex.Factory<? extends Vertex> factory, float[] matrix) { - pointFactory = factory; + pointFactory = factory; this.type = TYPE_UNKNOWN; m00 = matrix[0]; m10 = matrix[1]; @@ -316,25 +316,25 @@ public class AffineTransform implements Cloneable, Serializable { } public static <T extends Vertex> AffineTransform getScaleInstance(Vertex.Factory<? extends Vertex> factory, float scx, float scY) { - AffineTransform t = new AffineTransform(factory); + AffineTransform t = new AffineTransform(factory); t.setToScale(scx, scY); return t; } public static <T extends Vertex> AffineTransform getShearInstance(Vertex.Factory<? extends Vertex> factory, float shx, float shy) { - AffineTransform t = new AffineTransform(factory); + AffineTransform t = new AffineTransform(factory); t.setToShear(shx, shy); return t; } public static <T extends Vertex> AffineTransform getRotateInstance(Vertex.Factory<? extends Vertex> factory, float angle) { - AffineTransform t = new AffineTransform(factory); + AffineTransform t = new AffineTransform(factory); t.setToRotation(angle); return t; } public static <T extends Vertex> AffineTransform getRotateInstance(Vertex.Factory<? extends Vertex> factory, float angle, float x, float y) { - AffineTransform t = new AffineTransform(factory); + AffineTransform t = new AffineTransform(factory); t.setToRotation(angle, x, y); return t; } @@ -391,7 +391,7 @@ public class AffineTransform implements Cloneable, Serializable { throw new NoninvertibleTransformException(determinantIsZero); } return new AffineTransform( - this.pointFactory, + this.pointFactory, m11 / det, // m00 -m10 / det, // m10 -m01 / det, // m01 @@ -401,9 +401,9 @@ public class AffineTransform implements Cloneable, Serializable { ); } - public Vertex transform(Vertex src, Vertex dst) { + public Vertex transform(Vertex src, Vertex dst) { if (dst == null) { - dst = pointFactory.create(); + dst = pointFactory.create(); } float x = src.getX(); @@ -415,12 +415,12 @@ public class AffineTransform implements Cloneable, Serializable { public void transform(Vertex[] src, int srcOff, Vertex[] dst, int dstOff, int length) { while (--length >= 0) { - Vertex srcPoint = src[srcOff++]; + Vertex srcPoint = src[srcOff++]; float x = srcPoint.getX(); float y = srcPoint.getY(); Vertex dstPoint = dst[dstOff]; if (dstPoint == null) { - throw new IllegalArgumentException("dst["+dstOff+"] is null"); + throw new IllegalArgumentException("dst["+dstOff+"] is null"); } dstPoint.setCoord(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); dst[dstOff++] = dstPoint; @@ -444,9 +444,9 @@ public class AffineTransform implements Cloneable, Serializable { } } - public Vertex deltaTransform(Vertex src, Vertex dst) { + public Vertex deltaTransform(Vertex src, Vertex dst) { if (dst == null) { - dst = pointFactory.create(); + dst = pointFactory.create(); } float x = src.getX(); @@ -465,13 +465,13 @@ public class AffineTransform implements Cloneable, Serializable { } } - public Vertex inverseTransform(Vertex src, Vertex dst) throws NoninvertibleTransformException { + public Vertex inverseTransform(Vertex src, Vertex dst) throws NoninvertibleTransformException { float det = getDeterminant(); if (MathFloat.abs(det) < ZERO) { - throw new NoninvertibleTransformException(determinantIsZero); + throw new NoninvertibleTransformException(determinantIsZero); } if (dst == null) { - dst = pointFactory.create(); + dst = pointFactory.create(); } float x = src.getX() - m02; @@ -486,7 +486,7 @@ public class AffineTransform implements Cloneable, Serializable { { float det = getDeterminant(); if (MathFloat.abs(det) < ZERO) { - throw new NoninvertibleTransformException(determinantIsZero); + throw new NoninvertibleTransformException(determinantIsZero); } while (--length >= 0) { diff --git a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java index 431891361..edeabaa40 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java @@ -243,11 +243,11 @@ public final class Path2D implements Cloneable { } final public int size() { - return typeSize; + return typeSize; } final public boolean isClosed() { - return typeSize > 0 && types[typeSize - 1] == PathIterator.SEG_CLOSE ; + return typeSize > 0 && types[typeSize - 1] == PathIterator.SEG_CLOSE ; } public void closePath() { @@ -258,7 +258,7 @@ public final class Path2D implements Cloneable { } public String toString() { - return "[size "+size()+", closed "+isClosed()+"]"; + return "[size "+size()+", closed "+isClosed()+"]"; } public void append(Path2D path, boolean connect) { diff --git a/src/jogl/classes/jogamp/graph/math/plane/Crossing.java b/src/jogl/classes/jogamp/graph/math/plane/Crossing.java index 8f8638632..2138b217d 100644 --- a/src/jogl/classes/jogamp/graph/math/plane/Crossing.java +++ b/src/jogl/classes/jogamp/graph/math/plane/Crossing.java @@ -385,12 +385,12 @@ public class Crossing { // START if (x == x1) { - return x1 < x2 ? 0 : -1; + return x1 < x2 ? 0 : -1; } // END if (x == x2) { - return x1 < x2 ? 1 : 0; + return x1 < x2 ? 1 : 0; } // INSIDE-DOWN @@ -496,9 +496,9 @@ public class Crossing { // checks if the point (x,y) is the vertex of shape with PathIterator p if (x == cx && y == cy) { - cross = 0; - cy = my; - break; + cross = 0; + cy = my; + break; } p.next(); } |