diff options
author | Rami Santina <[email protected]> | 2011-04-08 17:31:17 +0300 |
---|---|---|
committer | Rami Santina <[email protected]> | 2011-04-08 17:31:17 +0300 |
commit | 7cd27e4daf27b730908f0b929385bffc2fa3c41d (patch) | |
tree | 0c452e68cb64ee416719d17b0a1e1e94a1e87da2 | |
parent | a140ed4798896ed5d786fbe63e7241309a4b4a91 (diff) |
Added getBounds impl to region, returning AABBox
3 files changed, 24 insertions, 2 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 051cb1c38..40161f067 100755 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -29,6 +29,7 @@ package com.jogamp.graph.curve; import java.util.ArrayList;
+import com.jogamp.graph.geom.AABBox;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.opengl.util.PMVMatrix;
@@ -117,6 +118,8 @@ public interface Region { */
public void destroy();
+ public AABBox getBounds();
+
public boolean isFlipped();
/** Set if the y coordinate of the region should be flipped
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java index 075a65ec9..94293a947 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java @@ -121,6 +121,7 @@ public class VBORegion2PES2 implements Region{ verticesBuffer.put(v.getY()); } verticesBuffer.put(v.getZ()); + if(flipped){ box.resize(v.getX(), -1*v.getY(), v.getZ()); } @@ -347,4 +348,8 @@ public class VBORegion2PES2 implements Region{ 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 701549d46..8f83d4d04 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -37,6 +37,7 @@ import javax.media.opengl.GLContext; import com.jogamp.common.nio.Buffers; import com.jogamp.graph.curve.Region; +import com.jogamp.graph.geom.AABBox; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Triangle; import com.jogamp.opengl.util.PMVMatrix; @@ -55,11 +56,14 @@ public class VBORegionSPES2 implements Region{ 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(); ShortBuffer indicies = Buffers.newDirectShortBuffer(triangles.size() * 3); @@ -93,14 +97,21 @@ public class VBORegionSPES2 implements Region{ FloatBuffer verticesBuffer = Buffers.newDirectFloatBuffer(vertices.size() * 3); for(Vertex v:vertices){ - verticesBuffer.put(v.getX()); + if(flipped){ + verticesBuffer.put(v.getX()); verticesBuffer.put(-1*v.getY()); + verticesBuffer.put(v.getZ()); + + box.resize(v.getX(),-1*v.getY(),v.getZ()); } else{ + verticesBuffer.put(v.getX()); verticesBuffer.put(v.getY()); + verticesBuffer.put(v.getZ()); + + box.resize(v.getX(),v.getY(),v.getZ()); } - verticesBuffer.put(v.getZ()); } verticesBuffer.rewind(); @@ -182,4 +193,7 @@ public class VBORegionSPES2 implements Region{ public void setFlipped(boolean flipped) { this.flipped = flipped; } + public AABBox getBounds(){ + return box; + } } |